<?php
// macos_textutil_convert.php
// Supervise macOS (via PHP exec) textutil (command line) conversions
// 8: /usr/bin/pandoc -t html "/tmp/xx.docx" -o "/tmp/FileZilla.html" > macos_textutil_convert.out 2> macos_textutil_convert.err; rm -f /tmp/xx.docx
/*     
textutil: [command_option] [other_options] file...
Command options are (-help is the default):
 -help          show this message and exit
 -info          display information about each file
 -convert fmt   convert each input file to format (txt, rtf, rtfd,
                html, doc, docx, odt, wordml, or webarchive)
 -cat fmt       concatenate input files into one output file
There are some additional optional arguments:
 -extension ext alternate extension for all output files
 -output path   alternate file name for first output file
 -stdin         read from stdin instead of files
 -stdout        send first output file to stdout
 -encoding IANA_name|NSStringEncoding
                encoding used for plain text or html output files
                (default encoding is UTF-8)
 -inputencoding IANA_name|NSStringEncoding
                encoding used to interpret plain text input files
                (by default encoding will be detected from BOM)
 -format fmt    force input files to be interpreted in this format
 -font font     specify font used for converting plain to rich text
 -fontsize size specify font size for converting plain to rich text
 --             specifies that all further arguments are file names

 -noload        do not load subsidiary resources for html files
 -nostore       do not write out subsidiary resources for html files
 -baseurl url   base URL for subsidiary resources in html files
 -timeout t     time in seconds to wait for html resources to load
 -textsizemultiplier x
                factor to apply to font sizes in html files
 -excludedelements "(tag1, tag2, ...)"
                html elements to exclude from html output files
 -prefixspaces n
                number of spaces to indent nested html output

 -strip         do not copy metadata attributes to output files
 -title val     title metadata attribute for output files
 -author val    author metadata attribute for output files
 -subject val   subject metadata attribute for output files
 -keywords "(val1, val2, ...)"
                keywords metadata attribute for output files
 -comment val   comment metadata attribute for output files
 -editor val    last editor metadata attribute for output files
 -company val   company metadata attribute for output files
 -creationtime yyyy-mm-ddThh:mm:ssZ
                creation time metadata attribute for output files
 -modificationtime yyyy-mm-ddThh:mm:ssZ
                modification time metadata attribute for output files
*/
ini_set('max_execution_time', 6000); 

$opth="";
$wobit="";
$switchfrom=" txt ";
$switchto=" txt ";

function server_remote_addr() {
    $rma = $_SERVER['REMOTE_ADDR'];
    $ua = strtolower($_SERVER['HTTP_USER_AGENT']);
    // you can add different browsers with the same way ..
    if (1 == 1) {
    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));
} 

if (file_exists('/tmp/wobit' . server_remote_addr() . '.xxx')) {
   $wobit=file_get_contents('/tmp/wobit' . server_remote_addr() . '.xxx');
   unlink('/tmp/wobit' . server_remote_addr() . '.xxx');
}

  $rjm='rjmprogramming.com.au';
  $whereplace=shell_exec("ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'");
  if (strpos(($whereplace . ' ' . $_SERVER['SERVER_ADDR']), '65.254.92.213') !== false) { //65.254.95.247') !== false) {
     $rjm='youllneverfindthis';
     $switchto=" plain ";
if (isset($_GET['outpath'])) {
   $_GET['outpath']=urlencode('/tmp/');
} else if (isset($_POST['outpath'])) {
   $_POST['outpath']=urlencode('/tmp/');
} else if (isset($_GET['outputname'])) {
   $_GET['outpath']=urlencode('/tmp/');
} else if (isset($_POST['outputname'])) {
   $_POST['outpath']=urlencode('/tmp/');
}    
  } else if (strpos(($whereplace . ' ' . $_SERVER['SERVER_ADDR']), '65.254.95.247') !== false) {
     $opth="/tmp/' readonly ";
     $rjm='youllneverfindthis';
     $switchto=" plain ";
if (isset($_GET['outpath'])) {
   $_GET['outpath']=urlencode('/tmp/');
} else if (isset($_POST['outpath'])) {
   $_POST['outpath']=urlencode('/tmp/');
} else if (isset($_GET['outputname'])) {
   $_GET['outpath']=urlencode('/tmp/');
} else if (isset($_POST['outputname'])) {
   $_POST['outpath']=urlencode('/tmp/');
}     
  }


$pltx="";
$avbit="out";  
$resbit="";  
$lportbit=":8888";
$imgn='imgm' . rand(0,1298765434) . '.gif';
$qindx=-1;
$divinfront="";
$rone="";
$rtwo="";
$resultof="";
$curt="";

if (isset($_GET['inpath'])) {
      $ona=str_replace('+',' ',urldecode($_GET['outputname']));
      if (strpos($ona, ',') !== false) {
      $resultof='<p>Result of Conversion from ' . str_replace('+',' ',urldecode($_GET['inpath'])) . str_replace('+',' ',urldecode((isset($_GET['dummyconvertthis']) ? $_GET['dummyconvertthis'] : (isset($_GET['convertthis']) ? $_GET['convertthis'] : '')))) . ' to ' . explode(',',$ona)[1] . ' ... </p><br><div id=dres></div>';
      } else {
      $resultof='<p>Result of Conversion from ' . str_replace('+',' ',urldecode($_GET['inpath'])) . str_replace('+',' ',urldecode((isset($_GET['dummyconvertthis']) ? $_GET['dummyconvertthis'] : (isset($_GET['convertthis']) ? $_GET['convertthis'] : '')))) . ' to ' . str_replace('+',' ',urldecode($_GET['outputname'])) . ' ... </p><br><div id=dres></div>';
      }
} else if (isset($_POST['inpath'])) {
      $ona=str_replace('+',' ',urldecode($_POST['outputname']));
      if (strpos($ona, ',') !== false) {
      $resultof='<p>Result of Conversion from ' . str_replace('+',' ',urldecode($_POST['inpath'])) . str_replace('+',' ',urldecode((isset($_POST['dummyconvertthis']) ? $_POST['dummyconvertthis'] : (isset($_POST['convertthis']) ? $_POST['convertthis'] : '')))) . ' to ' . explode(',',$ona)[1] . ' ... </p><br><div id=dres></div>';
      } else {
      $resultof='<p>Result of Conversion from ' . str_replace('+',' ',urldecode($_POST['inpath'])) . str_replace('+',' ',urldecode((isset($_POST['dummyconvertthis']) ? $_POST['dummyconvertthis'] : (isset($_POST['convertthis']) ? $_POST['convertthis'] : '')))) . ' to ' . str_replace('+',' ',urldecode($_POST['outputname'])) . ' ... </p><br><div id=dres></div>';
      }
}

if (isset($_GET['content']) || isset($_POST['content'])) {
  $curt=" document.body.style.cursor='progress'; ";
}

function switcheroo($swi) {
  global $switchfrom, $switchto;
  return str_replace($switchfrom,$switchto,$swi);
}

function theecho($ofwhat) {
  file_put_contents('abc.xyz', $ofwhat);
}

function big($invc) {
  global $indx, $qindx, $wobit;
  $qindx=-1;
  if ((0 + sizeof(explode(',',$invc))) > (1 + $indx)) {
    if (strlen(explode(',',$invc)[(1 + $indx)]) > strlen(explode(',',$invc)[(0 + $indx)])) {
      $qindx=(1 + $indx);
    }
  }
  return $invc;
}
  

$user_agent = $_SERVER["HTTP_USER_AGENT"];
function getOS() { // thanks to https://www.daniweb.com/programming/web-development/threads/495588/getting-users-os-info-out-of-server-http-user-agent
    global $user_agent, $lportbit;
    $os_platform    =   "win Unknown OS Platform";
    $os_array       =   array(
                            '/windows nt 10/i'     =>  'Windows 10',
                            '/windows nt 6.3/i'     =>  'Windows 8.1',
                            '/windows nt 6.2/i'     =>  'Windows 8',
                            '/windows nt 6.1/i'     =>  'Windows 7',
                            '/windows nt 6.0/i'     =>  'Windows Vista',
                            '/windows nt 5.2/i'     =>  'Windows Server 2003/XP x64',
                            '/windows nt 5.1/i'     =>  'Windows XP',
                            '/windows xp/i'         =>  'Windows XP',
                            '/windows nt 5.0/i'     =>  'Windows 2000',
                            '/windows me/i'         =>  'Windows ME',
                            '/win98/i'              =>  'Windows 98',
                            '/win95/i'              =>  'Windows 95',
                            '/win16/i'              =>  'Windows 3.11',
                            '/macintosh|mac os x/i' =>  'Mac OS X',
                            '/mac_powerpc/i'        =>  'Mac OS 9',
                            '/linux/i'              =>  'Linux',
                            '/ubuntu/i'             =>  'Ubuntu',
                            '/iphone/i'             =>  'iPhone',
                            '/ipod/i'               =>  'iPod',
                            '/ipad/i'               =>  'iPad',
                            '/android/i'            =>  'Android',
                            '/blackberry/i'         =>  'BlackBerry',
                            '/webos/i'              =>  'Mobile'
                        );

    foreach ($os_array as $regex => $value) { 

        if (preg_match($regex, $user_agent)) {
            $os_platform    =   $value;
        }

    }   

    return $os_platform;
}

if (substr(strtoupper(getOS()),0,3) === 'WIN') { $lportbit="";  }

if (isset($_GET['imgname'])) {
  if (1 == 5) {
  $im = imagecreatetruecolor(120, 10);
  $text_color = imagecolorallocate($im, 233, 14, 91);
  file_put_contents('aaaa.aaaa3', '');
  imagestring($im, 1, 5, 5,  'A Simple Text String', $text_color);
  // Output the image
  imagegif($im, urldecode($_GET['imgname']));
  // Free up memory
  imagedestroy($im);
  sleep(25);
  unlink(urldecode($_GET['imgname']));
  }
  echo "<html><body onload=\"    var asu=(('" . $_SERVER['QUERY_STRING'] . "').replace('&','?') + '?');  asu=('?' + asu.split('?')[1]).replace(/^\?$/g,'');  if (document.URL.indexOf('localhost') != -1) { window.open(document.URL.split('?')[0] + asu,'_blank'); }\"></body></html>";
  exit;
}


$innards="";
$innards=" if (!inIframe()) { if (document.URL.indexOf('httJUNKp:') == 0) { wowo=window.open('HTTP:/localhost" . $lportbit . "/macos_textutil_convert.php','mamptry'); document.getElementById('mamptry').style.display='block'; } else { windowopen('HTTP:/localhost" . $lportbit . "/macos_textutil_convert.php','blank');  } } ";

$thecontent="";
$tastuff="";
$doutput="";
$outfileis="";
$sufext="_0";
$iext=0;
$cself="";

$verb="textutil";
$switchone="-convert";
$switchtwo="-output";

$indx=0;
$iof=0;

$cvse="Convert";
$title="<title>Document Conversions via pandoc or textutil</title>";
$onl=" if (!navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { if (!window.parent) { document.getElementById('thewords').focus(); } else { if (window.parent == window.self) {  document.getElementById('thewords').focus();   }  } } ";

$iphone = strpos($_SERVER['HTTP_USER_AGENT'],"iPhone");
$ipad = strpos($_SERVER['HTTP_USER_AGENT'],"iPad");
$android = strpos($_SERVER['HTTP_USER_AGENT'],"Android");
$blackberry = strpos($_SERVER['HTTP_USER_AGENT'],"BlackBerry");
$ipod = strpos($_SERVER['HTTP_USER_AGENT'],"iPod");

$outfis='';

$precmds="";

function yourfile_get_contents($inff) {
   $jinff=@file_get_contents($inff);
   if (isset($_POST['content']) || isset($_GET['content'])) {
      if (strpos($jinff, 'No such file or directory') !== false) {
        return '';
      }
   }
   return $jinff;
}

function inf($indi) {
  if (isset($_POST['infname'])) {
    $pif=str_replace('+',' ',urldecode($_POST['infname']));
    $arrpif=explode('.', $pif);
    if (sizeof($arrpif) > 1) {
      return $arrpif[(-1 + sizeof($arrpif))];
    }
  }
  return $indi;
}

function getxenv($one,$two) {
  global $precmds;
  foreach (glob("C:\\Users\\*\\AppData\\Local\\Pandoc\\pandoc.exe") as $infl) {
  $precmds=explode("\\AppData", $infl)[0] . "\\AppData\\Local\\Programs\\MiKTeX\\miktex\\bin\\x64\\";
  return str_replace("\\","\\\\",explode("\\AppData", $infl)[0]);
  }
  return "C:\\Users\\user";
}

