<?php
// ziptest.php
// RJM Programming
// September, 2017
// Testing PHP zip file functionalities in PHP
// Thanks to https://www.w3schools.com/PHP/func_zip_entry_open.asp
 
$mtitles=["MAMP local Apache/PHP/MySql web server for URLs HTTP://localhost:8888/ ... if no others to right, a zipfile called mamptest.zip has good PHP code sources to save to /Applications/MAMP/htdocs/ to team up with MAMP HTTP://localhost:8888/","Convert text to audible speech","Interact with CD/DVD burners","Prevent the system from sleeping on behalf of a utility","Use FileMerge to graphically compare or merge file or directories","Quick Look Server debug and management tool","Secure copy (remote file copy program)"];

function mamptest($mode) {
 global $mtitles;
 if ($_SERVER['SERVER_PORT'] === "8888" && PHP_OS === "Darwin") {
   if ($mode != "") {
    return " or MAMP URL appended to http://localhost:8888/";
   } else {
    $more="";
    if (file_exists("say.php")) $more.=" <input title='" . $mtitles[1] . "' class=mamp onclick=\"mampit('say');\" style='background-color:yellow;' name=say type=button value='Say'>";
    if (file_exists("drutil.php")) $more.=" <input title='" . $mtitles[2] . "' class=mamp onclick=\"mampit('drutil');\" style='background-color:yellow;' name=drutil type=button value='Drutil'>";
    if (file_exists("caffeinate.php")) $more.=" <input title='" . $mtitles[3] . "' class=mamp onclick=\"mampit('caffeinate');\" style='background-color:yellow;' name=caffeinate type=button value='Caffeinate'>";
    if (file_exists("opendiff.php")) $more.=" <input title='" . $mtitles[4] . "' class=mamp onclick=\"mampit('opendiff');\" style='background-color:yellow;' name=opendiff type=button value='Opendiff'>";
    if (file_exists("qlmanage.php")) $more.=" <input title='" . $mtitles[5] . "' class=mamp onclick=\"mampit('qlmanage');\" style='background-color:yellow;' name=qlmanage type=button value='Qlmanage'>";
    if (file_exists("scp.php")) $more.=" <input title='" . $mtitles[6] . "' class=mamp onclick=\"mampit('scp');\" style='background-color:yellow;' name=scp type=button value='Scp'>";
    return "<input title='" . $mtitles[0] . "' class=mamp onclick=\"mampit('MAMP');\" style='background-color:yellow;' id=mamp name=mamp type=button value='MAMP'>" . $more;
   }
 }
 if ($mode == "") return "<div id='mmore' style='inline-block;'><br><input title='" . $mtitles[0] . "' class=mamp onclick=\"mampit('MAMP');\" style='background-color:yellow;display:none;' id=mamp name=mamp type=button value='MAMP'></div>"; 
 return "";
}

function reencode($theargs, $helpprefix, $sentencemode) {
  $retval="";
  if ($theargs == "") return $theargs;
  if (strpos(($theargs . "~!"), "&~!") !== false) $theargs=str_replace("&~!","?",($theargs . "~!"));
  if (strpos($theargs, "&") === false && $helpprefix != "") {
    $abits=explode(" ", $theargs);
    $retval.="&" . $helpprefix . '=' . urlencode($abits[0]);
    for ($iab=1; $iab<sizeof($abits); $iab++) {
     if ($sentencemode == 'sentence') {
      $retval.='%20' . urlencode($abits[$iab]);
     } else {
      $retval.="&" . $helpprefix . (1 + $iab) . '=' . urlencode($abits[$iab]);
     }
    }
  } else if (strpos($theargs, "&") === false) {
    return urlencode($theargs);
  } else if (strpos($theargs, "=") === false) { 
    return $theargs . "=";
  } else {
    $abits=explode("=", $theargs);
    $retval.="&" . explode("&",$abits[0])[-1 + sizeof(explode("&",$abits[0]).length)] . '=' . urlencode(explode("&",$abits[1])[0]);
    for ($iab=2; $iab<sizeof($abits); $iab+=2) {
     $retval.="&" . explode("&",$abits[$iab])[-1 + sizeof(explode("&",$abits[$iab]).length)] . '=' . urlencode(explode("&",$abits[1 + $iab])[0]);
    }
  }
  return $retval;
}

