<?php
  // slideshow_via_invisibility_and_fade.php
  // RJM Programming
  // August, 2015
  // Try to extract image data from RJM Programming WordPress TwentyTen theme blog postings, on the way to creating above the fold blog posting slideshow synopses
  // Four scenarios
  //   1) <a ...></a> tag href to an internal slideshow HTML file
  //   2) Twirling Javascript onmouseover scenario ... use eval([PHPequivalentOfJavascript]) to derive next image name (until, and excluding when, we get back to first image name)
  //   3) Single image scenario ... and ...
  //   4) Image place specified that has <td> ... </td> encasing <img ... /> and any relevant displayable text (comment) wording
  
  // WordPress TwentyTen theme class name (of interest, regarding where to extract image data)
  $wp_twentyten_classname_of_interest="wp-caption";
  // WordPress TwentyTen theme element type (of interest, regarding where to extract image data)
  $wp_twentyten_elementtype_of_interest="div";
  
  $prea="";
  $posta="";
  $tf="270";
  $andthencontent="";
  $wordingurl="http://www.rjmprogramming.com.au/ITblog/developing-black-and-white-photos-primer-tutorial/";  // default 4) scenario
  if (isset($_GET['wordingurl'])) $wordingurl=urldecode($_GET['wordingurl']);
  if (isset($_POST['wordingurl'])) $wordingurl=urldecode($_POST['wordingurl']);
  if (strlen($wordingurl) > 0 && strpos($wordingurl, "rjmprogramming.com.au/") === false) {
    $wordingurl = "http://www.rjmprogramming.com.au/ITblog/" . $wordingurl;
  }
  $wordcontent="";
  if ($wordingurl != "") $wordcontent=file_get_contents($wordingurl);
  $place="/Photography";  // default 4) image place defined
  if (isset($_GET['place'])) $place=urldecode($_GET['place']);
  if (isset($_POST['place'])) $place=urldecode($_POST['place']);
  if (strlen($place) > 0 && strpos("*" . $place . " ", "*/") === false) $place = "/" . $place;
  if ($place != "") $prea="<a target=_blank href='http://www.rjmprogramming.com.au" . $place . "'>";
  if ($place != "") $posta="</a>";
  $incrx="2750";
  if (isset($_GET['slideperiod'])) $incrx=$_GET['slideperiod'];
  if (isset($_POST['slideperiod'])) $incrx=$_POST['slideperiod'];
  $faderx="150";
  if (isset($_GET['fadercycle'])) $faderx=$_GET['fadercycle'];
  if (isset($_POST['fadercycle'])) $faderx=$_POST['fadercycle'];
  $istyle=" style='opacity:1.0;' ";
  $cwidth="";
  $cheight="";
  if (isset($_GET['width'])) $cwidth=$_GET['width']; // . "px";
  if (isset($_POST['width'])) $cwidth=$_POST['width']; // . "px";
  if (isset($_GET['height'])) $cheight=$_GET['height']; // . "px";
  if (isset($_POST['width'])) $cheight=$_POST['height']; // . "px";
  if (isset($_GET['width'])) $istyle=str_replace("width:px;", "", str_replace(";'", ";width:" . $_GET['width'] . "px;'", $istyle));
  if (isset($_POST['width'])) $istyle=str_replace("width:px;", "", str_replace(";'", ";width:" . $_POST['width'] . "px;'", $istyle));
  if (isset($_GET['height'])) $istyle=str_replace("height:px;", "", str_replace(";'", ";height:" . $_GET['height'] . "px;'", $istyle));
  if (isset($_POST['width'])) $istyle=str_replace("height:px;", "", str_replace(";'", ";height:" . $_POST['height'] . "px;'", $istyle));
  
  function wording($inimg) {
    global $wordingurl, $wordcontent, $place, $andthencontent, $prea, $posta;
        
    // The hard-coded (first) case of http://www.rjmprogramming.com.au/ITblog/developing-black-and-white-photos-primer-tutorial/ and photos of http://www.rjmprogramming.com.au/Photography/
    //if (strlen($place) > 0 && strpos(str_replace("\n","",str_replace(" ","",$wordcontent)), "<td><img ") !== false && strpos($wordcontent, "></td>") === false) {
    if (strlen($place) > 0 && strpos($wordcontent, "<img ") !== false && strpos($wordcontent, "</td>") !== false && strpos($wordcontent, "<td>") !== false) { 
     $cells=explode("<td>", $wordcontent);
     if (sizeof($cells) > 1) {
      for ($ij=0; $ij<sizeof($cells); $ij++) {
       $cellih=explode("</td>", $cells[$ij]);
       $cellnoti=explode(">", $cellih[0]);
       if (strpos($cellih[0], $inimg) !== false && sizeof($cellnoti) > 1) {
           return $cellnoti[sizeof($cellnoti) - 1];
       }
      }
     }
    } else if (strpos($andthencontent, "<img ") !== false) {  // inhouse slideshow arrangement
    
    } else {
//<div style="width: 230px" class="wp-caption alignnone">
//<a href="http://www.rjmprogramming.com.au/Mac/Xcode/iOS8/UIWebView/LearningProgramming/LearningProgramming_iOS.jpeg" target="_blank">
//<img onmouseover=" this.src=this.src.replace('.jpg','.JPEG').replace('.jpeg','.GIF').replace('.png','.jpg').replace('.gif','.png').replace('.JPEG','.jpeg').replace('.GIF','.gif');   " id="oijximpept" title="Xcode Learning Programming Primer Tutorial" src="http://www.rjmprogramming.com.au/Mac/Xcode/iOS8/UIWebView/LearningProgramming/LearningProgramming_iOS.png" alt="Xcode Learning Programming Primer Tutorial" style="float: left; border: 15px solid pink; margin-left: -20px;" itemprop="image">
//</a>
//<p class="wp-caption-text">Xcode Learning Programming Primer Tutorial</p>
//</div>
     $dstuff=explode($wp_twentyten_classname_of_interest, $wordcontent);
     if (sizeof($dstuff) >= 2) {
       $dih=explode("</" . $wp_twentyten_elementtype_of_interest . ">", $dstuff[1]);
       if (sizeof($dih) >= 2) { // this is the usual pattern for RJM Programming blog posts
        $hrefdihtwo=explode("href=", $dih[1]);
        if (sizeof($hrefdihtwo) >= 2) {
         $delimis=substr($hrefdihtwo[1],0,1);
         $hrefdht=explode($delimis, substr($hrefdihtwo[1],1));
         $prea="<a target=_blank href='" . $hrefdht[0] . "'>";
         $posta="</a>";
         if ($andthencontent == "") $andthencontent=file_get_contents($hrefdht[0]);
         if (strpos($andthencontent, "<img ") !== false) {   // inhouse slideshow arrangement
         }
        }
        $dihtwo=explode("title=", $dih[1]);
        if (sizeof($dihtwo) >= 2) {
         $delimis=substr($dihtwo[1],0,1);
         $dht=explode($delimis, substr($dihtwo[1],1));
         return $dht[0];
        }
       }
     }
    }
    return "";
  }
  
  function dojs($numimages, $ix, $fx, $wd, $ht) {
    $scris= " var iask=1;\n var iok=1;\n var iw='" . $wd . "';\n var ih='" . $ht . "';\n var lastslide=1;\n var lastix=" . $ix . ";\n var lastfx=" . $fx . ";\n var ix=" . $ix . ";\n var fx=" . $fx . ";\n var numimages=" . $numimages . "\n var way=1.0;\n var ncurid=0;\n var curopacity=1.0;\n function incr() { ncurid=eval((ncurid + 1) % numimages);\n if (lastix != ix) { document.getElementById('nslideperiod').value=ix; document.getElementById('slidesecs').title=ix; document.getElementById('slidesecs').value=ix; document.title=document.title.replace('Slide Period: ' + lastix, 'Slide Period: ' + ix); lastix=ix; } \n  if (lastfx != fx) { document.getElementById('nfadercycle').value=fx; document.getElementById('fadercycle').title=fx; document.getElementById('fadercycle').value=fx;  document.title=document.title.replace('Fader Cycle: ' + lastfx, 'Fader Cycle: ' + fx); lastfx=fx; } \n document.title=document.title.replace('Slideshow Slide ' + lastslide, 'Slideshow Slide ' + ncurid);\n lastslide=ncurid;  var was=document.getElementById('sos').innerHTML.replace('Start of slideshow ...',''); if (ncurid == 1) { document.getElementById('sos').innerHTML = 'Start of slideshow ...' + was;  } else if (was != document.getElementById('sos').innerHTML) { document.getElementById('sos').innerHTML=was; }  \n for (var ii=0; ii<numimages; ii++) { if (ii == ncurid) { if (iw != '') { document.getElementById('i' + ii).style.width=iw + 'px'; } if (ih != '') { document.getElementById('i' + ii).style.width=ih + 'px';   } document.getElementById('i' + ii).style.display='inline';  document.getElementById('wording').innerHTML=document.getElementById('i' + ii).title; } else { document.getElementById('i' + ii).style.display='none';   } }  if (iok == 1) { setTimeout(incr, ix); }   }\n function fader() { if (lastix != ix || lastfx != fx) { iok=0; incr(); iok=1; } curopacity=curopacity - (0.05 * way); if (curopacity <= 0.0 || curopacity >= 1.0) { way = -way; } document.getElementById('i' + ncurid).style.opacity=curopacity;  setTimeout(fader, fx);   } ";  
    $scris.=" \n function mclick(evt) { var mois=null; var minis=0; var maxis=0; if (evt.target.id) { mois=document.getElementById(evt.target.id); minis=mois.min; maxis=mois.max; } else if (evt.id) {  mois=document.getElementById(evt.target.id);  minis=mois.min; maxis=mois.max; } if (mois != null) { if (evt.clientY) { if (mois.id == 'slidesecs') { ix=verify(eval(Math.floor(((evt.clientY - 20) / 200.0) * (maxis - minis)) + minis));  document.getElementById('nslideperiod').value=ix; this.value=ix;  } else {  fx=verify(eval(Math.floor(((evt.clientY - 20) / 200.0) * (maxis - minis)) + minis));  document.getElementById('nfadercycle').value=fx;  this.value=fx;  }  } else if (evt.pageY) {  if (mois.id == 'slidesecs') {  ix=eval(Math.floor(((evt.pageY - 20) / 200.0) * (maxis - minis)) + minis); document.getElementById('nslideperiod').value=ix; this.value=ix;  } else {  fx=eval(Math.floor(((evt.pageY - 20) / 200.0) * (maxis - minis)) + minis); document.getElementById('nfadercycle').value=fx;  this.value=fx;  }  } } } ";
    $scris.=" \n function verify(inidea) { if (iask != 0) { var valis=prompt('If you are not happy with Calculated value, please change it as required.  Cancel stops asking, like this.',inidea); if (valis != null) { return valis; } else { iask=0; } } return inidea; } ";
    $scris.=" \n function fixifld(sval) { if (sval.indexOf('rjmprogramming.com.au') != -1) { document.getElementById('wordingurl').value=isd(sval.replace('http://www.rjmprogramming.com.au/ITblog/','').replace('http://www.rjmprogramming.com.au/wordpress','../wordpress'));   } } ";
    $scris.=" \n function isd(xval) { if (xval != 'developing-black-and-white-photos-primer-tutorial/' && document.getElementById('nplace').value == 'Photography') { document.getElementById('nplace').value='';  } return xval; } ";
    return $scris;
  } 
  
  function formstuff($wu, $plc,  $ix, $fx, $wd, $ht) {
    global $tf;
    if (strlen($plc) > 0 && strpos("*" . $plc . " ", "*/") !== false) $plc = substr($plc, 1);
    $wu=str_replace("http://www.rjmprogramming.com.au/ITblog/", "", str_replace("http://www.rjmprogramming.com.au/wordpress", "../wordpress", $wu)); 
    $mytuts=file_get_contents("http://www.rjmprogramming.com.au/Welcome.html");
    $myts=explode("mytuts", $mytuts);
    $optbits="";
    if (sizeof($myts) == 2) {
     $mytwo=explode("</select>", $myts[1]);
     $myts=explode(">", $mytwo[0]);
     $optbits=str_replace('selected="selected"', '', str_replace("selected='selected'", "", str_replace($myts[0] . ">", "", $mytwo[0])));
    }
    $fidea="
      <form style='position:absolute; top:" . $tf . "px; background-color: #fcfcfc; opacity: 0.3; z-index: 2;' action='./slideshow_via_invisibility_and_fade.php' method='GET'>
      <select id='rjmsel' onchange='fixifld(this.value);' style='background-color:lightgreen;'><option value=''>Blog Post</option>" . $optbits . "</select> <font size=1>http://www.rjmprogramming.com.au/ITblog/</font><input onblur='isd(this.value);' style='width:95%;background-color:lightblue;' type='text' id='wordingurl' name='wordingurl' value='" . $wu . "' /><br> 
      Images <font size=1>//www.rjmprogramming.com.au/</font><input style='width:95%;background-color:lightblue;' type='text' id='nplace' name='place' value='" . $plc . "' /><br> 
      Width <input style='width:20%;background-color:lightblue;' type='number' name='width' value='" . $wd . "' /><br> 
      Height <input style='width:20%;background-color:lightblue;' type='number' name='height' value='" . $ht . "' /><br>
      <input type='hidden' id='nslideperiod' name='slideperiod' value='" . $ix . "' /><input type='hidden' id='nfadercycle' name='fadercycle' value='" . $fx . "' />
      <input type='submit' value='Slideshow' style='background-color:orange;' />&nbsp;<input type='button' value='Blog Post' style='background-color:green;' onclick='window.open(\"http://www.rjmprogramming.com.au/ITblog/\" + document.getElementById(\"wordingurl\").value, \"_blank\");' /></form><br><br>
    ";
    return $fidea;
  }
  
  $inline = "inline";
  $bits=explode("/", getcwd());
  
  $diris=str_replace("/" . $bits[(sizeof($bits) - 1)], $place, getcwd()) . "/";
  
  $meterstr = "<div style=' position:absolute; top: 70px; -webkit-transform: rotate(90deg);  -ms-transform: rotate(90deg);  transform: rotate(90deg);'><br><br><meter onclick=' mclick(event); ' onchange=' ix=this.value; ' style=' width: 200px; ' id='slidesecs' title='" . $incrx . "' value='" . $incrx . "' min='1000' max='60000'>Slide Time in milliseconds</meter><br>Slide Time in milliseconds<br>(short) 1000 to 60000 (long)<br><meter onclick='  mclick(event); ' onchange=' fx=this.value; ' title='" . $faderx . "' style=' width: 200px; ' id='fadercycle' value='" . $faderx . "' min='50' max='360000'>Fader Cycle Period in milliseconds</meter><br>Fader Cycle Period in milliseconds<br> (lots) 50 to 3600000 (little)</div>";

  if (preg_match('/(?i)msie /',$_SERVER['HTTP_USER_AGENT'])) {
   $tf="175";
   $meterstr = "<div style=' position:absolute; top: 0px;'><br><br><input type='number' onblur=' ix=this.value; ' style=' width: 200px; ' id='slidesecs' title='" . $incrx . "' value='" . $incrx . "' min='1000' max='60000'></input><br>Slide Time in milliseconds<br>(short) 1000 to 60000 (long)<br><input type='number' onblur=' fx=this.value; ' title='" . $faderx . "' style=' width: 200px; ' id='fadercycle' value='" . $faderx . "' min='50' max='360000'></input><br>Fader Cycle Period (ms)<br> (lots) 50 to 3600000 (little)</div>";
  } else if (preg_match("/(android|avantgo|blackberry|bolt|boost|cricket|docomo|fone|hiptop|mini|mobi|palm|phone|pie|tablet|up\.browser|up\.link|webos|wos)/i", $_SERVER["HTTP_USER_AGENT"])) {
   $tf="175";
   $meterstr = "<div style=' position:absolute; top: 0px;'><br><br><input type='number' onblur=' ix=this.value; ' style=' width: 200px; ' id='slidesecs' title='" . $incrx . "' value='" . $incrx . "' min='1000' max='60000'></input><br>Slide Time in milliseconds<br>(short) 1000 to 60000 (long)<br><input type='number' onblur=' fx=this.value; ' title='" . $faderx . "' style=' width: 200px; ' id='fadercycle' value='" . $faderx . "' min='50' max='360000'></input><br>Fader Cycle Period (ms)<br> (lots) 50 to 3600000 (little)</div>";
  }

  if (strlen($place) > 0) {
   $myarray = glob($diris . "*.jp*g");  // Thanks to http://stackoverflow.com/questions/124958/glob-sort-by-date
   if (sizeof($myarray) == 0) $myarray = glob($diris . "*.JP*G");
   if (sizeof($myarray) == 0) $myarray = glob($diris . "*.gif");
   if (sizeof($myarray) == 0) $myarray = glob($diris . "*.GIF");
   if (sizeof($myarray) == 0) $myarray = glob($diris . "*.png");
   if (sizeof($myarray) == 0) $myarray = glob($diris . "*.PNG");
   if (sizeof($myarray) == 0) $myarray = glob($diris . "*.bmp");
   if (sizeof($myarray) == 0) $myarray = glob($diris . "*.BMP");
   if (sizeof($myarray) == 0) $myarray = glob($diris . "*.tif*");
   if (sizeof($myarray) == 0) $myarray = glob($diris . "*.TIF*");
   usort($myarray, create_function('$a,$b', 'return filemtime($b) - filemtime($a);'));
   echo "<!doctype html><html><head><title>" . str_replace("/", " ", $place) . " Slideshow Slide 1 Slide Period: " . $incrx . " Fader Cycle: " . $faderx . "</title><script type='text/javascript'> " . dojs(sizeof($myarray), $incrx, $faderx, $cwidth, $cheight) . " </script></head><body style='background-color: #f0f0f0;' onload=' setTimeout(incr," . $incrx . "); setTimeout(fader," . $faderx . "); '><table><tr><td>" . $prea; 
   for ($i=0; $i<sizeof($myarray); $i++) {
    $bits=explode("/", $myarray[$i]);
    echo "<img " . $istyle . " title='" . wording($bits[(sizeof($bits) - 1)])  . "' id='i" . $i . "' style='display:" . $inline . "' src='.." . $place . "/" . $bits[(sizeof($bits) - 1)] . "' title='" . $bits[(sizeof($bits) - 1)] . "' />";
    $inline = "none";
   }
  } else {
   $numi = 1;
   $fbit = "<!doctype html><html><head><title>" . str_replace("/", " ", $place) . " Slideshow Slide 1 Slide Period: " . $incrx . " Fader Cycle: " . $faderx . "</title><script type='text/javascript'> " . dojs($numi, $incrx, $faderx, $cwidth, $cheight) . " </script></head><body style='background-color: #f0f0f0;' onload=' setTimeout(incr," . $incrx . "); setTimeout(fader," . $faderx . "); '><table style='width:100%;'><tr><td style='width:75%;overflow:hidden;'>" . $prea; 
   $dstuff=explode($wp_twentyten_classname_of_interest, $wordcontent);
   if (sizeof($dstuff) >= 2) { // WordPress TwentyTen theme blog posting
       //$dih=explode("<img ", $dstuff[1]);
       $dih=explode("<a ", $dstuff[1]);
       if (sizeof($dih) >= 2) { // this is the usual pattern for RJM Programming blog posts
        //$dihtwo=explode(">", $dih[1]);
        $hrefdihtwo=explode("href=", $dih[1]);
        if (sizeof($hrefdihtwo) >= 2) {
         $delimis=substr($hrefdihtwo[1],0,1);
         $hrefdht=explode($delimis, substr($hrefdihtwo[1],1));
         $prea="<a target=_blank href='" . $hrefdht[0] . "'>";
         $posta="</a>";
         if ($andthencontent == "") $andthencontent=file_get_contents($hrefdht[0]);
         $jbits=explode("/", $hrefdht[0]);
         $pbit=$hrefdht[0];
         if (strpos($jbits[sizeof($jbits) - 1], ".") !== false) {
             if (strpos(strtolower($jbits[sizeof($jbits) - 1]), ".htm") !== false) { // || strpos(strtolower($jbits[sizeof($jbits) - 1]), ".php") !== false) {
              $pbit=str_replace("/" . $jbits[sizeof($jbits) - 1], "/", $pbit);
              if (strpos($andthencontent, "<img ") !== false) {
               if (strpos(substr($andthencontent, (strpos($andthencontent, "<img ") + 2)), "<img ") === false) $andthencontent=" ";
              }
             } else {
              $andthencontent=" ";
              $pbit=str_replace("/" . $jbits[sizeof($jbits) - 1], "/", $pbit);
             }
         }
         if (strpos($andthencontent, "<img ") !== false) {   // inhouse slideshow arrangement
           $ist=explode("<img ", $andthencontent);
           $numi=(sizeof($ist) - 1);
           $ioff = 0;
           $fbit = "";
           $ibitsare="";
           for ($i=1; $i<sizeof($ist); $i++) {
            $bits=explode("src=", $ist[$i]);
            $idelimis=substr($bits[1],0,1);
            $srcis=explode($idelimis, substr($bits[1],1));
            if (strpos($srcis[0], " ") !== false) {
              $ioff++;
              $numi--;
            } else {
              $titleisis="";
              $bits=explode("title=", $ist[$i]);
              if (sizeof($bits) >= 2) {
               $idelimis=substr($bits[1],0,1);
               $titleis=explode($idelimis, substr($bits[1],1));
               $titleisis=$titleis[0];
              }
              if (strpos("*" . strtolower($srcis[0]), "*http") !== false || strpos("*" . strtolower($srcis[0]), "*//") !== false) $pbit="";
              $ibitsare .= "<img " . $istyle . " title='" . $titleisis  . "' id='i" . ($i - 1 - $ioff) . "' style='width:95%;display:" . $inline . "' src='" . $pbit . $srcis[0] . "' />";
              $inline = "none";
            }
           }
           echo "<!doctype html><html><head><title>" . str_replace("/", " ", $place) . " Slideshow Slide 1 Slide Period: " . $incrx . " Fader Cycle: " . $faderx . "</title><script type='text/javascript'> " . dojs($numi, $incrx, $faderx, $cwidth, $cheight) . " </script></head><body style='background-color: #f0f0f0;width:100%;' onload=' setTimeout(incr," . $incrx . "); setTimeout(fader," . $faderx . "); '><table style='width:100%;'><tr><td style='width:75%;overflow:hidden;'>" . $prea; 
           echo $ibitsare;
         } else {  // single image blog posting mode
           $tsrc=explode("this.src.replace(", $dih[1]);
           $xsrc=explode("src=", $dih[1]);
           if (sizeof($tsrc) >= 2 && sizeof($xsrc) >= 2) { // this is a twirl image arrangement
               $titleisis="";
               $bits=explode("title=", $dih[1]);
               if (sizeof($bits) >= 2) {
                $idelimis=substr($bits[1],0,1);
                $titleis=explode($idelimis, substr($bits[1],1));
                $titleisis=$titleis[0];
               }
               $xtsrc=explode(");", $tsrc[1]);
               $xxtsrc=explode(").replace(", $xtsrc[0]);
               $idelimis=substr($xsrc[1],0,1);
               $srcis=explode($idelimis, substr($xsrc[1],1));
               if (strpos("*" . strtolower($srcis[0]), "*http") !== false || strpos("*" . strtolower($srcis[0]), "*//") !== false) $pbit="";
               $firstimg=$pbit . $srcis[0];
               $nextimg="";
               $theimg=$firstimg;
               $numi=1;
               $ibitsare = "<img " . $istyle . " title='" . $titleisis  . "' id='i" . ($numi - 1) . "' style='width:95%;display:" . $inline . "' src='" . $firstimg . "' />";
               $inline = "none";
               while ($nextimg != $firstimg) {
                 for ($ik=0; $ik<sizeof($xxtsrc); $ik++) {
                   eval("\$theimg=str_replace(" . str_replace('"', "'", $xxtsrc[$ik]) . ",\$theimg);");
                 }
                 if ($theimg != $firstimg) {
                  $numi++;
                  $ibitsare .= "<img " . $istyle . " title='" . $titleisis  . "' id='i" . ($numi - 1) . "' style='width:95%;display:" . $inline . "' src='" . $theimg . "' />";
                 }
                 $nextimg = $theimg;
               }
               $fbit = "";
               echo "<!doctype html><html><head><title>" . str_replace("/", " ", $place) . " Slideshow Slide 1 Slide Period: " . $incrx . " Fader Cycle: " . $faderx . "</title><script type='text/javascript'> " . dojs($numi, $incrx, $faderx, $cwidth, $cheight) . " </script></head><body style='background-color: #f0f0f0;width:100%;' onload=' setTimeout(incr," . $incrx . "); setTimeout(fader," . $faderx . "); '><table style='width:100%;'><tr><td style='width:75%;overflow:hidden;'>" . $prea; 
               echo $ibitsare;
           } else {  // bring over image and a tag
               echo $fbit;
               $fbit = "";
               $dihtwo=explode("</a>", $dih[1]);
               //echo "<img " . str_replace('style="', 'style="width:95%;', str_replace("style='", "style='width:95%;", $dihtwo[0])) . ">";
               echo "<a " . str_replace('style="', 'style="width:95%;', str_replace("style='", "style='width:95%;", str_replace("<img ", "<img id='i0' ", $dihtwo[0]))) . "</a>";
           }
         }
        }
        $inline = "none";
       }
       echo $fbit;
   }
  }
  // http://localhost:8888/slideshow_via_invisibility_and_fade.php?wordingurl=..%2Fwordpress%2F%3Fp%3D15819%26pp%3D%26pn%3D%26title%3DPHP_Lighthouses_in_Australia_Primer_Tutorial&place=&width=&height=&slideperiod=2750&fadercycle=150
  // HTML td cell alignment help from http://stackoverflow.com/questions/585945/how-to-align-content-of-a-div-to-the-bottom-with-css ... thanks
  echo $posta . "</td><td id='twording' style=' background-color: #f0f0f0; display: table-cell; vertical-align: bottom;'>" . $meterstr . "<br><br><br>" . formstuff($wordingurl, $place, $incrx, $faderx, $cwidth, $cheight) . "<div id='sos'>Start of slideshow ...</div><div id='wording' style='background-color: pink;'></div><br><br><br></td></tr></table></body></html>";
?>