if ( !file_exists( "/usr/local/bin" ) && !is_dir( "/usr/local/bin" ) &&  !file_exists( "/usr/bin" ) && !is_dir( "/usr/bin" ) ) {
if (getxenv("USERPROFILE",true)) {
    if (file_exists(getxenv("USERPROFILE",true) . "\\AppData\\Local\\Pandoc\\pandoc.exe")) {
      $verb=getxenv("USERPROFILE",true) . "\\AppData\\Local\\Pandoc\\pandoc.exe";
      $switchone="-t";
      $switchtwo="-o";
      $panplus="pandoc or ";
    }
}
} else {
//exec("which pandoc > lookup_pandoc.txt 2>>&1");
//shell_exec("/usr/local/bin/pandoc --version > lookup_pandoc.txt 2>&1");
    if (file_exists("/usr/bin/pandoc")) {
      $verb="/usr/bin/pandoc";
      $switchone="-t";
      $switchtwo="-o";
      $panplus="pandoc or ";
if (PHP_OS != "Darwin") {     
if (isset($_GET['outpath'])) {
   $_GET['outpath']='';
} else if (isset($_POST['outpath'])) {
   $_POST['outpath']='';
}
}
    } else if (file_exists("/usr/local/bin/pandoc")) {
      $verb="/usr/local/bin/pandoc";
      $switchone="-t";
      $switchtwo="-o";
      $panplus="pandoc or ";
if (PHP_OS != "Darwin") {     
if (isset($_GET['outpath'])) {
   $_GET['outpath']='';
} else if (isset($_POST['outpath'])) {
   $_POST['outpath']='';
}
}
    }
}


 if (isset($argv)) { // command line
  $numargs = sizeof($argv);
  if ($numargs <= 4) {
   if (PHP_OS == 'WINNT') {
    echo '$ Input path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then *.pdf,*.doc,*.docx,*.htm,*.html,*.txt Input File(spec) then Output path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then .pdf,.doc,.docx,.htm,.html,.txt Output File Extension below ...' . "\n";
    $line = stream_get_line(STDIN, 1024, PHP_EOL);
    if (str_replace("\n", "", $line) == "") { $line=dirname(__FILE__) . DIRECTORY_SEPARATOR; }
    $lineinspec = stream_get_line(STDIN, 1024, PHP_EOL);
    $outline = stream_get_line(STDIN, 1024, PHP_EOL);
    if (str_replace("\n", "", $outline) == "") { $outline=dirname(__FILE__) . DIRECTORY_SEPARATOR; }
    $outlineinspec = stream_get_line(STDIN, 1024, PHP_EOL);
    if (strpos(($outlineinspec . "~"), "htm~") !== false) {  $outlineinspec.="l";   }
   } else {
    $line = readline('$ Input path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then *.pdf,*.doc,*.docx,*.htm,*.html,*.txt Input File(spec) then Output path ( eg. we will take blank to mean ' . dirname(__FILE__) . DIRECTORY_SEPARATOR . ' ) then .pdf,.doc,.docx,.htm,.html,.txt Output File Extension below ...' . "\n");
    if (str_replace("\n", "", $line) == "") { $line=dirname(__FILE__) . DIRECTORY_SEPARATOR; }
    $lineinspec = readline('');
    $outline = readline('');
    if (str_replace("\n", "", $outline) == "") { $outline=dirname(__FILE__) . DIRECTORY_SEPARATOR; }
    $outlineinspec = readline('');
    if (strpos(($outlineinspec . "~"), "htm~") !== false) {  $outlineinspec.="l";   }
   }
  $cmdsuff="";
  if ($verb != "textutil" && explode(".",$outlineinspec)[-1 + sizeof(explode(".",$outlineinspec))] == "pdf") {
  if (file_exists("/Library/TeX/Root/bin/x86_64-darwin/pdflatex")) {
  $cmdsuff=" --pdf-engine=/Library/TeX/Root/bin/x86_64-darwin/pdflatex";
  } else if (file_exists("/Library/TeX/texbin/pdflatex")) {
  $cmdsuff=" --pdf-engine=/Library/TeX/texbin/pdflatex";
  } else {
  $cmdsuff=" --pdf-engine=" . $precmds . "pdflatex";
  }
  }
   $openers="";
   $openersdelim="";
  echo $line . $lineinspec;
  exit;
   foreach (glob($line . $lineinspec) as $filename) {    
    $outnameis=$outline . str_replace("." . explode(".", basename($filename))[-1 + sizeof(explode(".", basename($filename)))], ".", basename($filename)) . str_replace(".", "", $outlineinspec);
  if (file_exists($outnameis)) {
  $sufext="_0";
  $iext=0;
  $rone="";
  $rtwo="";
    while (file_exists($outnameis . $sufext)) {
      $iext++;
      $sufext="_" . $iext;
    }
    $rtwo=$outnameis;
    $rone=$outnameis . $sufext;
    echo "Renaming " . $outnameis . " to " . $outnameis . $sufext . "\n";
    try {
    rename($outnameis, $outnameis . $sufext);
    } catch (Exception $e) {
    echo $e->getMessage() . "\n";
    }
    if (!file_exists($outnameis . $sufext)) {
    echo "Renaming did not happen." . "\n";
    }
  }
    if (explode(".",$outlineinspec)[-1 + sizeof(explode(".",$outlineinspec))] == "pdJUNKf") {
    echo ("php " . $argv[0] . " " . $line . " " . basename($filename) . " " . $outline . " " . $outlineinspec . "\n");
    passthru("php " . $argv[0] . " " . $line . " " . basename($filename) . " " . $outline . " " . $outlineinspec);
    } else {

 //echo $verb . " " . $switchone . " " . str_replace(".", "", $outlineinspec) . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff;
 //exit;

    //echo ($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convertHUH.out 2> macos_textutil_convert.err");
    file_put_contents("macos_textutil_convertYES.out",$verb . "   " . $switchone . " " . str_replace(".", "", $outlineinspec) . " " . $filename . " " . $switchtwo . " \"" . $outnameis . "\"" . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err \n");
    if (isset($_POST['content'])) {
    //echo "yes";
    //exit;
    $befbsf=str_replace(' ','+', urldecode($_POST['content']));
    file_put_contents('/tmp/xx.' . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))), base64_decode(explode(';base64,',$befbsf)[1]));
//theecho("1:" . "$verb" . " " . $switchone . " " . "/tmp/xx." . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))) . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err ; rm -f " . "/tmp/xx." . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))));
//exit;
    exec("$verb" . " " . $switchone . switcheroo(" " . "/tmp/xx." . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))) . " ") . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err ; rm -f " . "/tmp/xx." . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))));

  $mimt=inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0]))));
  //file_put_contents("abc.xzy",yourstr_replace("+"," ",big(urldecode($_POST['outputname']))) );
  if ($mimt == 'html' && file_exists($outnameis)) {
  //file_put_contents("abc.xz2",yourstr_replace("+"," ",big(urldecode($_POST['outputname']))) );
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body>" . $ocontis . "</body></html>";
     }
  //file_put_contents("abc.xz3",$ocontis );
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );

     //echo "<html><body onload=\" " . $wobit . " \"></body></html>";   // might be temporary arrangement
     //exit;
  } else if ($mimt == "pdf") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/pdf;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if (substr($mimt,0,3) == "rtf") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/rtf;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if ($mimt == "odt") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/vnd.oasis.opendocument.text;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit ); 
  } else if (substr($mimt,0,3) == "doc") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit ); 
  } else if (str_replace('plain','txt',str_replace('text','txt',$mimt)) == "txt") {
     $ocontis=file_get_contents($outnameis);
     $pltx=$ocontis;
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><div>" . str_replace("\n","<br>",$ocontis) . "\"></div><br></body></html>";
     }
     $wobit=" top.document.getElementById('dres').style.width='98%'; top.document.getElementById('dres').style.height='30%'; top.document.getElementById('dres').innerHTML='<textarea style=width:98%;height:98%;>' + window.atob('" . base64_encode($pltx) . "') + '</textarea>';    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit ); 
  }

    } else {
//theecho("2:" . "$verb" . " " . $switchone . " \"" . str_replace(".", "", $outlineinspec) . " " . $filename . "\" " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err");
//exit;
    exec("$verb" . " " . $switchone . switcheroo(" \"") . str_replace(".", "", $outlineinspec) . " " . $filename . "\" " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err");

  $mimt=str_replace(".", "", $outlineinspec);
  //file_put_contents("abc.xzy",yourstr_replace("+"," ",big(urldecode($_POST['outputname']))) );
  if ($mimt == 'html' && file_exists($outnameis)) {
  //file_put_contents("abc.xz2",yourstr_replace("+"," ",big(urldecode($_POST['outputname']))) );
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body>" . $ocontis . "</body></html>";
     }
  //file_put_contents("abc.xz3",$ocontis );
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );

     //echo "<html><body onload=\" " . $wobit . " \"></body></html>";   // might be temporary arrangement
     //exit;
  } else if ($mimt == "pdf") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\"  src=\"data:application/pdf;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if (substr($mimt,0,3) == "rtf") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/rtf;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if ($mimt == "odt") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/vnd.oasis.opendocument.text;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit ); 
  } else if (substr($mimt,0,3) == "doc") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit ); 
  } else if (str_replace('plain','txt',str_replace('text','txt',$mimt)) == "txt") {
     $ocontis=file_get_contents($outnameis);
     $pltx=$ocontis;
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><div>" . str_replace("\n","<br>",$ocontis) . "\"></div><br></body></html>";
     }
     $wobit=" top.document.getElementById('dres').style.width='98%'; top.document.getElementById('dres').style.height='30%'; top.document.getElementById('dres').innerHTML='<textarea style=width:98%;height:98%;>' + window.atob('" . base64_encode($pltx) . "') + '</textarea>';    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  }


    }
  if (file_exists("macos_textutil_convert.out") && file_exists("macos_textutil_convert.err")) {
  if (filesize("macos_textutil_convert.out") == 0 && filesize("macos_textutil_convert.err") != 0) {
     if ($rone != "" && $rtwo != "") {
    echo "Renaming " . $rone . " back to " . $rtwo . "\n";
      rename($rone, $rtwo);
     }
     echo "\n\n" . yourfile_get_contents("macos_textutil_convert.err") . "\n\n";
  }
  }
    if (PHP_OS == "Darwin") { // && explode(".",$outlineinspec)[-1 + sizeof(explode(".",$outlineinspec))] != "pdf") {
       if (file_exists($outnameis)) {
       $openers.=$openersdelim . "open " . $outnameis;
       $openersdelim=" ; ";
       }
    }
    }
   }
   if (PHP_OS == "Darwin" && $openers != "") {
    echo "\n\nWill try to open successful (or old resurrected) files in 8 seconds ...\n"; 
    sleep(8);
    echo ($openers . " \n");
    exec($openers);
   }
   //echo "do the work";
  } else {
   $openers="";
   $openersdelim="";
   $line=trim($argv[1]);
   if (str_replace("\n", "", $line) == "") { $line=dirname(__FILE__) . DIRECTORY_SEPARATOR; }
   $lineinspec=$argv[2];
   $outline=trim($argv[3]);
   if (str_replace("\n", "", $outline) == "") { $outline=dirname(__FILE__) . DIRECTORY_SEPARATOR; }
   $outlineinspec=$argv[4];
  $cmdsuff="";
  if ($verb != "textutil" && explode(".",$outlineinspec)[-1 + sizeof(explode(".",$outlineinspec))] == "pdf") {
  if (file_exists("/Library/TeX/Root/bin/x86_64-darwin/pdflatex")) {
  $cmdsuff=" --pdf-engine=/Library/TeX/Root/bin/x86_64-darwin/pdflatex";
  } else if (file_exists("/Library/TeX/texbin/pdflatex")) {
  $cmdsuff=" --pdf-engine=/Library/TeX/texbin/pdflatex";
  } else {
  $cmdsuff=" --pdf-engine=" . $precmds . "pdflatex";
  }
  }
  echo $line . $lineinspec;
  exit;
  foreach (glob($line . $lineinspec) as $filename) {   
     $outnameis=$outline . str_replace("." . explode(".", basename($filename))[-1 + sizeof(explode(".", basename($filename)))], ".", basename($filename)) . str_replace(".", "", $outlineinspec);
  if (file_exists($outnameis)) {
  $sufext="_0";
  $iext=0;
  $rone="";
  $rtwo="";
    while (file_exists($outnameis . $sufext)) {
      $iext++;
      $sufext="_" . $iext;
    }
    $rtwo=$outnameis;
    $rone=$outnameis . $sufext;
    echo "Renaming " . $outnameis . " to " . $outnameis . $sufext . "\n";
    rename($outnameis, $outnameis . $sufext);
  }



 //echo $verb . " " . $switchone . " " . str_replace(".", "", $outlineinspec) . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff;
 //exit;

    //echo ($verb . " " . $switchone . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convertHUH.out 2> macos_textutil_convert.err");
    file_put_contents("macos_textutil_convertYES.out",$verb . "     " . $switchone . " " . str_replace(".", "", $outlineinspec) . " " . $filename . " " . $switchtwo . " \"" . $outnameis . "\"" . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err \n");
    if (isset($_POST['content'])) {
    //echo "Yes";
    //exit;
    $befbsf=str_replace(' ','+', urldecode($_POST['content']));
    file_put_contents('/tmp/xx.' . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))), base64_decode(explode(';base64,',$befbsf)[1]));
//theecho("3:" . "$verb" . " " . $switchone . " " . "/tmp/xx." . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))) . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err ; rm -f " . "/tmp/xx." . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))));
//exit;
    exec("$verb" . " " . $switchone . switcheroo(" " . "/tmp/xx." . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))) . " ") . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err ; rm -f " . "/tmp/xx." . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))));


  $mimt=inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0]))));
  //file_put_contents("abc.xzy",yourstr_replace("+"," ",big(urldecode($_POST['outputname']))) );
  if ($mimt == 'html' && file_exists($outnameis)) {
  //file_put_contents("abc.xz2",yourstr_replace("+"," ",big(urldecode($_POST['outputname']))) );
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body>" . $ocontis . "</body></html>";
     }
  //file_put_contents("abc.xz3",$ocontis );
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );

     //echo "<html><body onload=\" " . $wobit . " \"></body></html>";   // might be temporary arrangement
     //exit;
  } else if ($mimt == "pdf") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\"  src=\"data:application/pdf;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if (substr($mimt,0,3) == "rtf") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/rtf;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if ($mimt == "odt") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/vnd.oasis.opendocument.text;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit ); 
  } else if (substr($mimt,0,3) == "doc") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit ); 
  } else if (str_replace('plain','txt',str_replace('text','txt',$mimt)) == "txt") {
     $ocontis=file_get_contents($outnameis);
     $pltx=$ocontis;
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><div>" . str_replace("\n","<br>",$ocontis) . "\"></div><br></body></html>";
     }
     $wobit=" top.document.getElementById('dres').style.width='98%'; top.document.getElementById('dres').style.height='30%'; top.document.getElementById('dres').innerHTML='<textarea style=width:98%;height:98%;>' + window.atob('" . base64_encode($pltx) . "') + '</textarea>';    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  }




    } else {
//theecho("4:" . "$verb" . " " . $switchone . " \"" . str_replace(".", "", $outlineinspec) . " " . $filename . "\" " . $switchtwo . " \"" . $outnameis . "\"" . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err");
//exit;
    exec("$verb" . " " . $switchone . switcheroo(" \"" . str_replace(".", "", $outlineinspec) . " ") . $filename . "\" " . $switchtwo . " \"" . $outnameis . "\"" . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err");


  $mimt=str_replace(".", "", $outlineinspec);
  //file_put_contents("abc.xzy",yourstr_replace("+"," ",big(urldecode($_POST['outputname']))) );
  if ($mimt == 'html' && file_exists($outnameis)) {
  //file_put_contents("abc.xz2",yourstr_replace("+"," ",big(urldecode($_POST['outputname']))) );
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body>" . $ocontis . "</body></html>";
     }
  //file_put_contents("abc.xz3",$ocontis );
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );

     //echo "<html><body onload=\" " . $wobit . " \"></body></html>";   // might be temporary arrangement
     //exit;
  } else if ($mimt == "pdf") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\"  src=\"data:application/pdf;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if (substr($mimt,0,3) == "rtf") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/rtf;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if ($mimt == "odt") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/vnd.oasis.opendocument.text;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit ); 
  } else if (substr($mimt,0,3) == "doc") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit ); 
  } else if (str_replace('plain','txt',str_replace('text','txt',$mimt)) == "txt") {
     $ocontis=file_get_contents($outnameis);
     $pltx=$ocontis;
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><div>" . str_replace("\n","<br>",$ocontis) . "\"></div><br></body></html>";
     }
     $wobit=" top.document.getElementById('dres').style.width='98%'; top.document.getElementById('dres').style.height='30%'; top.document.getElementById('dres').innerHTML='<textarea style=width:98%;height:98%;>' + window.atob('" . base64_encode($pltx) . "') + '</textarea>';    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  }




    }
  if (file_exists("macos_textutil_convert.out") && file_exists("macos_textutil_convert.err")) {
  if (filesize("macos_textutil_convert.out") == 0 && filesize("macos_textutil_convert.err") != 0) {
     if ($rone != "" && $rtwo != "") {
    echo "Renaming " . $rone . " back to " . $rtwo . "\n";
      rename($rone, $rtwo);
     }
     echo "\n\n" . yourfile_get_contents("macos_textutil_convert.err") . "\n\n";
  }
  }
    if (PHP_OS == "Darwin") { // && explode(".",$outlineinspec)[-1 + sizeof(explode(".",$outlineinspec))] != "pdf") {
       if (file_exists($outnameis)) {
       $openers.=$openersdelim . "open " . $outnameis;
       $openersdelim=" ; ";
       }
    }
   }
   if (PHP_OS == "Darwin" && $openers != "") {
    echo "\n\nWill try to open successful (or old resurrected) files in 8 seconds ...\n"; 
    sleep(8);
    echo ($openers . " \n");
    exec($openers);
   }
   //echo "Do the work ";
  }
  exit;
 }
 
 if (strpos($_SERVER['SERVER_NAME'], "rjmprogramming.com.au") !== false && 45 == 43) { 
   $cvse="Email";
   $title="<title>Email off your Document Conversion Attachment Input Files for Your Inhouse Document Converter to Listen For and Convert</title>";
   if ($iphone || $ipad || $android || $ipod || $blackberry) { // thanks to http://www.phpmysqlscript.com/2012/03/detecting-users-screen-size-and.html
   $cself="&nbsp;"; //&#129331;&nbsp;";
   $cvse="Email &#128231;";
   $divinfront="<button onmouseover='tsuper();' style='width:100%;height:100px;background-color:#ffffe0;' onclick='return ddforb(event);' id=dbwithlf>Email &#128231; Document(s)<div id=dbafterfirstline<br><br><div style='border:1px dashed #9b870c;' id=bdiv onmouseover='domo(event);' onmouseout='domout(event);' onmousedown='ionclick(event);' onclick='return ionclick(event);' onfocus='onf(event);' contenteditable=true onblur='donblur(this);' title='Click in to change email address as required'></div></div></button>";
   } else {
   $cvse="Email";
   $divinfront="<button onmouseover='tsuper();' style='width:100%;height:100px;background-color:#ffffe0;' onclick='return ddforb(event);' id=dbwithlf>Email Document(s)<div id=dbafterfirstline<br><br><div style='border:1px dashed #9b870c;' id=bdiv onmouseover='domo(event);' onmouseout='domout(event);' onmousedown='ionclick(event);' onclick='return ionclick(event);' onfocus='onf(event);' contenteditable=true onblur='donblur(this);' title='Click in to change email address as required'></div></div></button>";
   }
   $title="<title>Email off your Document Conversion Attachment Input Files for Your Inhouse Document Converter to Listen For and Convert</title>";
   $onl="";
 }
 
 if (isset($_POST['to']) && isset($_POST['subject']) && isset($_POST['body'])) {
   $tow=str_replace("+"," ",urldecode($_POST['to']));
   if (strpos($tow, "@") !== false) {
   $subjw=str_replace('*','html',str_replace("+"," ",urldecode($_POST['subject'])));
   $orign=basename(explode(" ", $subjw)[0]);
   $thenn=basename(explode(" ", $subjw)[-1 + sizeof(explode(" ", $subjw))]);
   $bodyn=str_replace(" ","+",urldecode($_POST['body']));
   if (strpos($bodyn, "data:") !== false) {
     file_put_contents($thenn, base64_decode(explode(";base64,", $bodyn)[1]));
   } else {
     file_put_contents($thenn, $bodyn);
   }
   if (1 == 1) { // thanks to https://community.hpe.com/t5/general/use-of-sendmail-and-uuencode/td-p/2431436#.XxqPtvgzZZo
   //$cmd="/usr/sbin/sendmail " . $tow . " << END\nSubject: " . $subjw . "\n`uuencode " . $thenn . " " . $thenn . "`\nEND";
   $cmd="/usr/sbin/sendmail " . $tow . " << END\nSubject: " . $subjw . "\n`uuencode " . $thenn . " " . $thenn . "`\nEND";
   //file_put_contents("00x.00x", $cmd);
   exec($cmd);
   exec("rm -f " . $thenn);
   } else {
   //file_put_contents("0x.0x", "uuencode " . $thenn . " " . $thenn . " > " . explode(".", $thenn)[0] . "; cat " . explode(".", $thenn)[0] . " | /usr/sbin/sendmail " . $tow . "; rm -f " . explode(".", $thenn)[0] . "; rm -f " . $thenn);
   //exec("uuencode " . $thenn . " " . $thenn . " > " . explode(".", $thenn)[0] . "; cat " . explode(".", $thenn)[0] . " | /usr/sbin/sendmail " . $tow . " > smail.out 2> smail.err; rm -f " . explode(".", $thenn)[0] . "; rm -f " . $thenn);
   exec("uuencode " . $thenn . " " . $thenn . " > " . explode(".", $thenn)[0] . "; cat " . explode(".", $thenn)[0] . " | /usr/sbin/sendmail " . $tow . " > smail.out 2> smail.err; rm -f " . explode(".", $thenn)[0] . "; rm -f " . $thenn);
   }
   }
   exit;
 }
 
 if (isset($_GET['globit'])) {
   $accf="";
   $accfd="";
   $accfout="";
   $accfoutext=".html";
   if ($lportbit == "" && strpos($_SERVER['SERVER_NAME'],'rjmprogramming.com.au') === false) {
   $pprefix=dirname(__FILE__) . "\\";
   } else {
   $pprefix=dirname(__FILE__) . DIRECTORY_SEPARATOR;
   }
  if (isset($_GET['globpath'])) {
     if (str_replace("+", " ", urldecode($_GET['globpath'])) != "") {
     $pprefix=str_replace("+", " ", urldecode($_GET['globpath']));
     }
   }
   if (isset($_GET['globext'])) {
     $accfoutext="." . str_replace(".", "", str_replace("+", " ", urldecode($_GET['globext'])));
   }
 file_put_contents('a.a',$_GET['globit'] . "\n" . $_GET['globpath'] . "\n" . $_GET['globext'] . "\n" . $pprefix); 

   foreach (glob($pprefix . str_replace("+", " ", urldecode($_GET['globit']))) as $filename) {  
       $accf.=$accfd . basename($filename);
       $accfout.=$accfd . explode(".", basename($filename))[0] . $accfoutext;
       $accfd=",";
   }
   echo "<html><head>" . $title . "</head><body onload=\" " . $wobit . " parent.document.getElementById('thewords').value='" . $accf . "';  parent.document.getElementById('outputname').value='" . $accfout . "'; \"></body></html>";
   exit;
 }