$types = ["audio/wav","audio/x-wav","audio/x-pn-realaudio","audio/x-mpegurl","audio/x-aiff","audio/x-aifc","audio/mpeg","audio/mid",
      "audio/basic","audio/ogg","video/x-sgi-movie","video/x-msvideo","video/quicktime","audio/mp3","video/mp4","video/mpeg",
      "video/x-la-asf","video/ogg","video/webm","audio/mp4", "image/jpeg", "image/jpeg", "image/png", "image/gif", "image/bmp", "image/tif",
      "text/html", "text/html", "text/html", "text/javascript", "text/css", "text/plain", "text/xml", "text/csv",
      "application/vnd.ms-word", "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "application/x-php", "application/pdf",
      "application/vnd.openxmlformats-officedocument.presentationml.presentation", "application/vnd.ms-powerpoint",
      "application/vnd.ms-excel", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"];
$exts = [".wav",".wav",".ram",".m3u",".aiff",".aifc",".mp3",".rmi",
      ".snd",".ogg",".movie",".avi",".mov",".mp3",".m4v",".mpeg",
      ".lsx",".ogv",".webm",".m4a", ".jpg", ".jpeg", ".png", ".gif", ".bmp", ".tif",
      ".htm", ".html", ".htmls", ".js", ".css", ".txt", ".xml", ".csv", 
      ".doc", ".docx", ".php", ".pdf",
      ".pptx", ".ppt",
      ".xls", ".xlsx"];
      
$mampurl="";

$mampa="";
$onc=" window.location=document.URL.split('#')[0].replace('&myh1=y','') + '&myh1=y#myh1'; ";  
$ic="^";  
$itable="#itable";
if (strpos(("" . $_SERVER['QUERY_STRING']), "myh1=") !== false) {
 $ic="v";  
 $itable="&myh1=y#myh1";
 $onc=" window.location=document.URL.split('#')[0].replace('&myh1=y','') + '#itable'; ";  
}

$vsynclist="";
$asynclist="";
$burl="";
$muted="";
if (isset($_GET['muted'])) {
 $muted=" " . urldecode($_GET['muted']);
}

$zipfile="";
if (isset($_GET['zipfile'])) {
  $zipfile=urldecode($_GET['zipfile']);
}
      
$jsc="<style> td { text-align: center; } \n .mamp { border: 2px solid red; } </style>
      <scri" . "pt type='text/javascript'> 
    var jmampa=\"\",lasterr=-1,could_be_mac=false, is_mac=false, bigiu=-1, req, tr='', jsup=1, jsub=1, rawy='', htok=true, vsynclist=[], asynclist=[], loadedsynclist=[]; avo=[];
    var mampideas=['say.php','drutil.php','caffeinate.php','opendiff.php','qlmanage.php','scp.php']; 
    var mtitles=['MAMP local Apache/PHP/MySql web server for URLs HTTP://localhost:8888/ ... if no others to right a zipfile called mamptest.zip has good PHP code sources to save to /Applications/MAMP/htdocs/ to team up with MAMP HTTP://localhost:8888/','Convert text to audible speech','Interact with CD/DVD burners','Prevent the system from sleeping on behalf of a utility','Use FileMerge to graphically compare or merge file or directories','Quick Look Server debug and management tool','Secure copy (remote file copy program)'];
    function animqnextone() {
      jsup=eval(document.getElementById('jsup').innerHTML.replace('&nbsp;','').replace('g',''));
      jsub=eval(document.getElementById('jsub').innerHTML.replace('&nbsp;','').replace('g',''));
      if (jsup < jsub) {
        jsup++;
        document.getElementById('jsup').innerHTML=jsup;
        window.location='#g' + jsup;
        if (htok) setTimeout(animqnextone,2000);
      } else {
        if (htok) setTimeout(animqprevone,2000);
      }
    }
    function animqprevone() {
      jsup=eval(document.getElementById('jsup').innerHTML.replace('&nbsp;','').replace('g',''));
      jsub=eval(document.getElementById('jsub').innerHTML.replace('&nbsp;','').replace('g',''));
      if (jsup > 1) {
        jsup--;
        document.getElementById('jsup').innerHTML=jsup;
        window.location='#g' + jsup;
        if (htok) setTimeout(animqprevone,2000);
      } else {
        if (htok) setTimeout(animqnextone,2000);
      }
    }
    function animnextone() {
      var wls, wlstwo='';
      if (document.getElementById('ishownext')) {
        if (document.getElementById('ishownext').outerHTML.indexOf(' onclick=') != -1) {
          wls=document.getElementById('ishownext').outerHTML.replace(/&amp;/g,'&').split('window.location=');
          if (wls.length > 1) {
            wlstwo=wls[1].substring(1).split(wls[1].substring(0,1))[0].split('#')[0].replace('&animf=y','').replace('&animb=y','') + '&animf=y" . $itable . "';
            window.location=wlstwo;
          }
        } else {
          setTimeout(animprevone,8000);
        }
      }
    }
    function animprevone() {
      var wls, wlstwo='';
      if (document.getElementById('ishowprev')) {
        if (document.getElementById('ishowprev').outerHTML.indexOf(' onclick=') != -1) {
          wls=document.getElementById('ishowprev').outerHTML.replace(/&amp;/g,'&').split('window.location=');
          if (wls.length > 1) {
            wlstwo=wls[1].substring(1).split(wls[1].substring(0,1))[0].split('#')[0].replace('&animf=y','').replace('&animb=y','') + '&animb=y" . $itable . "';
            window.location=wlstwo;
          }
        } else {
          setTimeout(animnextone,8000);
        }
      }
    }
    
    function nounderline() {
      if (document.getElementById('ianim')) document.getElementById('ianim').style.textDecoration='none';
      if (document.getElementById('janim')) document.getElementById('janim').style.textDecoration='none';
    }
    
    function checkrawy() {
      if (document.getElementById('rawy').value != '') rawy='rawy=y&';
    }

    
    function setoff0() { var mediao=avo[0];  mediao.play(); } 
    function setoff1() { var mediao=avo[1];  mediao.play(); } 
    function setoff2() { var mediao=avo[2];  mediao.play(); } 
    function setoff3() { var mediao=avo[3];  mediao.play(); } 
    function setoff4() { var mediao=avo[4];  mediao.play(); } 
    function setoff5() { var mediao=avo[5];  mediao.play(); } 
    function setoff6() { var mediao=avo[6];  mediao.play(); } 
    function setoff7() { var mediao=avo[7];  mediao.play(); } 
    function setoff8() { var mediao=avo[8];  mediao.play(); } 
    function setoff9() { var mediao=avo[9];  mediao.play(); } 

    function checkav() {
      if (loadedsynclist.length >= (document.getElementById('videoflag').value.length + document.getElementById('audioflag').value.length)) {
        for (var ij=0; ij<loadedsynclist.length; ij++) {
          if (eval(ij % 10) == 0) { setTimeout(setoff0, eval(1000 - ij)); }
          else if (eval(ij % 10) == 1) { setTimeout(setoff1, eval(1000 - ij)); } 
          else if (eval(ij % 10) == 2) { setTimeout(setoff2, eval(1000 - ij)); } 
          else if (eval(ij % 10) == 3) { setTimeout(setoff3, eval(1000 - ij)); } 
          else if (eval(ij % 10) == 4) { setTimeout(setoff4, eval(1000 - ij)); } 
          else if (eval(ij % 10) == 5) { setTimeout(setoff5, eval(1000 - ij)); } 
          else if (eval(ij % 10) == 6) { setTimeout(setoff6, eval(1000 - ij)); } 
          else if (eval(ij % 10) == 7) { setTimeout(setoff7, eval(1000 - ij)); } 
          else if (eval(ij % 10) == 8) { setTimeout(setoff8, eval(1000 - ij)); } 
          else if (eval(ij % 10) == 9) { setTimeout(setoff9, eval(1000 - ij)); } 
        }
      } else {
        setTimeout(checkav,3000);
      }
    }
    
    function weareready(iois) {
    if (iois != null) {
    var aconto = (iois.contentWindow || iois.contentDocument);
    if (aconto != null) {
     if (aconto.document) { aconto = aconto.document; }
     if (aconto.body != null) {
       loadedsynclist.push(iois.id);
       if (aconto.getElementById('myvideo')) avo.push(aconto.getElementById('myvideo'));
       if (aconto.getElementById('myaudio')) avo.push(aconto.getElementById('myaudio'));
       if (loadedsynclist.length == (vsynclist.length + asynclist.length)) setTimeout(checkav, 1000);
     }
    }
    }
    }
    
    function ajobs() {
        for (var iu=0; iu<mampideas.length; iu++) {
    if (iu == bigiu) {
    $('#b' + iu).on('click', function() {
    $.ajax({
     url: 'http:/" . "/localhost:8888/' + mampideas[iu],
     dataType: 'jsonp',
     timeout: 5000,
     success: function (parsed_json) {
       //console.log(parsed_json);
     },
     error: function (parsedjson, textStatus, errorThrown) {
       lasterr=parsedjson.status;
       document.getElementById('mamptest').style.display='none';
     }
     });
     });
        document.getElementById('b' + bigiu).click();
        }
        }
    }
    
    function rezipit(newzipf) {
      if (newzipf != '') window.location=document.URL.split('#')[0].split('?')[0] + '?zipfile=' + encodeURIComponent(newzipf) + '&ofinterest=' + encodeURIComponent(document.getElementById('ofinterest').value); 
    }
    
    function mampit(usuffix) {
      window.location=document.URL.split('#')[0].split('?')[0] + '?zipfile=" . urlencode($zipfile) . "&ofinterest=' + '&' + usuffix.toLowerCase() + '=' + encodeURIComponent(usuffix); 
    }
    
    function checkjmampa() {
     if (!document.getElementById('mamp')) {
      if (document.getElementById('mmore')) {
          document.getElementById('mmore').innerHTML+=jmampa;
      } else if (document.getElementById('myform')) {
          document.getElementById('myform').innerHTML+=jmampa;
      } 
     } else if (is_mac || could_be_mac) {
      if (('' + document.getElementById('mamp').style.display).toLowerCase().indexOf('none') != -1) {
      if (document.getElementById('mmore')) {
          document.getElementById('mmore').innerHTML+=jmampa;
      } else if (document.getElementById('myform')) {
          document.getElementById('myform').innerHTML+=jmampa;
      } 
      }
     }
    }
    
    function newarg(olda) {
      if (olda.indexOf('?') != -1) {
        return olda.split('#')[0] + '&rand=' + Math.random();
      } else {
        return olda.split('#')[0] + '?rand=' + Math.random();
      }
    }
    
    function checkmamp() {
      if (bigiu < 0) {
       if (('' + navigator.ospu).toUpperCase().indexOf('MAC') == 0) {
         is_mac=true;
       } else if (('' + navigator.platform).toUpperCase().indexOf('WIN') != 0) {
         could_be_mac=true;
       }
       if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
         is_mac=false;
         could_be_mac=false;
       }
       if ((lasterr == 200 || document.getElementById('mamptest').innerHTML.indexOf('200') != -1) && could_be_mac) {
        if (document.getElementById('mamp')) document.getElementById('mamp').style.display='inline-block';
         document.getElementById('mamptest').innerHTML='';
         bigiu=0;
         ajobs();
         setTimeout(checkmamp, 5300);
         var oa=document.getElementsByTagName('a');
         for (var iy=0; iy<oa.length; iy++) {
           if (oa[iy].title == 'Click to download') oa[iy].title+=' ... then think to perhaps save/copy/move to /Applications/MAMP/htdocs/ to team up with MAMP HTTP://localhost:8888/';
         }
       }
       lasterr=-1;
      } else if (bigiu < eval(0 + mampideas.length)) {
        if ((lasterr == 200 || document.getElementById('mamptest').innerHTML.indexOf('200') != -1)) {
         document.getElementById('mamptest').innerHTML='';
         if (document.getElementById('mmore')) document.getElementById('mmore').innerHTML+=\" <input title='\" + mtitles[eval(1 + bigiu)] + \"' class=mamp onclick=mampit('\" + mampideas[bigiu].split('.')[0] + \"'); style='background-color:yellow;display:inline-block;' name=\" + mampideas[bigiu].split('.')[0] + \" type=button value='\" + mampideas[bigiu].split('.')[0].substring(0,1).toUpperCase() + mampideas[bigiu].split('.')[0].substring(1).toLowerCase() + \"'>\";
        }
        lasterr=-1;
        if (bigiu < eval(-1 + mampideas.length)) {
          bigiu++;
          ajobs();
          setTimeout(checkmamp, 5300);
        }
      }
    }
    
    if (document.URL.indexOf('&animf=') != -1) {
      setTimeout(nounderline, 300);
      setTimeout(animnextone, 8000);
    } else if (document.URL.indexOf('&animb=') != -1) {
      setTimeout(nounderline, 300);
      setTimeout(animprevone, 8000);
    }
    
    setTimeout(checkrawy, 2800); 
    setTimeout(checkmamp, 5300); 
    setTimeout(checkjmampa, 6300); 
    
    /" . "/ Thanks to https:/" . "/stackoverflow.com/questions/19035557/jsonp-request-error-handling
    $(document).ready(function(){
    $.ajax({
     url: 'http:/" . "/localhost:8888/MAMP/',
     dataType: 'jsonp',
     timeout: 5000,
     success: function (parsed_json) {
       //console.log(parsed_json);
     },
     error: function (parsedjson, textStatus, errorThrown) {
       if (('' + errorThrown).indexOf('Blocked loading ') != -1 && document.URL.toLowerCase().indexOf('https:') == 0) {
        window.location=newarg('http' + document.URL.substring(5)) + location.hash;
       } else if (('' + errorThrown).indexOf('Loading failed ') != -1) {
        if (document.URL.toLowerCase().indexOf('https:') == 0) {
        window.location=newarg('http' + document.URL.substring(5)) + location.hash;
        }
        lasterr=404;
       } else {
        lasterr=parsedjson.status;
       }
       if (lasterr != 200 && document.URL.toLowerCase().indexOf('https:') == 0) {
       if (('' + navigator.ospu).toUpperCase().indexOf('MAC') == 0) {
         is_mac=true;
       } else if (('' + navigator.platform).toUpperCase().indexOf('WIN') != 0) {
         could_be_mac=true;
       }
       if (navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) {
         is_mac=false;
         could_be_mac=false;
       }
       if (document.URL.toLowerCase().indexOf('https:') == 0) document.title=lasterr + ' ' + newarg('http' + document.URL.substring(5)) + location.hash;
         if (is_mac || could_be_mac) window.location=newarg('http' + document.URL.substring(5)) + location.hash;
       }
       //console.log(JSON.stringify(parsedjson).replace(/>/g,'&gt;').replace(/</g,'&lt;'));
       //document.getElementById('mamptest').innerHTML='' + parsedjson.status;
       document.getElementById('mamptest').style.display='none';
     }
     });
    });
    </scr" . "ipt>
    ";
    