function ourstr_replace($fris, $tois, $stris) {
  global $indx;
  if (strpos($stris, ",") !== false || ($indx == 0 && (isset($_GET['inpath']) || isset($_POST['inpath'])))) {
    $interim=str_replace($fris, $tois, explode(",",$stris)[$indx]);
    if (isset($_GET['inpath'])) {
      return str_replace("+"," ",urldecode($_GET['inpath'])) . $interim;
    } else if (isset($_POST['inpath'])) {
      return str_replace("+"," ",urldecode($_POST['inpath'])) . $interim;
    } 
    return $interim;
  } 
  return str_replace($fris, $tois, $stris);
}

function outf($fid) {
  global $outfis;
  if (isset($_POST['content'])) {
     if (isset($_POST['infname'])) {
       if ($_POST['content'] != $_POST['infname']) {
        if (basename($fid) == $fid && substr($fid,0,1) != '.') {
         $outfis='/tmp/' . basename($fid);
         file_put_contents('zv.zv', $outfis);
         return '/tmp/' . basename($fid);
        }
       }
     } else {
     //if (file_exists($fid)) {
        if (basename($fid) == $fid && substr($fid,0,1) != '.') {
         $outfis='/tmp/' . basename($fid);
         file_put_contents('zzv.zzv', $outfis);
         return '/tmp/' . basename($fid);
        }
     //}
     }
  }
  return $fid;
}

function yourstr_replace($fris, $tois, $stris) {
  global $indx, $qindx;
  $iindx=$indx;
  if ($qindx >= 0) {  $iindx=$qindx; }
  $qindx=-1;
  if (strpos($stris, ",") !== false || ($indx == 0 && (isset($_GET['outpath']) || isset($_POST['outpath'])))) {
    $interim=str_replace($fris, $tois, explode(",",$stris)[$iindx]);
    if (isset($_GET['outpath'])) {
      return outf(str_replace("+"," ",urldecode($_GET['outpath'])) . $interim);
    } else if (isset($_POST['outpath'])) {
      return outf(str_replace("+"," ",urldecode($_POST['outpath'])) . $interim);
    } 
    return $interim;
  } 
  return str_replace($fris, $tois, $stris);
}

if (isset($_GET['vsfs']) && isset($_GET['vsfn']) && isset($_GET['vsfi']) && isset($_GET['vsfu'])) {
  $docroot=dirname(__FILE__);
  if (file_exists("lookup_" . str_replace(")","",str_replace("(","",str_replace("+"," ",urldecode($_GET['vsfn'])))))) {
    unlink("lookup_" . str_replace(")","",str_replace("(","",str_replace("+"," ",urldecode($_GET['vsfn'])))));
  }
  exec("find " . $_SERVER['DOCUMENT_ROOT'] . " -name '" . str_replace(")","*",str_replace("(","*",str_replace("+"," ",urldecode($_GET['vsfn'])))) . "' -exec ls -l {} \\; 2> /dev/null > lookup_" . str_replace(")","",str_replace("(","",str_replace("+"," ",urldecode($_GET['vsfn'])))));
  if (file_exists("lookup_" . str_replace(")","",str_replace("(","",str_replace("+"," ",urldecode($_GET['vsfn'])))))) {
    $infois=file_get_contents(("lookup_" . str_replace(")","",str_replace("(","",str_replace("+"," ",urldecode($_GET['vsfn']))))));
    $lines=explode("\n", $infois);
    for ($il=0; $il<sizeof($lines); $il++) {
      $lines[$il]=str_replace("\r","",$lines[$il]);
      if (strpos($lines[$il], " " . $_GET['vsfs'] . " ") !== false) {
        //file_put_contents("look_" . str_replace(")","",str_replace("(","",str_replace("+"," ",urldecode($_GET['vsfn'])))), "thisplace=" . $docroot . "\n" . "rootplace=" . $_SERVER['DOCUMENT_ROOT'] . "\n" . "origplace=" . str_replace("+"," ",urldecode($_GET['vsfu'])) . "\n" . "foundplace=" . explode(" ", $lines[$il])[-1 + sizeof( explode(" ", $lines[$il]))] . "\n" . '<html><body onload=" parent.document.getElementById(' . "'" . str_replace("+"," ",urldecode($_GET['vsfi'])) . "'" . ").value='" . str_replace($_SERVER['DOCUMENT_ROOT'],explode("localhost",str_replace("+"," ",urldecode($_GET['vsfu'])))[0] . "localhost" . explode("/",explode("localhost",str_replace("+"," ",urldecode($_GET['vsfu'])))[1])[0] . "",explode(" ", $lines[$il])[-1 + sizeof( explode(" ", $lines[$il]))]) . "'; " . '"></body></html>');
        if (strpos(explode(" ", $lines[$il])[-1 + sizeof( explode(" ", $lines[$il]))], $_SERVER['DOCUMENT_ROOT']) !== false) {
          //file_put_contents("x7.x7",'<html><body onload=" if (parent.document.getElementById(' . "'" . 'eangle' . "'" . ')) { parent.document.getElementById(' . "'" . 'eangle' . "'" . ').value=' . "'" . $ort . "'" . ';  } top.document.getElementById(' . "'" . str_replace("+"," ",urldecode($_GET['vsfi'])) . "'" . ").value='" . $ort . "'; " . '"></body></html>');
          if (isset($_GET['turl'])) {      
          echo "<html><body onload=\" " . $wobit . " var tp='" . str_replace("junk" . $_SERVER['DOCUMENT_ROOT'],"juJUNKnk" . explode("localhost",str_replace("+"," ",urldecode($_GET['vsfu'])))[0] . "localhost" . explode("/",explode("localhost",str_replace("+"," ",urldecode($_GET['vsfu'])))[1])[0] . "",explode(" ", $lines[$il])[-1 + sizeof( explode(" ", $lines[$il]))]) . "'; " . "  var tt='" . str_replace("+"," ",urldecode($_GET['vsfn'])) . "'; "  . ' var ct=top.document.getElementById(' . "'" . 'cto' . "'" . ').value; ct=ct.replace(' . "'" . '*' . "'" . ',' . "'" . 'html' . "'" . '); top.document.getElementById(' . "'" . 'sin' . "'" . ').style.display=' . "'" . 'inline-block' . "'" . '; top.document.getElementById(' . "'" . 'path' . "'" . ").value=tp.replace(tt, ''); " . ' top.document.getElementById(' . "'" . 'opath' . "'" . ").value=tp.replace(tt, ''); " . '  top.selch(ct);   "></body></html>'; 
          } //else { 
          //echo '<html><body onload=" if (parent.document.getElementById(' . "'" . 'eangle' . "'" . ')) { parent.document.getElementById(' . "'" . 'eangle' . "'" . ').value=' . "'" . $ort . "'" . ';  } top.document.getElementById(' . "'" . str_replace("+"," ",urldecode($_GET['vsfi'])) . "'" . ").value='" . $ort . "'; " . '"></body></html>'; 
          //}
        } //else if (isset($_GET['turl'])) {      
          //echo '<html><body onload=" top.document.getElementById(' . "'" . 'turl' . "'" . ").placeholder='" . str_replace($_SERVER['DOCUMENT_ROOT'],explode("localhost",str_replace("+"," ",urldecode($_GET['vsfu'])))[0] . "localhost" . explode("/",explode("localhost",str_replace("+"," ",urldecode($_GET['vsfu'])))[1])[0] . "",explode(" ", $lines[$il])[-1 + sizeof( explode(" ", $lines[$il]))]) . "'; " . '  top.document.getElementById(' . "'" . 'turl' . "'" . ').title=top.document.getElementById(' . "'" . 'turl' . "'" . ').placeholder;   top.document.getElementById(' . "'" . 'thewords' . "'" . ').title=top.document.getElementById(' . "'" . 'thewords' . "'" . ').title.replace( top.document.getElementById(' . "'" . 'turl' . "'" . ').value, top.document.getElementById(' . "'" . 'turl' . "'" . ').placeholder);   top.document.getElementById(' . "'" . 'thewords' . "'" . ').value=top.document.getElementById(' . "'" . 'thewords' . "'" . ').value.replace( top.document.getElementById(' . "'" . 'turl' . "'" . ').value, top.document.getElementById(' . "'" . 'turl' . "'" . ').placeholder);   top.document.getElementById(' . "'" . 'turl' . "'" . ').value=top.document.getElementById(' . "'" . 'turl' . "'" . ').placeholder;   top.document.getElementById(' . "'" . 'thewords' . "'" . ').value=top.document.getElementById(' . "'" . 'thewords' . "'" . ').value.replace( top.document.getElementById(' . "'" . 'turl' . "'" . ').value, top.document.getElementById(' . "'" . 'turl' . "'" . ').placeholder);  "></body></html>'; 
        //} else { 
        //  echo '<html><body onload=" parent.document.getElementById(' . "'" . str_replace("+"," ",urldecode($_GET['vsfi'])) . "'" . ").value='" . str_replace($_SERVER['DOCUMENT_ROOT'],explode("localhost",str_replace("+"," ",urldecode($_GET['vsfu'])))[0] . "localhost" . explode("/",explode("localhost",str_replace("+"," ",urldecode($_GET['vsfu'])))[1])[0] . "",explode(" ", $lines[$il])[-1 + sizeof( explode(" ", $lines[$il]))]) . "'; " . '"></body></html>'; 
        //}
        unlink("lookup_" . str_replace(")","",str_replace("(","",str_replace("+"," ",urldecode($_GET['vsfn']))))); 
      } else {
        unlink("lookup_" . str_replace(")","",str_replace("(","",str_replace("+"," ",urldecode($_GET['vsfn']))))); 
      }
    }
  } 
  exit;
}



if ((PHP_OS == "Darwin" || $verb != "textutil"  || (strpos($verb, DIRECTORY_SEPARATOR) !== false && strpos($iverb, DIRECTORY_SEPARATOR) !== false)) || isset($_GET['emailanyway']) || $iphone || $ipad || $android || $ipod || $blackberry) {
if (strpos($verb, DIRECTORY_SEPARATOR) !== false && strpos($verb, DIRECTORY_SEPARATOR) !== false) {
  $avbit='';
  //$resbit="<input type=hidden id=saysub value=''></input><input type=hidden id=resultout value=''></input><input type=hidden id=resJUNKult value=''></input><input type=hidden id=audioname value=''></input><textarea id=toptext style=visibility:hidden;></textarea>";
  $resbit="<input type=hidden id=saysub value=''></input><input type=hidden id=resultout value=''></input><input type=hidden id=resJUNKult value=''></input><input type=hidden id=audioname value=''></input>" . $resultof . "<textarea id=myta rows=50 cols=120 id=toptext style=visibility:hidden;></textarea>";
}
if (isset($_GET['convertthis']) && isset($_GET['outputname'])) {
  if ($_GET['convertthis'] != "") {
  $thewords=str_replace("+"," ",urldecode($_GET['convertthis']));
  $thegoes=explode(",", $thewords);
  for ($indx=0; $indx<sizeof($thegoes); $indx++) {
  if (file_exists(yourstr_replace("+"," ",urldecode($_GET['outputname'])))) {
    while (file_exists(yourstr_replace("+"," ",urldecode($_GET['outputname'])) . $sufext)) {
      $iext++;
      $sufext="_" . $iext;
    }
    exec("rename " . yourstr_replace("+"," ",urldecode($_GET['outputname'])) . " " . yourstr_replace("+"," ",urldecode($_GET['outputname'])) . $sufext);
  }
  // pandoc -t pdf scjob.docx -o scjob.pdf  --pdf-engine=/Library/TeX/Root/bin/x86_64-darwin/pdflatex
  $cmdsuff="";
  if ($verb != "textutil" && explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))] == "pdf") {
  if (file_exists("/Library/TeX/Root/bin/x86_64-darwin/pdflatex")) {
  $cmdsuff=" --pdf-engine=/Library/TeX/Root/bin/x86_64-darwin/pdflatex";
  } else if (file_exists("/Library/TeX/texbin/pdflatex")) {
  $cmdsuff=" --pdf-engine=/Library/TeX/texbin/pdflatex";
  } else {
  $cmdsuff=" --pdf-engine=" . $precmds . "pdflatex";
  }
  }


 //echo $verb . " " . $switchone . " " . explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))] . " " . ourstr_replace("+"," ",$thewords) . " " . $switchtwo . " " . yourstr_replace("+"," ",urldecode($_GET['outputname'])) . $cmdsuff;
 //exit;

    file_put_contents("macos_textutil_convertYES.out",$verb . "        " . $switchone . " " . explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))] . " " . ourstr_replace("+"," ",$thewords) . " " . $switchtwo . " " . yourstr_replace("+"," ",urldecode($_GET['outputname'])) . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err \n");

    if (isset($_POST['content'])) {
    //echo "yeS";
    //exit;
    $befbsf=str_replace(' ','+', urldecode($_POST['content']));
    file_put_contents('/tmp/xx.' . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))), base64_decode(explode(';base64,',$befbsf)[1]));