$rawystuff="<input style=display:none; id=b0 type=button value=b0><input style=display:none; id=b1 type=button value=b1><input style=display:none; id=b2 type=button value=b2><input style=display:none; id=b3 type=button value=b3><input style=display:none; id=b4 type=button value=b4><input style=display:none; id=b5 type=button value=b5><div id='mamptest' style='position:absolute;top:-500px;left:-500px;display:none;'></div><input id='rawy' value='' type='hidden'>";
$syncstuff="<input id='videoflag' type='hidden' value=''><input id='audioflag' type='hidden' value=''><div id='davsynch' style='display:none;'><iframe onload='weareready(this);' src='./ziptest.php' id='iavsynch2' style='display:inline-block;height:500px;'></iframe></div>";  

$gthisis=1;
$gtotis=0;
$thisis=0;
$totis=0;
$numis=0;
$ourfilename="";
$ofprevinterest="";
$firstone="";
$lastone="";
$secondone="";
$secondlastone="";
$prevone="";
$nextone="";
$prevtoprevone="";
$nexttoprevone="";
$nexttonextone="";
$prevtonextone="";

$gnumis=0;
$greportdata="";
$gofprevinterest="";
$ofinterest="youllneverfindthis";
if (isset($_GET['ofinterest'])) {
  $ofinterest=urldecode($_GET['ofinterest']);
  if (isset($_GET['say'])) {
  $mampurl="http://localhost:8888/say.php?argsfollow=" . reencode(str_replace("+"," ",str_replace("?","&",str_replace("say.php","",$ofinterest))),'say','sentence');
  } else if (isset($_GET['drutil'])) {
  $mampurl="http://localhost:8888/drutil.php?argsfollow=" . reencode(str_replace("+"," ",str_replace("?","&",str_replace("drutil.php","",$ofinterest))),'drutil','sentence');
  } else if (isset($_GET['caffeinate'])) {
  $mampurl="http://localhost:8888/caffeinate.php?argsfollow=" . reencode(str_replace("+"," ",str_replace("?","&",str_replace("caffeinate.php","",$ofinterest))),'caffeinate','sentence');
  } else if (isset($_GET['opendiff'])) {
  $mampurl="http://localhost:8888/opendiff.php?argsfollow=" . reencode(str_replace("+"," ",str_replace("?","&",str_replace("opendiff.php","",$ofinterest))),'opendiff','sentence');
  } else if (isset($_GET['qlmanage'])) {
  $mampurl="http://localhost:8888/qlmanage.php?argsfollow=" . reencode(str_replace("+"," ",str_replace("?","&",str_replace("qlmanage.php","",$ofinterest))),'qlmanage','sentence');
  } else if (isset($_GET['scp'])) {
  $mampurl="http://localhost:8888/scp.php?argsfollow=" . reencode(str_replace("+"," ",str_replace("?","&",str_replace("scp.php","",$ofinterest))),'scp','sentence');
  } else if (isset($_GET['mamp'])) {
  $mampurl="http://localhost:8888/MAMP/?argsfollow=" . reencode(str_replace("+"," ",str_replace("?","&",str_replace("MAMP/","",$ofinterest))),'mamp','sentence');
  } 
  if ($ofinterest == "") $ofinterest="youllneverfindthis";
}
$asgallery="";
if (isset($_GET['asgallery'])) {
  $asgallery=urldecode($_GET['asgallery']);
}
     