//theecho("6:" . "$verb" . " " . $switchone . " " . "/tmp/xx." . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))) . " " . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err ; rm -f " . "/tmp/xx." . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))));
//exit;
    exec("$verb" . " " . $switchone . switcheroo(" " . "/tmp/xx." . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))) . " ") . $filename . " " . $switchtwo . " " . $outnameis . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err ; rm -f " . "/tmp/xx." . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))));


  $mimt=inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0]))));
  //file_put_contents("abc.xzy",yourstr_replace("+"," ",big(urldecode($_POST['outputname']))) );
  if ($mimt == 'html' && file_exists($outnameis)) {
  //file_put_contents("abc.xz2",yourstr_replace("+"," ",big(urldecode($_POST['outputname']))) );
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body>" . $ocontis . "</body></html>";
     }
  //file_put_contents("abc.xz3",$ocontis );
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );

     //echo "<html><body onload=\" " . $wobit . " \"></body></html>";   // might be temporary arrangement
     //exit;
  } else if ($mimt == "pdf") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\"  src=\"data:application/pdf;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if (substr($mimt,0,3) == "rtf") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/rtf;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if ($mimt == "odt") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/vnd.oasis.opendocument.text;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit ); 
  } else if (substr($mimt,0,3) == "doc") {
     $ocontis=file_get_contents($outnameis);
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename($outnameis) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit ); 
  } else if (str_replace('plain','txt',str_replace('text','txt',$mimt)) == "txt") {
     $ocontis=file_get_contents($outnameis);
     $pltx=$ocontis;
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename($outnameis) . "</title></head><body><div>" . str_replace("\n","<br>",$ocontis) . "\"></div><br></body></html>";
     }
     $wobit=" top.document.getElementById('dres').style.width='98%'; top.document.getElementById('dres').style.height='30%'; top.document.getElementById('dres').innerHTML='<textarea style=width:98%;height:98%;>' + window.atob('" . base64_encode($pltx) . "') + '</textarea>';    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  }




    } else {
//theecho("7:" . "$verb" . " " . $switchone . " \"" . explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))] . "\" " . ourstr_replace("+"," ",$thewords) . " " . $switchtwo . " \"" . yourstr_replace("+"," ",urldecode($_GET['outputname'])) . "\"" . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err");
//exit;
  exec("$verb" . " " . $switchone . switcheroo(" \"" . explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))] . "\" ") . ourstr_replace("+"," ",$thewords) . " " . $switchtwo . " \"" . yourstr_replace("+"," ",urldecode($_GET['outputname'])) . "\"" . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err");


  $mimt=explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))];
  //file_put_contents("abc.xzy",yourstr_replace("+"," ",big(urldecode($_POST['outputname']))) );
  if ($mimt == 'html' && file_exists(yourstr_replace("+"," ",urldecode($_GET['outputname'])))) {
  //file_put_contents("abc.xz2",yourstr_replace("+"," ",big(urldecode($_POST['outputname']))) );
     $ocontis=file_get_contents(yourstr_replace("+"," ",urldecode($_GET['outputname'])));
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",urldecode($_GET['outputname']))) . "</title></head><body>" . $ocontis . "</body></html>";
     }
  //file_put_contents("abc.xz3",$ocontis );
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );

     //echo "<html><body onload=\" " . $wobit . " \"></body></html>";   // might be temporary arrangement
     //exit;
  } else if ($mimt == "pdf") {
     $ocontis=file_get_contents(yourstr_replace("+"," ",urldecode($_GET['outputname'])));
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "</title></head><body><iframe style=\"width:100%;height:100%;\"  src=\"data:application/pdf;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if (substr($mimt,0,3) == "rtf") {
     $ocontis=file_get_contents(yourstr_replace("+"," ",urldecode($_GET['outputname'])));
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/rtf;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if ($mimt == "odt") {
     $ocontis=file_get_contents(yourstr_replace("+"," ",urldecode($_GET['outputname'])));
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/vnd.oasis.opendocument.text;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit ); 
  } else if (substr($mimt,0,3) == "doc") {
     $ocontis=file_get_contents(yourstr_replace("+"," ",urldecode($_GET['outputname'])));
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit ); 
  } else if (str_replace('plain','txt',str_replace('text','txt',$mimt)) == "txt") {
     $ocontis=file_get_contents(yourstr_replace("+"," ",urldecode($_GET['outputname'])));
     $pltx=$ocontis;
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",urldecode($_GET['outputname']))) . "</title></head><body><div>" . str_replace("\n","<br>",$ocontis) . "\"></div><br></body></html>";
     }
     $wobit=" top.document.getElementById('dres').style.width='98%'; top.document.getElementById('dres').style.height='30%'; top.document.getElementById('dres').innerHTML='<textarea style=width:98%;height:98%;>' + window.atob('" . base64_encode($pltx) . "') + '</textarea>';    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  }




    }
  if (explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))] == "pdf") {
        $PDFfilename=yourstr_replace("+"," ",urldecode($_GET['outputname']));
        $pdf = file_get_contents($PDFfilename);

        header('Content-Type: application/pdf');
        header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
        header('Pragma: public');
        header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Content-Length: ' . strlen($pdf));
        header('Content-Disposition: inline; filename="' . basename($PDFfilename) .'";');
        ob_clean(); 
        flush(); 
        echo $pdf;  
        //exit; 
  } else if (explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))] == "rtf") {
        $PDFfilename=yourstr_replace("+"," ",urldecode($_GET['outputname']));
        $pdf = file_get_contents($PDFfilename);

        header('Content-Type: application/rtf');
        header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
        header('Pragma: public');
        header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Content-Length: ' . strlen($pdf));
        header('Content-Disposition: inline; filename="' . basename($PDFfilename) .'";');
        ob_clean(); 
        flush(); 
        echo $pdf;  
        //exit; 
  } else if (explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))] == "odt") {
        $PDFfilename=yourstr_replace("+"," ",urldecode($_GET['outputname']));
        $pdf = file_get_contents($PDFfilename);

        header('Content-Type: application/odt');
        header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
        header('Pragma: public');
        header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Content-Length: ' . strlen($pdf));
        header('Content-Disposition: inline; filename="' . basename($PDFfilename) .'";');
        ob_clean(); 
        flush(); 
        echo $pdf;  
        //exit; 
  }
  if (file_exists("macos_textutil_convert.out") && file_exists("macos_textutil_convert.err")) {
  if (filesize("macos_textutil_convert.out") == 0 && filesize("macos_textutil_convert.err") != 0) {
     if ($rone != "" && $rtwo != "") {
      rename($rone, $rtwo);
     }
    //if (explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))] == 'html') {
    //echo file_get_contents(ourstr_replace("+"," ",$thewords) . " " . $switchtwo . " " . yourstr_replace("+"," ",urldecode($_GET['outputname'])));
    //} else {
    if (file_exists(yourstr_replace("+"," ",urldecode($_GET['outputname']))) && explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))] == 'html') {
    echo file_get_contents(yourstr_replace("+"," ",urldecode($_GET['outputname'])));
    } else {
    echo "<html><head><style> * { overflow-y:visible; } </style>
      <scr" . "ipt type=text/javascript>   

  
  function yesfivefive(restis) {
    document.getElemenetById('toptext').innerHTML=restis;
  }
  
  function checkformaybes() {
     var argd='?', argst='', contd='';
     if ((('' + document.getElementById('maybee').value).replace(/^undefined/g,'') + ('' + document.getElementById('maybes').value).replace(/^undefined/g,'')) != '') {
        document.getElementById('myform').method='GET';
        var things=document.getElementById('myform').innerHTML.split(' name=');
        var idthing='', namething='';
        for (var ith=1; ith<things.length; ith++) {
         namething=things[ith].split(' ')[0].split('>')[0].replace('\"','').replace('\"','').replace(/\'/g, '');
         idthing=namething.replace('convertto','cto').replace('outpath','opath').replace('inpath','path').replace('convertthis','thewords');
         if (namething == 'content') {
         if (document.getElementById('content0')) {
         contd='#content=' + encodeURIComponent(document.getElementById('content0').value);
         } else {
         contd='#content=' + encodeURIComponent(document.getElementById('content').value);
         }
         } else {
         if (!document.getElementById(idthing)) {   
         argst+=argd + namething + '=' + '';
         } else {
         argst+=argd + namething + '=' + encodeURIComponent(document.getElementById(idthing).value);
         }
         argd='&';
         }
        }
        location.href=document.URL.split('?')[0].split('#')[0] + argst + contd; //'?outputname=' + encodeURIComponent(document.getElementById('outputname').value)
        return false;
     }
     return true;
  }
  
  function shareit() {
     var recipient=prompt('Please enter an email address or SMS number to send results to?', '');
     if (recipient != null) {
       if (('' + recipient).trim() != '') {
        if (('' + recipient).trim().indexOf('@') != -1) {
          document.body.style.cursor='progress';
          document.getElementById('maybee').value=('' + recipient).trim();
          document.getElementById('ifsubmit').click();
        } else if (('' + recipient).trim().replace(/0/g,'').replace(/1/g,'').replace(/2/g,'').replace(/3/g,'').replace(/4/g,'').replace(/5/g,'').replace(/6/g,'').replace(/7/g,'').replace(/8/g,'').replace(/9/g,'') == '') {
          document.body.style.cursor='progress';
          document.getElementById('maybes').value=('' + recipient).trim();
          document.getElementById('ifsubmit').click();
        }
       }
     }
  }
  
  function yesthreethree(restis) {
  // alert(45);
   if (document.getElementById('ifesubmit')) {
    if (document.getElementById('ifsubmit')) {
      document.getElementById('ifsubmit').style.width='48%';
      document.getElementById('ifesubmit').style.display='inline-block';
    }
   }
   if (document.getElementById('ifesubmit')) {
    if (document.getElementById('ifsubmit')) {
      document.getElementById('ifsubmit').style.width='48%';
      document.getElementById('ifesubmit').style.display='inline-block';
    }
   }
   if (document.getElementById('content0')) {
   //alert(restis);
    document.getElementById('content0').value=restis;
    //alert('467 ' + restis);
   }
   if (document.getElementById('dinhouse')) {
   //alert(restis);
    document.getElementById('dinhouse').innerHTML+='<div id=divcontent><input type=hidden name=infname id=infname value=\"' + document.getElementById('thewords').value + '\"></input><input type=hidden name=content id=content value=\"' + restis + '\"></input><input type=hidden name=maybee id=maybee value=\"\"></input><input type=hidden name=maybes id=maybes value=\"\"></input>';
    //setTimeout(function(){ document.getElementById('divcontent').innerHTML='';   }, 20000);
    //alert('1467 ' + document.getElementById('dinhouse').innerHTML);
    if (('' + location.hash).indexOf('content=') != -1) {
      document.body.style.cursor='progress';
      if (document.getElementById('myes')) {
         document.getElementById('myes').click();
      }
      document.getElementById('ifsubmit').click();
    }
   }
  }
  
  function worry() {
     if (document.getElementById('myta')) {
       if (document.getElementById('myta').value == '') {
        setTimeout(worry, 5000);
       } else {
        document.body.style.cursor='pointer';
       }
     } else {
       setTimeout(worry, 5000);
     }  
  }
  
  function oops(inidis) {
     if (inidis == 'hidden') {
       setTimeout(worry, 5000);
     }
     return inidis;
  }

  function lhit() {
  var resultof='';
  " . $curt . " 
  if (('' + location.hash).indexOf('content=') != -1) {
   if (document.getElementById('myp')) { document.body.style.cursor='progress'; document.getElementById('myp').style.visibility=oops('hidden');  }
  //alert(256);
     if (window.top) {
  //alert(37256);
       if (!document.getElementById('myform')) {
//&inpath=&convertto=*&outpath=&outputname=.html%2Cxxx.html&convertthis=xxx.txt&
         if (decodeURIComponent((document.URL.replace('#','&') + '&').split('outputname=')[1].split('&')[0]).indexOf(',') != -1) {
         resultof='Result of Conversion from ' + decodeURIComponent((document.URL.replace('#','&') + '&').split('inpath=')[1].split('&')[0]) + decodeURIComponent((document.URL.replace('#','&') + '&').split('convertthis=')[1].split('&')[0]) + ' to ' + decodeURIComponent((document.URL.replace('#','&') + '&').split('outputname=')[1].split('&')[0]).split(',')[1] + ' ... ';
         } else {
         resultof='Result of Conversion from ' + decodeURIComponent((document.URL.replace('#','&') + '&').split('inpath=')[1].split('&')[0]) + decodeURIComponent((document.URL.replace('#','&') + '&').split('convertthis=')[1].split('&')[0]) + ' to ' + decodeURIComponent((document.URL.replace('#','&') + '&').split('outputname=')[1].split('&')[0]) + ' ... ';
         }
  //alert('48256 ');
         document.body.innerHTML+=\"<form style=display:none; id=myform data-onsubmit=\\\" if (!checkformaybes()) {  return false;  } if (document.getElementById('ifsubmit').value.indexOf('mail ') != -1) { setTimeout(askee,9000); return false; } else { if (document.getElementById('thewords').value.indexOf(',') != -1) {  woit(); return false; } else { document.getElementById('myform').style.cursor='progress'; document.body.style.cursor='progress'; setTimeout(thenreload,20000); return true; } }\\\" target=dothework action=./macos_textutil_convert.php method=POST><table border=20 style='width:98%;' cellspacing=5 cellpadding=5><tr><th style='background-color:lightgreen;'>Input Document File(s) <span id=sin style=display:none;>in</span> <input name=inpath style=display:inline-block;width:60%; type=text id=path value='" . str_replace('+',' ',urldecode($_GET['inpath'])) . "' placeholder='Optional input path'></input></th><th><select onchange=\\\" selch(this.value);  \\\" style=display:inline-block; name=convertto id=cto><option value='" . str_replace('+',' ',urldecode($_GET['convertto'])) . "'></option><option value='*'>Convert to</option><option value='txt'>Convert to txt</option><option value='rtf'>Convert to rtf</option><!--option value='rtfd'>Convert to rtfd</option--><option value='html'>Convert to html</option><!--option value='doc'>Convert to doc</option--><option value='docx'>Convert to docx</option><option value='odt'>Convert to odt</option><option value='wordml'>Convert to wordml</option><option value='webarchive'>Convert to webarchive</option> <option value='pdf'>Convert to pdf</option></select>&nbsp;<input name=outpath style=display:inline-block;width:30%; type=text id=opath value='" . str_replace('+',' ',urldecode($_GET['outpath'])) . "' placeholder='Optional output path'></input> <input style='width:40%;' onblur=\\\"if (document.URL.toLowerCase().indexOf('" . $rjm . "') != -1) { this.value=''; } if (this.value.toLowerCase().indexOf('.pdf') != -1) { document.getElementById('myform').target='_blank';   }  \\\" placeholder='Output document file(s)' type=text name=outputname id=outputname value='" . str_replace('+',' ',urldecode($_GET['outputname'])) . "'></input></div>&nbsp;</th></tr><tr><td style='vertical-align:top;background-color:lightgreen;'><input type=text onblur=\\\"if (document.URL.toLowerCase().indexOf('" . $rjm . "') != -1) { this.value=''; } else { assessit(this.value); }\\\" style='width:90%;' placeholder='Input document file(s)' id=thewords name=convertthis  value='" . str_replace('+',' ',urldecode($_GET['convertthis'])) . "'></input><br><sup>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...&nbsp;or" . $cself . "&nbsp;...&nbsp;</sup><div style='display:inline-block;width:95px;height:30px;overflow:hidden;vertical-align:text-bottom;'><iframe scrolling=no frameborder=0 id=cbi data-style='border-top:1px solid black;border-bottom:1px solid black;border-left:2px solid yellow;border-right:1px solid yellow;' style='width:173px;height:228px;margin-top:-194px;' src='HTMLCSS/client_browsing.htm?totype=html&d=" . rand(0,18765432) . "'></iframe></div></td><td style=vertical-align:top;><div id=dforbutton>" . $divinfront . "</div><input id=ifsubmit style='width:100%;height:100px;background-color:yellow;display:inline-block;' type=submit value='" . $cvse . " Document(s)'></input>&nbsp;<input onclick=shareit(); id=ifesubmit style='width:48%;height:100px;background-color:lightblue;display:none;' type=button value='" . $cvse . " Document(s) to Recipient'></input><br><div id=resultout>" . str_replace("\n","<br>",$thecontent) . "</div></td></tr></table><div id=dinhouse></div></form>\";
         if (document.getElementById('maybee')) {
          if (document.getElementById('maybee').value != '') {
  //alert('48256maybee ');
            document.getElementById('esmore').innerHTML+=\"<a target=_top href='mailto:\" + document.getElementById('maybee').value + \"?subject=\" + encodeURIComponent(resultof) + \"&body=\" + encodeURIComponent(document.URL.replace(/\&maybe/g,'&bemay')) + \"' id=myes style=display:none;>Email</a>\";
          }
         } else if (document.URL.indexOf('maybee=') != -1 && (document.URL.replace('#','&') + '&').indexOf('maybee=&') == -1) {
            document.getElementById('esmore').innerHTML+=\"<a target=_top href='mailto:\" + decodeURIComponent((document.URL.replace('#','&') + '&').split('maybee=')[1].split('&')[0]) + \"?subject=\" + encodeURIComponent(resultof) + \"&body=\" + encodeURIComponent(document.URL.replace(/\&maybe/g,'&bemay')) + \"' id=myes style=display:none;>Email</a>\";
         }
         if (document.getElementById('maybes')) {
          if (document.getElementById('maybes').value != '') {
  //alert('48256maybes ');
            document.getElementById('esmore').innerHTML+=\"<a target=_top href='sms:\" + document.getElementById('maybes').value + \"&body=\" + encodeURIComponent(document.URL.replace(/\&maybe/g,'&bemay')) + \"' id=myes style=display:none;>SMS</a>\";
          } else if (document.URL.indexOf('maybes=') != -1 && (document.URL.replace('#','&') + '&').indexOf('maybes=&') == -1) {
            document.getElementById('esmore').innerHTML+=\"<a target=_top href='sms:\" + decodeURIComponent((document.URL.replace('#','&') + '&').split('maybes=')[1].split('&')[0]) + \"&body=\" + encodeURIComponent(document.URL.replace(/\&maybe/g,'&bemay')) + \"' id=myes style=display:none;>SMS</a>\";
          }
         }
       }
     }
  //alert('9256 ' + document.getElementById('thewords').value);
     var inna=decodeURIComponent(('' + location.hash).split('content=')[1].split('&')[0].split('#')[0]);
     if (document.getElementById('thewords').value == '') {
        if (inna.indexOf('data:') == 0) {
  //alert(1256);
          inna=inna.replace(/\ /g,'+');
          document.getElementById('thewords').value='xx.' + inna.split('/')[1].split(';')[0].split(',')[0].replace('plain','txt');
          document.getElementById('thewords').blur();
        } else {
  //alert(2256);
          document.getElementById('thewords').value=inna;
          document.getElementById('thewords').blur();
        }
     }
  //alert(3256);
     yesthreethree(inna);
  //alert(4256);
  }
  }
    </scr" . "ipt>
    </head><body onload=\" " . $wobit . " lhit(); if (window.opener) { window.opener.document.getElementById('dothework').style.height='80%';    window.opener.document.getElementById('dothework').style.display='block';  } else if (window.parent) { parent.document.getElementById('dothework').style.height='80%';    parent.document.getElementById('dothework').style.display='block'; } \"><p id=myp>" . yourfile_get_contents("macos_textutil_convert.err") . "</p><iframe style='width:100%;height:0px;display:none;' frameborder=0 name=dothework id=dothework src=macos_textutil_convert.php></iframe><div id=esmore></div></body></html>";
    }
  } else {
    if (explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))] == 'html') {
    echo file_get_contents(yourstr_replace("+"," ",urldecode($_GET['outputname'])));
    } else {
    echo explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_GET['outputname']))))];
    }
  }
  }
  }
  exit;
  }
} else if (isset($_POST['convertthis']) && isset($_POST['outputname'])) {
  if ($_POST['convertthis'] != "") {
  $thewords=str_replace("+"," ",urldecode($_POST['convertthis']));
  $thegoes=explode(",", $thewords);
  for ($indx=0; $indx<sizeof($thegoes); $indx++) {
    
  $rone="";
  $rtwo="";  
  
  if (file_exists(yourstr_replace("+"," ",urldecode($_POST['outputname'])))) {
    $sufext="_0";
    $iext=0;
    while (file_exists(yourstr_replace("+"," ",urldecode($_POST['outputname'])) . $sufext)) {
      $iext++;
      $sufext="_" . $iext;
    }
    $rtwo=yourstr_replace("+"," ",urldecode($_POST['outputname']));
    $rone=yourstr_replace("+"," ",urldecode($_POST['outputname'])) . $sufext;
    rename(yourstr_replace("+"," ",urldecode($_POST['outputname'])), yourstr_replace("+"," ",urldecode($_POST['outputname'])) . $sufext);
  }
  // pandoc -t pdf scjob.docx -o scjob.pdf
  $cmdsuff="";
  if ($verb != "textutil" && explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname']))))] == "pdf") {
  if (file_exists("/Library/TeX/Root/bin/x86_64-darwin/pdflatex")) {
  $cmdsuff=" --pdf-engine=/Library/TeX/Root/bin/x86_64-darwin/pdflatex";
  } else if (file_exists("/Library/TeX/texbin/pdflatex")) {
  $cmdsuff=" --pdf-engine=/Library/TeX/texbin/pdflatex";
  } else {
  $cmdsuff=" --pdf-engine=" . $precmds . "pdflatex";
  }
  }
    //file_put_contents("macos_textutil_convertYES.out",$verb . "     " . "       " . $switchone . " " . explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname']))))] . " " . ourstr_replace("+"," ",$thewords) . " " . $switchtwo . " " . yourstr_replace("+"," ",big(urldecode($_POST['outputname']))) . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err \n");

    if (isset($_POST['content'])) {
    //echo "yEs";
    //exit;
    $befbsf=str_replace(' ','+', urldecode($_POST['content']));
    //file_put_contents("macos_textutil_convertYES.oux", substr($befbsf,0,120));
    file_put_contents('/tmp/xx.' . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))), base64_decode(explode(';base64,',$befbsf)[1]));
    //file_put_contents("xn.xn","$verb" . " " . $switchone . " " . explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname']))))] . " \"" . '/tmp/xx.' . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))) . "\" " . $switchtwo . " \"" . (yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "\"" . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err ; rm -f " . '/tmp/xx.' . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))));
//theecho("8:" . "$verb" . " " . $switchone . " " . explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname']))))] . " \"" . '/tmp/xx.' . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))) . "\" " . $switchtwo . " \"" . (yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "\"" . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err; rm -f " . '/tmp/xx.' . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))));
//exit;
  exec("$verb" . " " . $switchone . switcheroo(" " . explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname']))))] . " \"") . '/tmp/xx.' . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))) . "\" " . $switchtwo . " \"" . (yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "\"" . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err; rm -f " . '/tmp/xx.' . inf(substr(explode(';base64,',$befbsf)[0], (-3 + strlen(explode(';base64,',$befbsf)[0])))));
  $mimt=explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname']))))];
  //file_put_contents("abc.xzy",$mimt);
  if ($mimt == 'html' && file_exists(yourstr_replace("+"," ",big(urldecode($_POST['outputname']))))) {
  //file_put_contents("abc.xz2",yourstr_replace("+"," ",big(urldecode($_POST['outputname']))) );
     $ocontis=file_get_contents(yourstr_replace("+"," ",big(urldecode($_POST['outputname']))));
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "</title></head><body>" . $ocontis . "</body></html>";
     }
  //file_put_contents("abc.xz3",$ocontis );
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );

     //echo "<html><body onload=\" " . $wobit . " \"></body></html>";   // might be temporary arrangement
     //exit;
  } else if ($mimt == "pdf") {
     $ocontis=file_get_contents(yourstr_replace("+"," ",big(urldecode($_POST['outputname']))));
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "</title></head><body><iframe style=\"width:100%;height:100%;\"  src=\"data:application/pdf;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if (substr($mimt,0,3) == "rtf") {
     $ocontis=file_get_contents(yourstr_replace("+"," ",big(urldecode($_POST['outputname']))));
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/rtf;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if ($mimt == "odt") {
     $ocontis=file_get_contents(yourstr_replace("+"," ",big(urldecode($_POST['outputname']))));
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/vnd.oasis.opendocument.text;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if (substr($mimt,0,3) == "doc") {
     $ocontis=file_get_contents(yourstr_replace("+"," ",big(urldecode($_POST['outputname']))));
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if (str_replace('plain','txt',str_replace('text','txt',$mimt)) == "txt") {
     $ocontis=file_get_contents(yourstr_replace("+"," ",big(urldecode($_POST['outputname']))));
     $pltx=$ocontis;
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "</title></head><body><div>" . str_replace("\n","<br>",$ocontis) . "\"></div><br></body></html>";
     }
     $wobit=" top.document.getElementById('dres').style.width='98%'; top.document.getElementById('dres').style.height='30%'; top.document.getElementById('dres').innerHTML='<textarea style=width:98%;height:98%;>' + window.atob('" . base64_encode($pltx) . "') + '</textarea>';    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  }
    } else {
//theecho("9:" . "$verb" . " " . $switchone . " \"" . explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname']))))] . "\" " . ourstr_replace("+"," ",$thewords) . " " . $switchtwo . " \"" . (yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "\"" . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err");
//exit;
  exec("$verb" . " " . $switchone . switcheroo(" \"" . explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname']))))] . "\" ") . ourstr_replace("+"," ",$thewords) . " " . $switchtwo . " \"" . (yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "\"" . $cmdsuff . " > macos_textutil_convert.out 2> macos_textutil_convert.err");

  $mimt=explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname']))))];
  file_put_contents("abc.xzy",yourstr_replace("+"," ",big(urldecode($_POST['outputname']))) );
  if ($mimt == 'html' && file_exists(yourstr_replace("+"," ",big(urldecode($_POST['outputname']))))) {
  //file_put_contents("abc.xz2",yourstr_replace("+"," ",big(urldecode($_POST['outputname']))) );
     $ocontis=file_get_contents(yourstr_replace("+"," ",big(urldecode($_POST['outputname']))));
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "</title></head><body>" . $ocontis . "</body></html>";
     }
  //file_put_contents("abc.xz3",$ocontis );
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );

     //echo "<html><body onload=\" " . $wobit . " \"></body></html>";   // might be temporary arrangement
     //exit;
  } else if ($mimt == "pdf") {
     $ocontis=file_get_contents(yourstr_replace("+"," ",big(urldecode($_POST['outputname']))));
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "</title></head><body><iframe style=\"width:100%;height:100%;\"  src=\"data:application/pdf;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if (substr($mimt,0,3) == "rtf") {
     $ocontis=file_get_contents(yourstr_replace("+"," ",big(urldecode($_POST['outputname']))));
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/rtf;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if ($mimt == "odt") {
     $ocontis=file_get_contents(yourstr_replace("+"," ",big(urldecode($_POST['outputname']))));
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/vnd.oasis.opendocument.text;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if (substr($mimt,0,3) == "doc") {
     $ocontis=file_get_contents(yourstr_replace("+"," ",big(urldecode($_POST['outputname']))));
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "</title></head><body><iframe style=\"width:100%;height:100%;\" src=\"data:application/vnd.openxmlformats-officedocument.wordprocessingml.document;base64," . base64_encode($ocontis) . "\"></iframe><br></body></html>";
     }
     $wobit=" var wwoo=top.window.open('','" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "','left=10,top=10,width=500,height=500');  wwoo.document.write(window.atob('" . base64_encode($ocontis) . "'));    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  } else if (str_replace('plain','txt',str_replace('text','txt',$mimt)) == "txt") {
     $ocontis=file_get_contents(yourstr_replace("+"," ",big(urldecode($_POST['outputname']))));
     $pltx=$ocontis;
     if (strpos($ocontis, '<body') === false) {
       $ocontis="<html><head><meta charset='UTF-8'/><title>" . basename(yourstr_replace("+"," ",big(urldecode($_POST['outputname'])))) . "</title></head><body><div>" . str_replace("\n","<br>",$ocontis) . "\"></div><br></body></html>";
     }
     $wobit=" top.document.getElementById('dres').style.width='98%'; top.document.getElementById('dres').style.height='30%'; top.document.getElementById('dres').innerHTML='<textarea style=width:98%;height:98%;>' + window.atob('" . base64_encode($pltx) . "') + '</textarea>';    ";
  //file_put_contents("abc.xz4",$wobit );
    file_put_contents("/tmp/wobit" . server_remote_addr() . ".xxx",$wobit );
  }


    }
  if (explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname']))))] == "pdf") {
        $PDFfilename=yourstr_replace("+"," ",urldecode($_POST['outputname']));
        $pdf = file_get_contents($PDFfilename);
        
        header('Content-Type: application/pdf');
        header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
        header('Pragma: public');
        header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Content-Length: ' . strlen($pdf));
        header('Content-Disposition: inline; filename="' . basename($PDFfilename) .'";');
        ob_clean(); 
        flush(); 
        echo $pdf;  
        //exit; 
  } else if (explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname']))))] == "rtf") {
        $PDFfilename=yourstr_replace("+"," ",urldecode($_POST['outputname']));
        $pdf = file_get_contents($PDFfilename);

        header('Content-Type: application/rtf');
        header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
        header('Pragma: public');
        header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Content-Length: ' . strlen($pdf));
        header('Content-Disposition: inline; filename="' . basename($PDFfilename) .'";');
        ob_clean(); 
        flush(); 
        echo $pdf;  
        //exit; 
  } else if (explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",yourstr_replace("+"," ",urldecode($_POST['outputname']))))] == "odt") {
        $PDFfilename=yourstr_replace("+"," ",urldecode($_POST['outputname']));
        $pdf = file_get_contents($PDFfilename);

        header('Content-Type: application/odt');
        header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
        header('Pragma: public');
        header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Content-Length: ' . strlen($pdf));
        header('Content-Disposition: inline; filename="' . basename($PDFfilename) .'";');
        ob_clean(); 
        flush(); 
        echo $pdf;  
        //exit; 
  }
    file_put_contents('xvvv.xvvv',$outfis);
  sleep(60);
  if (file_exists("macos_textutil_convert.out") && file_exists("macos_textutil_convert.err")) {
    file_put_contents('xvvvv.xvvvv',$outfis);
    if (strpos(file_get_contents("macos_textutil_convert.err"), 'xiting with status 0') !== false)
  if (filesize("macos_textutil_convert.out") == 0 && (strpos(file_get_contents("macos_textutil_convert.err"), 'xiting with status 0') === false && filesize("macos_textutil_convert.err") != 0)) {
    file_put_contents('xvvvvx.xvvvvx',$outfis);
     if ($rone != "" && $rtwo != "") {
      rename($rone, $rtwo);
     }
    echo "<html>
    <head>
    <scr" . "ipt type=text/javascript>
      
  function worry() {
     if (document.getElementById('myta')) {
       if (document.getElementById('myta').value == '') {
        setTimeout(worry, 5000);
       } else {
        document.body.style.cursor='pointer';
       }
     } else {
       setTimeout(worry, 5000);
     }  
  }
  
  function oops(inidis) {
     if (inidis == 'hidden') {
       setTimeout(worry, 5000);
     }
     return inidis;
  }

   </scr" . "ipt></head>    
    <body onload=\" " . $wobit . " if (('' + location.hash).indexOf('content=') != -1) { document.getElementById('myp').style.visibility=oops('hidden');  } parent.document.getElementById('dothework').style.height='80%';  parent.document.getElementById('dothework').style.display='block'; \"><p id=myp>" . yourfile_get_contents("macos_textutil_convert.err") . "</p></body></html>";
  } else if (isset($_POST['content']) && $outfis != '') {
    //sleep(20);
    file_put_contents('xv.xv',$outfis);
    if (file_exists($outfis)) {
      file_put_contents('xvv.xvv',"<html><head><scr" . "ipt type=text/javascript> function winopit() { var tow=top.window.open('','_blank','top=10,left=10,width=600,height=600'); tow.document.write(document.body.innerHTML); } setTimeout(winopit, 5000); </scr" . "ipt></head><body onload=winopit();>" . $resultof . "<textarea id=myta rows=50 cols=120>" . file_get_contents($outfis) . "</textarea></body></html>");
      echo "<html><head><scr" . "ipt type=text/javascript> function winopit() { if (window.opener) { window.opener.yesfivefive(document.body.innerHTML); } else { parent.yesfivefive(document.body.innerHTML);  if (parent.document.getElementById('toptext')) {   parent.document.getElementById('toptext').value=document.body.innerHTML.replace(/\</g,'&lt;').replace(/\>/g,'&gt;'); } else { var tow=parent.window.open('','_blank','top=10,left=10,width=600,height=600'); tow.document.write(document.body.innerHTML); } } } setTimeout(winopit, 5000); </scr" . "ipt></head><body onload=\" " . $woit . " winopit();\">" . str_replace('></div>','>' . str_replace("\n","<br>",$pltx) . '</div>',$resultof) . "<textarea id=myta rows=50 cols=120>" . file_get_contents($outfis) . "</textarea></body></html>";
    }
  }
  }
  }
  exit;
  }
} else if ((!isset($_GET['convertthis']) && !isset($_POST['convertthis'])) || !isset($_GET['outputname']) || !isset($_POST['outputname'])) {
  $outfileis="";
  if (isset($_GET['outputname'])) {
    $extis=explode(".",str_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",str_replace("+"," ",urldecode($_GET['outputname']))))];
    if (file_exists(str_replace("+"," ",urldecode($_GET['outputname'])))) {
    if (strtolower("~" . $extis, "~htm") !== false) {
    $thecontent=file_get_contents(str_replace("+"," ",urldecode($_GET['outputname'])));
    } else if (strtolower("~" . $extis, "~pdf") !== false) { // thanks to https://stackoverflow.com/questions/12730581/use-this-php-code-to-open-a-pdf-in-a-new-tab
        if (1 == 2) {
        $PDFfilename=str_replace("+"," ",urldecode($_GET['outputname']));
        $pdf = file_get_contents($PDFfilename);

        header('Content-Type: application/pdf');
        header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
        header('Pragma: public');
        header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Content-Length: ' . strlen($pdf));
        header('Content-Disposition: inline; filename="' . basename($PDFfilename) .'";');
        ob_clean(); 
        flush(); 
        echo $pdf; 
        }
        exit;  
    } else if (strtolower("~" . $extis, "~rtf") !== false) { // thanks to https://stackoverflow.com/questions/12730581/use-this-php-code-to-open-a-pdf-in-a-new-tab
        if (1 == 1) {
        $PDFfilename=str_replace("+"," ",urldecode($_GET['outputname']));
        $pdf = file_get_contents($PDFfilename);

        header('Content-Type: application/rtf');
        header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
        header('Pragma: public');
        header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Content-Length: ' . strlen($pdf));
        header('Content-Disposition: inline; filename="' . basename($PDFfilename) .'";');
        ob_clean(); 
        flush(); 
        echo $pdf; 
        } 
        exit; 
    } else {
    //echo explode(".",str_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",str_replace("+"," ",urldecode($_GET['outputname']))))];
    //exit;
    header('Content-type: application/' . explode(".",str_replace("+"," ",urldecode($_GET['outputname'])))[-1 + sizeof(explode(".",str_replace("+"," ",urldecode($_GET['outputname']))))]); 
    echo file_get_contents(str_replace("+"," ",urldecode($_GET['outputname'])));
    exit;
    }
    }
  } else if (isset($_POST['outputname'])) {  
    $extis=explode(".",str_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",str_replace("+"," ",urldecode($_POST['outputname']))))];
    if (file_exists(str_replace("+"," ",urldecode($_POST['outputname'])))) {
    if (strtolower("~" . $extis, "~htm") !== false) {
    $thecontent=file_get_contents(str_replace("+"," ",urldecode($_POST['outputname'])));
    } else if (strtolower("~" . $extis, "~pdf") !== false) { // thanks to https://stackoverflow.com/questions/12730581/use-this-php-code-to-open-a-pdf-in-a-new-tab
        if (1 == 2) {
        $PDFfilename=str_replace("+"," ",urldecode($_POST['outputname']));
        $pdf = file_get_contents($PDFfilename);

        header('Content-Type: application/pdf');
        header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
        header('Pragma: public');
        header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Content-Length: ' . strlen($pdf));
        header('Content-Disposition: inline; filename="' . basename($PDFfilename) .'";');
        ob_clean(); 
        flush(); 
        echo $pdf; 
        } 
        exit; 
    } else if (strtolower("~" . $extis, "~rtf") !== false) { // thanks to https://stackoverflow.com/questions/12730581/use-this-php-code-to-open-a-pdf-in-a-new-tab
        if (1 == 1) {
        $PDFfilename=str_replace("+"," ",urldecode($_POST['outputname']));
        $pdf = file_get_contents($PDFfilename);

        header('Content-Type: application/rtf');
        header('Cache-Control: public, must-revalidate, max-age=0'); // HTTP/1.1
        header('Pragma: public');
        header('Expires: Sat, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
        header('Content-Length: ' . strlen($pdf));
        header('Content-Disposition: inline; filename="' . basename($PDFfilename) .'";');
        ob_clean(); 
        flush(); 
        echo $pdf; 
        } 
        exit; 
    } else {
    //echo explode(".",str_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",str_replace("+"," ",urldecode($_POST['outputname']))))];
    //exit;
    header('Content-type: application/' . explode(".",str_replace("+"," ",urldecode($_POST['outputname'])))[-1 + sizeof(explode(".",str_replace("+"," ",urldecode($_POST['outputname']))))]); 
    echo file_get_contents(str_replace("+"," ",urldecode($_POST['outputname'])));
    exit;
    }
    }
  }
  echo "<html>
<head>" . $title . "
<meta charset='UTF-8'/>
<script type='text/javascript'>
  var wasv='';
  var firstgo=true;
  var lastvalue='.html';
  var oktosub=true;
  var origemail='';
  var wowo=null;
  var ourwis='&wording=Pandoc%20document%2E%20';
  var avbit='" . $avbit . "', resbit=\"" . $resbit . "\"; 
  var wasv='';
  
  function yesfivefive(restis) {
    document.getElemenetById('toptext').innerHTML=restis;
  }
  
  function checkformaybes() {
     var argd='?', argst='', contd='';
     if ((('' + document.getElementById('maybee').value).replace(/^undefined/g,'') + ('' + document.getElementById('maybes').value).replace(/^undefined/g,'')) != '') {
        document.getElementById('myform').method='GET';
        var things=document.getElementById('myform').innerHTML.split(' name=');
        var idthing='', namething='';
        for (var ith=1; ith<things.length; ith++) {
         namething=things[ith].split(' ')[0].split('>')[0].replace('\"','').replace('\"','').replace(/\'/g, '');
         idthing=namething.replace('convertto','cto').replace('outpath','opath').replace('inpath','path').replace('convertthis','thewords');
         if (namething == 'content') {
         if (document.getElementById('content0')) {
         contd='#content=' + encodeURIComponent(document.getElementById('content0').value);
         } else {
         contd='#content=' + encodeURIComponent(document.getElementById('content').value);
         }
         } else {
         if (!document.getElementById(idthing)) {   
         argst+=argd + namething + '=' + '';
         } else {
         argst+=argd + namething + '=' + encodeURIComponent(document.getElementById(idthing).value);
         }
         argd='&';
         }
        }
        location.href=document.URL.split('?')[0].split('#')[0] + argst + contd; //'?outputname=' + encodeURIComponent(document.getElementById('outputname').value)
        return false;
     }
     return true;
  }
  
  function shareit() {
     var recipient=prompt('Please enter an email address or SMS number to send results to?', '');
     if (recipient != null) {
       if (('' + recipient).trim() != '') {
        if (('' + recipient).trim().indexOf('@') != -1) {
          document.getElementById('maybee').value=('' + recipient).trim();
          document.getElementById('ifsubmit').click();
        } else if (('' + recipient).trim().replace(/0/g,'').replace(/1/g,'').replace(/2/g,'').replace(/3/g,'').replace(/4/g,'').replace(/5/g,'').replace(/6/g,'').replace(/7/g,'').replace(/8/g,'').replace(/9/g,'') == '') {
          document.getElementById('maybes').value=('' + recipient).trim();
          document.getElementById('ifsubmit').click();
        }
       }
     }
  }
  
  function yesthreethree(restis) {
   if (document.getElementById('ifesubmit')) {
    if (document.getElementById('ifsubmit')) {
      document.getElementById('ifsubmit').style.width='48%';
      document.getElementById('ifesubmit').style.display='inline-block';
    }
   }
   if (document.getElementById('content0')) {
   //alert(restis);
    document.getElementById('content0').value=restis;
    //alert('467 ' + restis);
   }
   if (document.getElementById('dinhouse')) {
   //alert(restis);
    document.getElementById('dinhouse').innerHTML+='<div id=divcontent><input type=hidden name=infname value=\"' + document.getElementById('thewords').value + '\"></input><input type=hidden name=content value=\"' + restis + '\"></input><input type=hidden name=maybee id=maybee value=\"\"></input><input type=hidden name=maybes id=maybes value=\"\"></input>';
    //setTimeout(function(){ document.getElementById('divcontent').innerHTML='';   }, 20000);
    //alert('1467 ' + document.getElementById('dinhouse').innerHTML);
   }
  }
  
  function notwotwo() {
  }
  
  function setoe() {
  localStorage.setItem('macos_textutil_convert', encodeURIComponent(origemail));
  }

  
  function worry() {
     if (document.getElementById('myta')) {
       if (document.getElementById('myta').value == '') {
        setTimeout(worry, 5000);
       } else {
        document.body.style.cursor='pointer';
       }
     } else {
       setTimeout(worry, 5000);
     }  
  }
  
  function oops(inidis) {
     if (inidis == 'hidden') {
       setTimeout(worry, 5000);
     }
     return inidis;
  }
  
  function lhit() {
  " . $curt . "
  if (('' + location.hash).indexOf('content=') != -1) {
   if (document.getElementById('myp')) { document.body.style.cursor='progress'; document.getElementById('myp').style.visibility=oops('hidden');  }
  //alert(256);
     var inna=decodeURIComponent(('' + location.hash).split('content=')[1].split('&')[0].split('#')[0]);
     if (document.getElementById('thewords').value == '') {
        if (inna.indexOf('data:') == 0) {
          inna=inna.replace(/\ /g,'+');
          document.getElementById('thewords').value='xx.' + inna.split('/')[1].split(';')[0].split(',')[0].replace('plain','txt');
          document.getElementById('thewords').blur();
        } else {
          document.getElementById('thewords').value=inna;
          document.getElementById('thewords').blur();
        }
     }
     yesthreethree(inna);
  }
  }

  function getoe() {
  " . $wobit . "
  " . $curt . "
  //alert(56);
  var eeeis=decodeURIComponent(('' + localStorage.getItem('macos_textutil_convert')).replace(/^null$/g,''));
  if (eeeis != '') { 
    origemail=eeeis; 
    if (document.getElementById('bdiv')) { document.getElementById('bdiv').innerHTML=origemail; } 
    if (document.getElementById('preaemail')) { document.getElementById('preaemail').innerHTML=origemail; } 
  }
  lhit();
  }
  
  function ots() {
    oktosub=true;
  }
  
  function dforb(evt) {
  evt.stopPropagation(); 
  if (oktosub) { document.getElementById('ifsubmit').click();  document.getElementById('myform').style.cursor='progress'; document.body.style.cursor='progress';  }
  return false;
  }
  
  function ddforb(evt) {
  evt.stopPropagation(); 
  if (oktosub) { document.getElementById('ifsubmit').click();  document.getElementById('myform').style.cursor='progress'; document.body.style.cursor='progress';  }
  return false;
  }
  
  function getask(defv, force) {
  if (defv.indexOf('@') != -1 && !force) {
  return defv;
  } else {
  var eee=prompt('Email to?',defv); 
  if (eee == null) { 
   eee=''; 
  } 
  if (eee.indexOf('@') != -1) { origemail=eee; setoe(); }
  return eee;
  }
  }
  
  function aonclick(evt) {
  evt.stopPropagation(); 
  athis=evt.target;
  oktosub=false; 
  var ee=getask(athis.innerHTML.replace('&nbsp;',''), true);
  if (ee != '') { 
   athis.innerHTML=ee.trim();  
  } 
  if (ee.indexOf('@') != -1) { 
   origemail=ee;
   oktosub=true; 
   document.getElementById('ifsubmit').click();   
  } else { 
   setTimeout(ots, 1000); 
  }
  return false;
  }
  
  function donblur(dthis) {
  oktosub=false; 
  var ee=dthis.innerHTML; 
  if (ee == null) { 
   ee=''; 
  } 
  if (ee != '') { 
   dthis.innerHTML=ee.trim();  
  } 
  if (ee.indexOf('@') != -1) { 
   if (ee != origemail) {
   oktosub=true; 
   origemail=ee;
   setoe();
   document.getElementById('ifsubmit').click();   
   }
  } else { 
   setTimeout(ots, 1000); 
  }
  }
  
  function domo(evt) {
  evt.stopPropagation(); 
  oktosub=false;
  return false;
  }
  
  function domout(evt) {
  evt.stopPropagation(); 
  oktosub=true;
  return false;
  }
  
  function ionclick(evt) {
  evt.stopPropagation(); 
  oktosub=false;
  return false;
  }
  
  function onf(evt) {
  evt.stopPropagation(); 
  oktosub=false;
  origemail=' ';
  }
  
  function tsuper() {
  if (document.getElementById('thsuperfluous')) { document.getElementById('thsuperfluous').style.visibility='hidden';    }
  if (document.getElementById('tdsuperfluous')) { document.getElementById('tdsuperfluous').style.visibility='hidden';    }
  }

  function woit() {
    var lf=100,tpq=100;
    for (var ij=0; ij<document.getElementById('thewords').value.split(',').length; ij++) {
    window.open(document.URL.split('?')[0].split('#')[0] + '?outputname=' + encodeURIComponent(document.getElementById('outputname').value.split(',')[ij]) + '&inpath=' + encodeURIComponent(document.getElementById('path').value) + '&outpath=' + encodeURIComponent(document.getElementById('opath').value) + '&convertthis=' + encodeURIComponent(document.getElementById('thewords').value.split(',')[ij]),'_blank','top=' + tpq + ',left=' + lf + ',width=500,height=500');
    lf+=20;
    tpq+=20;
    }
  }

  function thenreload() {
    location.href=document.URL.split('?')[0].split('#')[0] + '?outputname=' + encodeURIComponent(document.getElementById('outputname').value) + '&inpath=' + encodeURIComponent(document.getElementById('path').value) + '&outpath=' + encodeURIComponent(document.getElementById('opath').value) + '&dummyconvertthis=' + encodeURIComponent(document.getElementById('thewords').value);
  }
  
  function resultchange() {
    var newwo=null;
    if (document.getElementById('dbwithlf')) { document.getElementById('ifsubmit').style.display='none'; }
    if (('' + document.getElementById('resultout').value).replace(/^undefined/g,'') == '') {
    setTimeout(resultchange, 2000);
    } else if (firstgo) {
    alert(document.getElementById('resultout').value);
    firstgo=false;
    setTimeout(resultchange, 6000);
    } else if (window.opener && document.URL.indexOf('outpath=') == -1) {
    } else if (window.opener && document.URL.indexOf('outpath=') != -1) {
    if (document.URL.split('outpath=')[1].indexOf('html') != -1) {
      newwo=window.open('','_blank','left=200,top=200,width=300,height=300');
      newwo.document.write(document.getElementById('resultout').value);
    }
    }
  }
  
  function selch(thisvalue) {
    if (lastvalue != '.*') {
     while (document.getElementById('outputname').value.indexOf(lastvalue) != -1) {
      document.getElementById('outputname').value=document.getElementById('outputname').value.replace(lastvalue, '.*');
     }
    }
    document.getElementById('outputname').value=document.getElementById('outputname').value.replace(/\.\*/g,'.' + thisvalue);
    lastvalue='.' + thisvalue;
    document.getElementById('cbi').src=document.getElementById('cbi').src.split('#')[0].split('?')[0] + '?totype=' + encodeURIComponent(thisvalue.replace('*','html')) + '&d=' + Math.floor(Math.random() * 19876543);
  }
  
  function filespecit(iois) {
  var aconto=null;
  if (aconto != null) {
       aconto = (iois.contentWindow || iois.contentDocument);
       if (aconto != null) {
       if (aconto.document) { aconto = aconto.document; }
       if (aconto.body != null) {
         iois=iois;
       }
       }
  }
  }
 
 function assessit(tv) {
  if (tv.indexOf('*') != -1 || tv.indexOf('%') != -1 || tv.indexOf('$') != -1) {
    document.getElementById('globit').src=document.URL.split('#')[0].split('?')[0] + '?globit=' + encodeURIComponent(tv) + '&globpath=' + encodeURIComponent(document.getElementById('path').value) + '&globext=' + encodeURIComponent(document.getElementById('cto').value.replace('*','html'));
  } else if (tv.indexOf(',') == -1) {
    document.getElementById('outputname').value=tv.split('.')[0] + '.' + document.getElementById('cto').value.replace('*','html').replace('.','');
  }
 }
 
 function askee() {
   var msg='';
   if (document.getElementById('thewords').value.trim() != '' && document.getElementById('outputname').value.trim() != '') {
   var ee=prompt('Please enter your emailee address.','');
   if (ee == null) { ee=''; }
   if (ee.indexOf('@') != -1) {
     var inps=document.getElementsByTagName('input');
     for (var iii=0; iii<inps.length; iii++) {
     if (('~' + ('' + inps[iii].name) + '~').indexOf('to~') != -1 || ('~' + ('' + inps[iii].name) + '~').indexOf('~to') != -1) {
       inps[iii].value=ee;
     } else if (('~' + ('' + inps[iii].name) + '~').indexOf('subject~') != -1 || ('~' + ('' + inps[iii].name) + '~').indexOf('~subject') != -1) {
       //alert('lastvalue=' + lastvalue + ' and inps[iii].value=' + inps[iii].value + ' AND ' + document.getElementById('cto').value.toLowerCase()); 
       // lastvalue=.gif and inps[iii].value=0000__1-Arial_12pxnormal.pdf downloadable ready for your inhouse .pdf to .html conversions, sent to you (for you to download) as convert_audiovideo_please_html_0000__1-Arial_12pxnormal.pdf AND gif
       inps[iii].value=inps[iii].value.replace('_*_','_html_').replace('.* ','.html ');;
       if (inps[iii].value.indexOf('_html_') != -1 && document.getElementById('cto').value.toLowerCase().replace('.','') != 'html') {
          inps[iii].value=inps[iii].value.replace('_html_', '_' + document.getElementById('cto').value.toLowerCase() + '_').replace('.html ', '.' + document.getElementById('cto').value.toLowerCase() + ' ');
       } else if (inps[iii].value.indexOf(lastvalue.replace('.','_') + '_') != -1 && lastvalue.replace('.','') != document.getElementById('cto').value.replace('.','')) {
          inps[iii].value=inps[iii].value.replace(lastvalue.replace('.','_') + '_', '_' + document.getElementById('cto').value.toLowerCase() + '_').replace(lastvalue + ' ', '.' + document.getElementById('cto').value.toLowerCase() + ' ');
       } 
     } else if (('' + inps[iii].type).toLowerCase().indexOf('submit') != -1 && ('' + inps[iii].id).toLowerCase().indexOf('ifsubmit') == -1) {
       inps[iii].click();
       if (msg == '') {
         msg='Email sent';
       } else {
         msg='Emails sent';
       }
     }
     }
   }
   }
   document.getElementById('myform').style.cursor='pointer'; 
   document.body.style.cursor='pointer';    
   if (msg != '') {
     alert(msg + ' to ' + ee);
   }
 }
</script>
</head>" . $title . "
<style>
  input[type=text] { background-color: #f0f0f0;  border-radius: 5px; }
  input[type=submit] { font-size: 18px; border-radius: 20px; }
  button { font-size: 18px; border-radius: 20px; }
  div[contenteditable=true] { font-size: 14px; border-radius: 5px; }
  table { border-radius: 25px; }
</style>
<body onload=\" " . $wobit . " getoe(); " . $onl . " resultchange();\" style=\"background: linear-gradient(to left, #ffffff 40%, #ffefba 60%); \">
<br><h1>Supervise <span id=sverb>" . $panplus . "textutil</span> Document Conversions</h1>
<h3>RJM Programming - July, 2020</h3>
" . $outfileis . "
<form id=myform onsubmit=\" if (!checkformaybes()) {  return false;  } if (document.getElementById('ifsubmit').value.indexOf('mail ') != -1) { setTimeout(askee,9000); return false; } else { if (document.getElementById('thewords').value.indexOf(',') != -1) {  woit(); return false; } else { document.getElementById('myform').style.cursor='progress'; document.body.style.cursor='progress'; setTimeout(thenreload,20000); return true; } }\" target=dothework action=./macos_textutil_convert.php method=POST>
<table border=20 style='width:98%;' cellspacing=5 cellpadding=5>
<tr><th style='background-color:lightgreen;'>Input Document File(s) <span id=sin style=display:none;>in</span> <input name=inpath style=display:inline-block;width:60%; type=text id=path value='' placeholder='Optional input path'></input></th><th><select onchange=\" selch(this.value);  \" style=display:inline-block; name=convertto id=cto>
<option value='*'>Convert to</option> 
<option value='txt'>Convert to txt</option>  
<option value='rtf'>Convert to rtf</option> 
<!--option value='rtfd'>Convert to rtfd</option--> 
<option value='html'>Convert to html</option>  
<!--option value='doc'>Convert to doc</option-->  
<option value='docx'>Convert to docx</option> 
<option value='odt'>Convert to odt</option> 
<option value='wordml'>Convert to wordml</option> 
<option value='webarchive'>Convert to webarchive</option> 
<option value='pdf'>Convert to pdf</option> 
</select>&nbsp;<input name=outpath style=display:inline-block;width:30%; type=text id=opath value='" . $opth . "' placeholder='Optional output path'></input> <input style='width:40%;' onblur=\"if (document.URL.toLowerCase().indexOf('" . $rjm . "') != -1) { this.value=''; } if (this.value.toLowerCase().indexOf('.pdf') != -1) { document.getElementById('myform').target='_blank';   }  \" placeholder='Output document file(s)' type=text name=outputname id=outputname value=''></input></div>&nbsp;</th></tr>
<tr><td style='vertical-align:top;background-color:lightgreen;'><input type=text onblur=\"if (document.URL.toLowerCase().indexOf('" . $rjm . "') != -1) { this.value=''; } else { assessit(this.value); }\" style='width:90%;' placeholder='Input document file(s)' id=thewords name=convertthis  value=''></input><br><sup>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;...&nbsp;or" . $cself . "&nbsp;...&nbsp;</sup><div style='display:inline-block;width:95px;height:30px;overflow:hidden;vertical-align:text-bottom;'><iframe scrolling=no frameborder=0 id=cbi data-style='border-top:1px solid black;border-bottom:1px solid black;border-left:2px solid yellow;border-right:1px solid yellow;' style='width:173px;height:228px;margin-top:-194px;' src='HTMLCSS/client_browsing.htm?totype=html&d=" . rand(0,18765432) . "'></iframe></div></td><td style=vertical-align:top;><div id=dforbutton>" . $divinfront . "</div><input id=ifsubmit style='width:100%;height:100px;background-color:yellow;' type=submit value='" . $cvse . " Document(s)'></input>&nbsp;<input onclick=shareit(); id=ifesubmit style='width:48%;height:100px;background-color:lightblue;display:none;' type=button value='" . $cvse . " Document(s) to Recipient'></input><br><div id=resultout>" . str_replace("\n","<br>",$thecontent) . "</div></td></tr>
</table>
<div id=dinhouse></div>
</form>
<iframe style='width:100%;height:0px;display:none;' frameborder=0 name=dothework id=dothework src=macos_textutil_convert.php></iframe>
<iframe onload='filespecit(this);' style='display:none;' id=globit src=></iframe>
<input type=text style='position:absolute;top:-1200px;left:-1200px;'></input>
<input type=hidden id=turl value=''></input>
<div id=dforms>" . $resbit . "</div>
</body>
</html>";
} 
} else {
// try {
//   @file_get_contents('HTTP://localhost' . $lportbit . '/macos_textutil_convert.php?imgname=' . $imgn);
//   sleep(2);
// } catch (Exception $exc) { }
 echo "<html><head><scr" . "ipt type=text/javascript> 
 var tryit='HTTP://localhost" . $lportbit . "/" . $imgn . "'; 
 var thatone='', thattwo='';
 var wowowo=null;
   
 function calledlater() {
            if (tryit != '') {
            if (!inIframe() && document.URL.indexOf('https:') == 0 && document.URL.indexOf('localhost') == -1 && navigator.userAgent.toLowerCase().indexOf('safari/') > -1) {
              location.href=document.URL.replace('https:','http:');
            }
            if (1 == 5) {
            // document.body.style.background='URL(" . "HTTP://localhost" . $lportbit . "/" . $imgn . ")'; 
   // window.open('HTTP://localhost" . $lportbit . "/" . $imgn . "','xxlocit');
            var im=new Image();

    im.onload = function() {
      console.log('event')
            tryit+=' ';
    };
 
    
  im.onerror = function error(event) {
      console.log(event)
  };
               
            im.src=tryit + '';
            }
            }
 }

 function windowopen(theone, thetwo) {
   var asu=('&" . $_SERVER['QUERY_STRING'] . "').replace(/^\&$/g,'');  
   wowowo=window.open('HTTP://localhost" . $lportbit . "/macos_textutil_convert.php?imgname=" . $imgn . "' + asu,'xxlocit');
   thatone=theone;
   thattwo=thetwo;
   setTimeout(postwo, 4000);
 }
 
 function postwo() {
   if (tryit.trim() == tryit) {
     return null;
   } 
   wowo=window.open(thatone, thattwo);
 }
 
 function inIframe () {  // thanks to https://stackoverflow.com/questions/326069/how-to-identify-if-a-webpage-is-being-loaded-inside-an-iframe-or-directly-into-t
    try {
        return window.self !== window.top;
    } catch (e) {
        return true;
    }
 }
  
 function mamptry() { " . $innards . "
 }
 
 setTimeout(calledlater, 2000);
  
</scr" . "ipt><title>Email off your Document Conversion Attachment Input Files for Your Inhouse Document Converter to Listen For and Convert</title></head><body onload=setTimeout(mamptry,9000);><p>This PHP web application only works with macOS and its textutil -convert [outextension] [infilename] -output [outfilename] command line Document Conversion functionality, or install <a target=_blank title='pandoc Document Conversion' href='https://pandoc.org/'>pandoc</a> (for Windows).  Perhaps consider getting a local Apache/PHP/MySql web server such as <a target=_blank title='MAMP for Apache/PHP/MySql on Mac OS X local web server' href='http://www.mamp.info'><i>MAMP</i></a> or you have an email listener and will <a target=_self href='./macos_textutil_convert.php?emailanyway=y'>Email and Download</a> to that emailee to do the conversions</p><br><br><iframe style=display:none;width:100%;height:900px; name=mamptry id=mamptry src=></iframe><iframe name=xxlocit id=xxlocit style='display:none;' src=></iframe></body><html>";
 exit;
}
?>