if (isset($_GET['ofinterest']) && isset($_GET['ofprevinterest']) && isset($_GET['ofnextinterest'])) {
$formstuff="<br><form id=myform style='padding:5px 5px 5px 5px;border:3px solid red;background-color:pink;' action='./ziptest.php' method=GET>
  Zipfile Name: <input onblur=rezipit(this.value); type=text name=zipfile value='" . $zipfile . "' title='Zipfile name goes here'><br>
  Zipfile File of Interest (can be comma separated list" . mamptest("suffix") . "): <input style='width:60%;' type=text id=ofinterest name=ofinterest value='" . str_replace("youllneverfindthis","",$ofinterest) . "' title='Zipfile file of Interest name goes here'><br><select id=mysel onchange=\" if (this.value != '') { if (document.getElementById('ofinterest').value != '') { document.getElementById('ofinterest').value+=','; } document.getElementById('ofinterest').value+=this.value; } \"><option value=''>Optionally please add to list above selecting below ...</option></select><br>
  <br><br><input style='background-color:yellow;' type=submit name=asgallery value='Display Media Gallery from Media Files within Zipfile'> <input onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&asgallery=y'; \" style='background-color:yellow;' type=button value='Media Gallery of all Media in Zipfile List'> <input onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "'; \" style='background-color:yellow;' type=button value='This Zipfile List'> <input style='background-color:yellow;' type=submit value='Other Zipfile Run'> <input style='background-color:yellow;' name=synchronize type=submit value='Synchronize'> " . mamptest("") . "   
  </form><br><table id='itable' style='width:100%;'><tbody><tr><td style='vertical-align:top;width:5%;background-color:rgba(255,0,0,0.2);'><a id='ishowprev' style='cursor:pointer;text-decoration:none;display:none;'>&lt;</a></td><td style='width:90%;'><table><tbody><tr><td style='width:5%;background-color:rgba(127,127,0,0.2);'><a id='ishowfirst' style='cursor:pointer;text-decoration:none;display:none;'>&lt;&lt;</a></td><td style='width:15%;background-color:rgba(127,127,127,0.2);'><a id='ianim' style='cursor:pointer;text-decoration:underline;display:block;' title='Animate a slideshow' onclick=' nounderline(); setTimeout(animnextone,3000);  '>&#127916;<sup id=isup></sup></a><sub id=isub></sub></a></td><td style='width:15%;background-color:rgba(127,0,127,0.2);'><a id='ianim' style='cursor:pointer;text-decoration:none;display:block;' title='Hashtag positioning' onclick=\"" . $onc . "\">" . $ic . "</a></td><td style='border:5px solid purple;'><a onclick=\"window.open('" . "./ziptest.php?' + rawy + 'zipfile=" . $zipfile . "&ofinterest=" . $ofinterest . $itable . "','_blank'); \" title='New window for this' style='cursor:pointer;text-decoration:underline;'>" . $ofinterest . "</a></td><td style='width:5%;background-color:rgba(0,255,0,0.2);'><a id='ishowlast' style='cursor:pointer;text-decoration:none;display:none;'>&gt;&gt;</a></td></tr></tbody></table><br><iframe frameborder=0 width='90%' height='600px;' id='ishow' src='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $ofinterest . $itable . "'></iframe></td><td style='vertical-align:top;width:5%;background-color:rgba(0,0,255,0.2);'><a id='ishownext' style='cursor:pointer;text-decoration:none;display:none;'>&gt;</a></td></td></td></tbody></table>";
} else if (isset($_GET['ofinterest']) && isset($_GET['ofprevinterest'])) {
$formstuff="<br><form id=myform style='padding:5px 5px 5px 5px;border:3px solid red;background-color:pink;' action='./ziptest.php' method=GET>
  Zipfile Name: <input onblur=rezipit(this.value); type=text name=zipfile value='" . $zipfile . "' title='Zipfile name goes here'><br>
  Zipfile File of Interest (can be comma separated list" . mamptest("suffix") . "): <input style='width:60%;' type=text id=ofinterest name=ofinterest value='" . str_replace("youllneverfindthis","",$ofinterest) . "' title='Zipfile file of Interest name goes here'><br><select id=mysel onchange=\" if (this.value != '') { if (document.getElementById('ofinterest').value != '') { document.getElementById('ofinterest').value+=','; } document.getElementById('ofinterest').value+=this.value; } \"><option value=''>Optionally please add to list above selecting below ...</option></select><br>
  <br><br><input style='background-color:yellow;' type=submit name=asgallery value='Display Media Gallery from Media Files within Zipfile'> <input onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&asgallery=y'; \" style='background-color:yellow;' type=button value='Media Gallery of all Media in Zipfile List'> <input onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "'; \" style='background-color:yellow;' type=button value='This Zipfile List'> <input style='background-color:yellow;' type=submit value='Other Zipfile Run'> <input style='background-color:yellow;' name=synchronize type=submit value='Synchronize'> " . mamptest("") . "
  </form><br><table id='itable' style='width:100%;'><tbody><tr><td style='vertical-align:top;width:5%;;background-color:rgba(255,0,0,0.2);'><a id='ishowprev' style='cursor:pointer;text-decoration:none;display:none;'>&lt;</a></td><td style='width:90%;'><table><tbody><tr><td style='width:5%;background-color:rgba(127,127,0,0.2);'><a id='ishowfirst' style='cursor:pointer;text-decoration:none;display:none;'>&lt;&lt;</a></td><td style='width:15%;background-color:rgba(127,127,127,0.2);'><a id='ianim' style='cursor:pointer;text-decoration:underline;display:block;' title='Animate a slideshow' onclick=' nounderline();  setTimeout(animnextone,3000);  '>&#127916;<sup id=isup></sup></a><sub id=isub></sub></a></td><td style='width:15%;background-color:rgba(127,0,127,0.2);'><a id='ianim' style='cursor:pointer;text-decoration:none;display:block;' title='Hashtag positioning' onclick=\"" . $onc . "\">" . $ic . "</a></td><td style='border:5px solid purple;'><a onclick=\"window.open('" . "./ziptest.php?' + rawy + 'zipfile=" . $zipfile . "&ofinterest=" . $ofinterest . $itable . "','_blank'); \" title='New window for this' style='cursor:pointer;text-decoration:underline;'>" . $ofinterest . "</a></td><td style='width:5%;background-color:rgba(0,255,0,0.2);'><a id='ishowlast' style='cursor:pointer;text-decoration:none;display:none;'>&gt;&gt;</a></td></tr></tbody></table><br><iframe frameborder=0 width='90%' height='600px;' id='ishow' src='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $ofinterest . $itable . "'></iframe></td><td style='vertical-align:top;width:5%;background-color:rgba(0,0,255,0.2);'><a id='ishownext' style='cursor:pointer;text-decoration:none;display:none;'>&gt;</a></td></td></td></tbody></table>";
} else if (isset($_GET['ofinterest']) && isset($_GET['ofnextinterest'])) {
$formstuff="<br><form id=myform style='padding:5px 5px 5px 5px;border:3px solid red;background-color:pink;' action='./ziptest.php' method=GET>
  Zipfile Name: <input onblur=rezipit(this.value); type=text name=zipfile value='" . $zipfile . "' title='Zipfile name goes here'><br>
  Zipfile File of Interest (can be comma separated list" . mamptest("suffix") . "): <input style='width:60%;' type=text id=ofinterest name=ofinterest value='" . str_replace("youllneverfindthis","",$ofinterest) . "' title='Zipfile file of Interest name goes here'><br><select id=mysel onchange=\" if (this.value != '') { if (document.getElementById('ofinterest').value != '') { document.getElementById('ofinterest').value+=','; } document.getElementById('ofinterest').value+=this.value; } \"><option value=''>Optionally please add to list above selecting below ...</option></select><br>
  <br><br><input style='background-color:yellow;' type=submit name=asgallery value='Display Media Gallery from Media Files within Zipfile'> <input onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&asgallery=y'; \" style='background-color:yellow;' type=button value='Media Gallery of all Media in Zipfile List'> <input onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "'; \" style='background-color:yellow;' type=button value='This Zipfile List'> <input style='background-color:yellow;' type=submit value='Other Zipfile Run'> <input style='background-color:yellow;' name=synchronize type=submit value='Synchronize'> " . mamptest("") . "
  </form><br><table id='itable' style='width:100%;'><tbody><tr><td style='vertical-align:top;width:5%;;background-color:rgba(255,0,0,0.2);'><a id='ishowprev' style='cursor:pointer;text-decoration:none;display:none;display:none;'>&lt;</a></td><td style='width:90%;'><table><tbody><tr><td style='width:5%;background-color:rgba(127,127,0,0.2);'><a id='ishowfirst' style='cursor:pointer;text-decoration:none;display:none;'>&lt;&lt;</a></td><td style='width:15%;background-color:rgba(127,127,127,0.2);'><a id='ianim' style='cursor:pointer;text-decoration:underline;display:block;' title='Animate a slideshow' onclick=' nounderline();  setTimeout(animnextone,3000);  '>&#127916;<sup id=isup></sup></a><sub id=isub></sub></a></td><td style='width:15%;background-color:rgba(127,0,127,0.2);'><a id='ianim' style='cursor:pointer;text-decoration:none;display:block;' title='Hashtag positioning' onclick=\"" . $onc . "\">" . $ic . "</a></td><td style='border:5px solid purple;'><a onclick=\"window.open('" . "./ziptest.php?' + rawy + 'zipfile=" . $zipfile . "&ofinterest=" . $ofinterest . $itable . "','_blank'); \" title='New window for this' style='cursor:pointer;text-decoration:underline;'>" . $ofinterest . "</a></td><td style='width:5%;background-color:rgba(0,255,0,0.2);'><a id='ishowlast' style='cursor:pointer;text-decoration:none;display:none;'>&gt;&gt;</a></td></tr></tbody></table><br><iframe frameborder=0 width='90%' height='600px;' id='ishow' src='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $ofinterest . $itable . "'></iframe></td><td style='vertical-align:top;width:5%;background-color:rgba(0,0,255,0.2);'><a id='ishownext' style='cursor:pointer;text-decoration:none;display:none;'>&gt;</a></td></td></td></tbody></table>";
} else if (1 == 2 && isset($_GET['ofinterest'])) {
$formstuff="<br><form id=myform style='padding:5px 5px 5px 5px;border:3px solid red;background-color:pink;' action='./ziptest.php' method=GET>
  Zipfile Name: <input onblur=rezipit(this.value); type=text name=zipfile value='" . $zipfile . "' title='Zipfile name goes here'><br>
  Zipfile File of Interest (can be comma separated list" . mamptest("suffix") . "): <input style='width:60%;' type=text id=ofinterest name=ofinterest value='" . str_replace("youllneverfindthis","",$ofinterest) . "' title='Zipfile file of Interest name goes here'><br><select id=mysel onchange=\" if (this.value != '') { if (document.getElementById('ofinterest').value != '') { document.getElementById('ofinterest').value+=','; } document.getElementById('ofinterest').value+=this.value; } \"><option value=''>Optionally please add to list above selecting below ...</option></select><br>
  <br><br><input style='background-color:yellow;' type=submit name=asgallery value='Display Media Gallery from Media Files within Zipfile'> <input onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&asgallery=y'; \" style='background-color:yellow;' type=button value='Media Gallery of all Media in Zipfile List'> <input onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "'; \" style='background-color:yellow;' type=button value='This Zipfile List'> <input style='background-color:yellow;' type=submit value='Other Zipfile Run'> <input style='background-color:yellow;' name=synchronize type=submit value='Synchronize'> " . mamptest("") . "
  </form><br><table style='width:100%;'><tbody><tr><td style='width:5%;'><iframe id='ishowprev' style='display:none;' src='./ziptest.php'></iframe></td><td style='width:90%;'><iframe id='ishow' style='display:none;' src='./ziptest.php'></iframe></td><td style='width:5%;'><iframe id='ishownext' style='display:none;' src='./ziptest.php'></iframe></td></td></tbody></table>";
} else if ($zipfile != "") {
$formstuff="<br><form id=myform style='padding:5px 5px 5px 5px;border:3px solid red;background-color:pink;' action='./ziptest.php' method=GET>
  Zipfile Name: <input onblur=rezipit(this.value); type=text name=zipfile value='" . $zipfile . "' title='Zipfile name goes here'><br>
  Zipfile File of Interest (can be comma separated list" . mamptest("suffix") . "): <input style='width:60%;' type=text id=ofinterest name=ofinterest value='" . str_replace("youllneverfindthis","",$ofinterest) . "' title='Zipfile file of Interest name goes here'><br><select id=mysel onchange=\" if (this.value != '') { if (document.getElementById('ofinterest').value != '') { document.getElementById('ofinterest').value+=','; } document.getElementById('ofinterest').value+=this.value; } \"><option value=''>Optionally please add to list above selecting below ...</option></select><br>
  <br><br><input style='background-color:yellow;' type=submit name=asgallery value='Display Media Gallery from Media Files within Zipfile'> <input onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&asgallery=y'; \" style='background-color:yellow;' type=button value='Media Gallery of all Media in Zipfile List'> <input onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "'; \" style='background-color:yellow;' type=button value='This Zipfile List'> <input style='background-color:yellow;' type=submit value='Other Zipfile Run'> <input style='background-color:yellow;' name=synchronize type=submit value='Synchronize'> " . mamptest("") . "
  </form><br><table style='width:100%;'><tbody><tr><td style='width:5%;'><iframe id='ishowprev' style='display:none;' src='./ziptest.php'></iframe></td><td style='width:90%;'><iframe id='ishow' style='display:none;' src='./ziptest.php'></iframe></td><td style='width:5%;'><iframe id='ishownext' style='display:none;' src='./ziptest.php'></iframe></td></td></tbody></table>";
} else {
$formstuff="<br><form id=myform style='padding:5px 5px 5px 5px;border:3px solid red;background-color:pink;' action='./ziptest.php' method=GET>
  Zipfile Name: <input onblur=rezipit(this.value); type=text name=zipfile value='" . $zipfile . "' title='Zipfile name goes here'><br>
  Zipfile File of Interest (can be comma separated list" . mamptest("suffix") . "): <input style='width:60%;' type=text id=ofinterest name=ofinterest value='" . str_replace("youllneverfindthis","",$ofinterest) . "' title='Zipfile file of Interest name goes here'><br><select id=mysel onchange=\" if (this.value != '') { if (document.getElementById('ofinterest').value != '') { document.getElementById('ofinterest').value+=','; } document.getElementById('ofinterest').value+=this.value; } \"><option value=''>Optionally please add to list above selecting below ...</option></select><br>
  <br><br><input style='background-color:yellow;' type=submit name=asgallery value='Display Media Gallery from Media Files within Zipfile'> <input style='background-color:yellow;' type=submit value='Other Zipfile Run'> <input style='background-color:yellow;' name=synchronize type=submit value='Synchronize'> " . mamptest("") . "
  </form><br><table style='width:100%;'><tbody><tr><td style='width:5%;'><iframe id='ishowprev' style='display:none;' src='./ziptest.php'></iframe></td><td style='width:90%;'><iframe id='ishow' style='display:none;' src='./ziptest.php'></iframe></td><td style='width:5%;'><iframe id='ishownext' style='display:none;' src='./ziptest.php'></iframe></td></tbody></table>";
}
$tabledata="";
if ($mampurl != "") {
  $tabledata="<!doctype html><html><head><title>MAMP Functionality</title></head><body><iframe style='width:100%;height:500px;' id='mymamp' src='" . $mampurl . "' title='MAMP PHP'></iframe><br></body></html>";
}
$reportdata="";
if ($zipfile != "") {
$zip = zip_open($zipfile);

if ($zip)
  {
  while ($zip_entry = zip_read($zip)) {
    $ourfilename=zip_entry_name($zip_entry);
    if (strpos($ourfilename, "__MACOSX/") === false) {
    $formstuff=str_replace("</select>", "<option value='" . $ourfilename . "'>" . $ourfilename . "</option></select>", $formstuff);
    $ourext=explode(".",$ourfilename)[-1 + sizeof(explode(".",$ourfilename))];
    if (strtolower($ourext) == "php") {
      $mampa="&nbsp;<span><a target=_blank title='MAMP local Apache/PHP/MySql web server' href='https://mamp.info'>MAMP</a> can help run PHP</span>";
      $jsc=str_replace('jmampa=""','jmampa="' . $mampa . '"',$jsc);
    }
    $ourmimetype="";
    for ($i=0; $i<sizeof($exts); $i++) {
      if (strtolower("." . $ourext) == strtolower($exts[$i])) $ourmimetype=$types[$i];
    }
    if ($mampurl != "") {
      $mampurl=$mampurl;
    } else if (isset($_GET['synchronize']) && (strpos($ourmimetype, "video/") !== false || strpos($ourmimetype, "audio/") !== false)) {
      if (strpos("," . $ofinterest . ",","," . $ourfilename . ",") !== false) {
        if (strpos($ourmimetype, "video/") !== false) {
          if ($vsynclist == "") {
            $vsynclist=$ourfilename;
          } else {
            $vsynclist.="," . $ourfilename;
          }
        } else if (strpos($ourmimetype, "audio/") !== false) {
          if ($asynclist == "") {
            $asynclist=$ourfilename;
          } else {
            $asynclist.="," . $ourfilename;
          }
        }
      }
    } else if (isset($_GET['synchronize']) && (strpos($ourmimetype, "image/") !== false)) {
      if (strpos("," . $ofinterest . ",","," . $ourfilename . ",") !== false) {
        $cont=zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
        $burl=" style='background:url(\"data:" . $ourmimetype . ";base64," . base64_encode($cont) . "\");'";
      }
    } else if (!isset($_GET['synchronize'])) {
    if (($asgallery == "" || 1 == 1) && (strpos($ourmimetype, "image/") !== false || strpos($ourmimetype, "video/") !== false || strpos($ourmimetype, "audio/") !== false)) {
        $totis++;
        if (urldecode($ourfilename) == urldecode($_GET['ofinterest'])) {
          $thisis=$totis;
        }
        if ($firstone == "") {
          $firstone=$ourfilename;
        } else if ($secondone == "") {
          $secondone=$ourfilename;
        }
        if ($lastone != "") $secondlastone=$lastone;
        $lastone=$ourfilename;
    }

    if ($asgallery == "" && (strpos($ourmimetype, "image/") !== false || strpos($ourmimetype, "video/") !== false || strpos($ourmimetype, "audio/") !== false)) {
      if (isset($_GET['ofprevinterest'])) {   // new if
        if (urldecode($ourfilename) == urldecode($_GET['ofprevinterest'])) {
          $prevtoprevone=" " . $prevtoprevone . " ";
          $nexttoprevone="";
        } else if (trim($prevtoprevone) == $prevtoprevone && $nexttoprevone == "") {
          $prevtoprevone=$ourfilename;
        } else if ($nexttoprevone == "") {
          $nexttoprevone=$ourfilename;
          $prevtoprevone=trim($prevtoprevone);
        }
      }
    }

    if ($asgallery == "" && (strpos($ourmimetype, "image/") !== false || strpos($ourmimetype, "video/") !== false || strpos($ourmimetype, "audio/") !== false)) {
      if (isset($_GET['ofnextinterest'])) {   // new if
        if (urldecode($ourfilename) == urldecode($_GET['ofnextinterest'])) {
          $prevtonextone=" " . $prevtonextone . " ";
          $nexttonextone="";
        } else if (trim($prevtonextone) == $prevtonextone && $nexttonextone == "") {
          $prevtonextone=$ourfilename;
        } else if ($nexttonextone == "") {
          $nexttonextone=$ourfilename;
          $prevtonextone=trim($prevtonextone);
        }
      }
    }


    if ($asgallery == "" && (strpos($ourmimetype, "image/") !== false || strpos($ourmimetype, "video/") !== false || strpos($ourmimetype, "audio/") !== false)) {
      if (isset($_GET['ofprevinterest']) || isset($_GET['ofnextinterest'])) {   // new if
        if (urldecode($ofinterest) == urldecode($ourfilename)) {
          $prevone=" " . $ourfilename . " ";
          $nextone="";
        } else if (trim($prevone) == $prevone && $nextone == "") {
          $prevone=$ourfilename;
        } else if ($nextone == "") {
          $nextone=$ourfilename;
          $prevone=trim($prevone);
        }
      }
    }
    if ($asgallery != "" && (strpos($ourmimetype, "image/") !== false || strpos($ourmimetype, "video/") !== false || strpos($ourmimetype, "audio/") !== false)) {
        if (firstone == "") {
          $firstone=$ourfilename;
        } else if ($secondone == "") {
          $secondone=$ourfilename;
        }
      $lastone=$ourfilename;
      $isok=true;
      if ($ofinterest != "youllneverfindthis" && strpos("," . $ofinterest . ",","," . $ourfilename . ",") === false) $isok=false;
      if ($isok) {
      if ($tabledata == "") {
        $tabledata="<!doctype html><html><head><title>Media Gallery extracted from " . $zipfile . "</title></head><body><table border=5><THEAD><TR><td></td></TR></THEAD><tbody><tr><td style='width:15%;background-color:rgba(127,127,127,0.2);'><a id='janim' style='cursor:pointer;text-decoration:underline;display:block;' title='Animate a slideshow' onclick=' htok=true; nounderline(); setTimeout(animqnextone,3000);  '>&#127916;<sup id=jsup></sup></a><sub id=jsub></sub></a></td></tr></tbody></table></body></html>";
      }
    if ($gnumis == 0) {
        $gtotis++;
    $gnumis++;  // &#127916;
    $greportdata="<a onclick=\" htok=false; window.open('" . "./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $ourfilename . $itable . "','_blank');\" id='g" . $gnumis . "' style='cursor:pointer;text-decoration:underline;' title='Click to display in new window'>&#127916;</a>";
    $gofprevinterest="&ofprevinterest=" . $ourfilename;
    } else {
        $gtotis++;
        
    $tabledata=str_replace($itable . "','_blank');\" id='g" . $gnumis . "'","&ofnextinterest=" . $ourfilename . $itable . "','_blank');\" id='g" . $gnumis . "'",$tabledata);
    $gnumis++;
    $greportdata="<a onclick=\" htok=false; window.open('" . "./ziptest.php?zipfile=" . $zipfile . $gofprevinterest . "&ofinterest=" . $ourfilename . $itable . "','_blank');\" id='g" . $gnumis . "' style='cursor:pointer;text-decoration:underline;' title='Click to display in new window'>&#127916;</a>";
    $gofprevinterest="&ofprevinterest=" . $ourfilename;
    }
      $tabledata=str_replace("</TR>", "<th><a style=\"cursor:pointer;text-decoration:none;\" onclick=\" htok=false; document.getElementById('jsup').innerHTML='&nbsp;" . $gtotis . "'; setTimeout(animqprevone,1000); \" href=#g" . $gtotis . " title='Bit to left'>&#11013;</a>&nbsp;&nbsp;<a style=\"cursor:pointer;text-decoration:none;\" onclick=\" htok=false; document.getElementById('jsup').innerHTML='&nbsp;" . $gtotis . "'; setTimeout(animqnextone,1000); \" href=#g" . $gtotis . " title='Bit to right'>&#10145;</a>&nbsp;&nbsp;<a onclick=\" htok=false; window.open('" . "./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $ourfilename . $itable . "','_blank');\" style='cursor:pointer;text-decoration:underline;' title='Click for this in new window'>" . $ourfilename . "</a>&nbsp;" . $greportdata . "&nbsp;&nbsp;<a style=\"cursor:pointer;text-decoration:none;\" onclick=\" htok=false;  document.getElementById('jsup').innerHTML='&nbsp;1'; \" href='#janim' title='Back to left'>&#11013;&#11013;</a>&nbsp;&nbsp;<a style=\"cursor:pointer;text-decoration:none;\" onclick=\" htok=false; document.getElementById('jsup').innerHTML='&nbsp;" . $gtotis . "'; setTimeout(animqprevone,1000); \" href=#g" . $gtotis . " title='Bit to left'>&#11013;</a>&nbsp;&nbsp;<a style=\"cursor:pointer;text-decoration:none;\" onclick=\" htok=false; document.getElementById('jsup').innerHTML='&nbsp;" . $gtotis . "'; setTimeout(animqnextone,1000); \" href=#g" . $gtotis . " title='Bit to right'>&#10145;</a>&nbsp;&nbsp;<a style=\"cursor:pointer;text-decoration:none;\" href=#g0 title='Back to right'>&#10145;&#10145;</a></th></TR>", $tabledata);
      $tabledata=str_replace("</tr>", "<td><iframe src='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $ourfilename . $itable . "'></iframe></td></tr>", $tabledata);
      }
    }
    if ($asgallery == "" && strpos("," . $ofinterest . ",","," . $ourfilename . ",") !== false) {
    if (!isset($_GET['ofprevinterest']) && !isset($_GET['ofnextinterest'])) {   // new if
    if (zip_entry_open($zip, $zip_entry)) {
      // some code
      $cont=zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
      zip_close($zip);
      if (!isset($_GET['raw']) && strpos($ourmimetype, "video/") !== false) {
      echo "<!doctype html><html><body><video id='myvideo' style='display:inline-block;width:100%;height:600px;' onloadeddata=\"  if (parent.document.getElementById('videoflag')) { parent.document.getElementById('videoflag').value+='y';  } else if (document.getElementById('videoflag')) {  document.getElementById('videoflag').value+='y';  } \" onerror=\" if (parent.document.getElementById('rawy')) {  parent.document.getElementById('rawy').value='raw=y&'; } \" controls" . $muted . "><source type=\"" . $ourmimetype . "\" src=\"data:" . $ourmimetype . ";base64," . base64_encode($cont) . "\"></source></video></body></html>";
      exit;
      } else if (!isset($_GET['raw']) && strpos($ourmimetype, "audio/") !== false) {
      echo "<!doctype html><html><body><audio id='myaudio' style='display:inline-block;width:100%;height:600px;' onloadeddata=\"  if (parent.document.getElementById('audioflag')) { parent.document.getElementById('audioflag').value+='y';  } else if (document.getElementById('audioflag')) {  document.getElementById('audioflag').value+='y';  } \"  onerror=\" if (parent.document.getElementById('rawy')) {  parent.document.getElementById('rawy').value='raw=y&'; } \" controls" . $muted . " src=\"data:" . $ourmimetype . ";base64," . base64_encode($cont) . "\" /></body></html>";
      exit;
      } else {
      //echo $ourmimetype . ' ' . zip_entry_filesize($zip_entry);
      //exit;
      header('Content-type: ' . $ourmimetype);
      if (strpos(str_replace("text/csv","application/csv",$ourmimetype),"application/") !== false) header("Content-Disposition: attachment;Filename=" . explode("/",str_replace(substr("\\",0,1),"",$ourfilename))[-1 + sizeof(explode("/",str_replace(substr("\\",0,1),"",$ourfilename)))]);
      echo $cont;
      exit;
      }
    }
    }
    //}
    
   
     

        
    } else if ($ofinterest == "youllneverfindthis") {
    $reportdata.="<p>";
    $dtitle="Click to display in new window";
    if (strtolower($ourext) == "php") {
      $dtitle="Click to download";
    }
    if ($ourmimetype == "") {
    $reportdata.="Name: " . $ourfilename . "<br />";
    } else {
    if ($numis == 0) {
    $numis++;
    $reportdata.="Name: <a onclick=\"window.open('" . "./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $ourfilename . $itable . ",'_blank');\" id='" . $numis . "' style='cursor:pointer;text-decoration:underline;' title='" . $dtitle . "'>" . $ourfilename . "</a><br />";
    $ofprevinterest="&ofprevinterest=" . $ourfilename;
    } else {
    $reportdata=str_replace($itable . "','_blank');\" id='" . $numis . "'","&ofnextinterest=" . $ourfilename . $itable . "','_blank');\" id='" . $numis . "'",$reportdata);
    $numis++;
    $reportdata.="Name: <a onclick=\"window.open('" . "./ziptest.php?zipfile=" . $zipfile . $ofprevinterest . "&ofinterest=" . $ourfilename . $itable . "','_blank');\" id='" . $numis . "' style='cursor:pointer;text-decoration:underline;' title='" . $dtitle . "'>" . $ourfilename . "</a><br />";
    $ofprevinterest="&ofprevinterest=" . $ourfilename;
    }
    }
    $reportdata.="Original size: " . zip_entry_filesize($zip_entry);
    $reportdata.="</p>";
    }
    }
  }
  }
  zip_close($zip);
  }




    if (isset($_GET['synchronize'])) {
      if (strlen($vsynclist) > 0) $jsc=str_replace("vsynclist=[]", "vsynclist=['" . str_replace(",","','",$vsynclist) . "']", $jsc);
      if (strlen($asynclist) > 0) $jsc=str_replace("asynclist=[]", "asynclist=['" . str_replace(",","','",$asynclist) . "']", $jsc);
      if ((sizeof(explode(",",$vsynclist)) + sizeof(explode(",",$asynclist))) > 2) {
        for ($ial=2; $ial<(sizeof(explode(",",$vsynclist)) + sizeof(explode(",",$asynclist))); $ial++) {
          $syncstuff=str_replace("</div>","<iframe onload='weareready(this);' src='./ziptest.php' id='iavsynch" . (1 + $ial) . "' style='display:none;'></iframe></div>", $syncstuff);
        }
      }

      if (sizeof(explode(",",$vsynclist)) == 0) {
         //echo "here at 0 with " . $asynclist;
         //exit;
         $al=explode(",",$asynclist);
         $rawystuff.="<br><table style='width:100%;'><tbody><tr><td style='vertical-align:top;'><iframe onload=\" weareready(this); \" style=\"width:100%;height:800px;\" src='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $al[0] . $itable . " id='iavsynch1'></iframe></td><td style='vertical-align:top;'>";
         for ($ial=1; $ial<sizeof($al); $ial++) {
          $syncstuff=str_replace("ziptest.php' id='iavsynch" . (1 + $ial) . "'","ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $al[$ial] . $itable . "'", $syncstuff);
          $lasti++;
         }
         $syncstuff.="</td></tr></tbody></table>";
      } else if (sizeof(explode(",",$vsynclist)) == 1) {
         //echo "here at 1 with " . $vsynclist . " and " . $asynclist;
         //exit;
         $al=explode(",",$asynclist);
         if (sizeof($al) > 0) $muted="&muted=muted";
         $rawystuff.="<br><table style='width:100%;'><tbody><tr><td style='vertical-align:top;'><iframe onload=\" weareready(this); \" style=\"width:100%;height:800px;\" src='./ziptest.php?zipfile=" . $zipfile . $muted . "&ofinterest=" . $vsynclist . $itable . " id='iavsynch1'></iframe></td><td style='vertical-align:top;'>";
         for ($ial=0; $ial<sizeof($al); $ial++) {
          $syncstuff=str_replace("ziptest.php' id='iavsynch" . (2 + $ial) . "'","ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $al[$ial] . $itable . "'", $syncstuff);
         }
         $syncstuff.="</td></tr></tbody></table>";
      } else {
         //echo "here with " . $vsynclist . " and " . $asynclist;
         //exit;
         $lasti=0;
         $vl=explode(",",$vsynclist);
         $al=explode(",",$asynclist);
         if (sizeof($al) > 0) $muted="&muted=muted";
         $rawystuff.="<br><table style='width:100%;'><tbody><tr><td style='vertical-align:top;'><iframe onload=\" weareready(this); \" style=\"width:100%;height:800px;\" id='iavsynch1' src='./ziptest.php?zipfile=" . $zipfile . $muted . "&ofinterest=" . $vl[0] . $itable . "'></iframe></td><td style='vertical-align:top;'>";
         for ($ial=1; $ial<sizeof($vl); $ial++) {
          $syncstuff=str_replace("<div id='davsynch' style='display:none;'>","<div id='davsynch' style='display:inline-block;height:600px;'>",$syncstuff);
          if ($ial > 1) {
          $syncstuff=str_replace("ziptest.php' id='iavsynch" . (1 + $ial) . "' style='display:none;'","ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $vl[$ial] . $itable . "' style='display:inline-block;height:600px;'", $syncstuff);
          } else {
          $syncstuff=str_replace("ziptest.php' id='iavsynch" . (1 + $ial) . "'","ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $vl[$ial] . $itable . "'", $syncstuff);
          }
          $lasti=(1 + $ial);
         }
         for ($ial=0; $ial<sizeof($al); $ial++) {
          $syncstuff=str_replace("ziptest.php' id='iavsynch" . (1 + $lasti) . "'","ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $al[$ial] . $itable . "'", $syncstuff);
          $lasti++;
         }
         $syncstuff.="</td></tr></tbody></table>";
      }


    } else if ($mampurl == "" || 1 == 1) {

    if ($asgallery == "") {
      if (isset($_GET['ofnextinterest'])) {   // new if
        if ($prevtonextone != "" && $nexttonextone != "") {
          $formstuff=str_replace("display:none;'>&gt;<","display:block;' onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . urldecode($_GET['ofnextinterest']) . "&ofprevinterest=" . trim($prevtonextone) . "&ofnextinterest=" . $nexttonextone . $itable . "'; \">&gt;<",$formstuff);
        } else if ($prevtonextone != "") {
          $formstuff=str_replace("display:none;'>&gt;<","display:block;' onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . urldecode($_GET['ofnextinterest']) . "&ofprevinterest=" . trim($prevtonextone) . $itable . "'; \">&gt;<",$formstuff);
        } else if ($nexttonextone != "") {
          $formstuff=str_replace("display:none;'>&gt;<","display:block;' onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . urldecode($_GET['ofnextinterest']) . "&ofnextinterest=" . trim($nexttonextone) . $itable . "'; \">&gt;<",$formstuff);
        } else {
          $formstuff=str_replace("display:none;'>&gt;<","display:block;' onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . urldecode($_GET['ofnextinterest']) . $itable . "'; \">&gt;<",$formstuff);
        }
      }
    }


    if ($asgallery == "") {
      if (isset($_GET['ofprevinterest'])) {   // new if
        if ($prevtoprevone != "" && $nexttoprevone != "") {
          $formstuff=str_replace("display:none;'>&lt;<","display:block;' onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . urldecode($_GET['ofprevinterest']) . "&ofprevinterest=" . trim($prevtoprevone) . "&ofnextinterest=" . $nexttoprevone . $itable . "'; \">&lt;<",$formstuff);
        } else if ($prevtoprevone != "") {
          $formstuff=str_replace("display:none;'>&lt;<","display:block;' onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . urldecode($_GET['ofprevinterest']) . "&ofprevinterest=" . trim($prevtoprevone) . $itable . "'; \">&lt;<",$formstuff);
        } else if ($nexttoprevone != "") {
          $formstuff=str_replace("display:none;'>&lt;<","display:block;' onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . urldecode($_GET['ofprevinterest']) . "&ofnextinterest=" . trim($nexttoprevone) . $itable . "'; \">&lt;<",$formstuff);
        } else {
          $formstuff=str_replace("display:none;'>&lt;<","display:block;' onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . urldecode($_GET['ofprevinterest']) . $itable . "'; \">&lt;<",$formstuff);
        }
      }
    }
    
    if ($asgallery == "") {
        if ($firstone != "" && $secondone != "") {
          $formstuff=str_replace("display:none;'>&lt;&lt;<","display:block;' onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $firstone . "&ofnextinterest=" . $secondone . $itable . "'; \">&lt;&lt;<",$formstuff);
        } else if ($firstone != "") {
          $formstuff=str_replace("display:none;'>&lt;&lt;<","display:block;' onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $firstone . $itable . "'; \">&lt;&lt;<",$formstuff);
        }
	}

    if ($asgallery == "") {
        if ($lastone != "" && $secondlastone != "") {
          $formstuff=str_replace("display:none;'>&gt;&gt;<","display:block;' onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $lastone . "&ofprevinterest=" . $secondlastone . $itable . "'; \">&gt;&gt;<",$formstuff);
        } else if ($lastone != "") {
          $formstuff=str_replace("display:none;'>&gt;&gt;<","display:block;' onclick=\" window.location='./ziptest.php?zipfile=" . $zipfile . "&ofinterest=" . $lastone . $itable . "'; \">&gt;&gt;<",$formstuff);
        }
	}

    if ($asgallery == "" || 1 == 1) {
        if ($totis != 0) {
          $formstuff=str_replace("></sub>",">&nbsp;" . $totis . "</sub>",$formstuff);
        }
        if ($thisis != 0) {
          $formstuff=str_replace("></sup>",">&nbsp;" . $thisis . "</sup>",$formstuff);
        }
    }
    
    $formstuff=str_replace("&lt;","&#11013;",$formstuff);
    $formstuff=str_replace("&gt;","&#10145;",$formstuff);
    $formstuff=str_replace(">^<",">&#11014;<",$formstuff);
    $formstuff=str_replace(">v<",">&#11015;<",$formstuff);
    
    if ($asgallery == "" || 1 == 1) { // && $mampurl == "") {
        if ($gtotis != 0) {
          $tabledata=str_replace("></sub>",">&nbsp;" . $gtotis . "</sub>",$tabledata);
          $tabledata=str_replace("#g0","#g" . $gtotis . " onclick=\" htok=false; document.getElementById('jsup').innerHTML='&nbsp;" . $gtotis . "; \" ",$tabledata);
        }
        if ($gthisis != 0) {
          $tabledata=str_replace("></sup>",">&nbsp;" . $gthisis . "</sup>",$tabledata);
        }
    }
    }
  }    
    
  if ($tabledata != "") {
    echo str_replace("</body>", "<!doctype html><html><head><title>Zipfile Information - RJM Programming - September, 2017</title><scr" . "ipt type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></scr" . "ipt>" . $jsc . "</head><body" . $burl .">" . "<h1 id=myh1>Zipfile Information</h1><h3>RJM Programming - September, 2017</h3>" . $formstuff . "" . $rawystuff . $syncstuff . "</body>", $tabledata);
  } else if ($reportdata != "") {
    echo "<!doctype html><html><head><title>Files extracted from " . $zipfile . "</title><scr" . "ipt type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></scr" . "ipt>" . $jsc . "</head><body" . $burl ."><h1 id=myh1>Zipfile Information</h1><h3>RJM Programming - September, 2017</h3><table border=20><tbody><tr><td style='vertical-align:top;'>" . $formstuff . "</td><td style='vertical-align:top;background-color:cyan;'>" . $reportdata . "</td></tr></tbody></table>" . $rawystuff . $syncstuff . "</body></html>";
  } else {
    echo "<!doctype html><html><head><title>Zipfile Information - RJM Programming - September, 2017</title><scr" . "ipt type='text/javascript' src='//ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js'></scr" . "ipt>" . $jsc . "</head><body" . $burl .">" . "<h1 id=myh1>Zipfile Information</h1><h3>RJM Programming - September, 2017</h3>" . $formstuff . "" . $rawystuff . $syncstuff . "</body></html>";
  }
?> 
