<?php
// mapper.php
// RJM Programming
// April, 2017
// Blog match functionality
$onclick=" onclick=";
$firstnine=false;

if (isset($_GET['otherpm'])) {  // recall scenario
 $firstnine=true;
 $pmval=@file_get_contents("http://www.rjmprogramming.com.au/Welcome.html");
 $bits=explode("id='tuts'", $pmval);
 if (sizeof($bits) > 1) {
   $ssomeof=someof(explode('</select>', $bits[1])[0], str_replace('+',' ',urldecode($_GET['otherpm'])));
   if (1 == 1) {
   echo '<html><body onload="if (window.parent) {  if (parent.document.getElementById(' . "'blogp'" . ')) { parent.document.getElementById(' . "'blogp'" . ').value=' . "'" . $ssomeof . "'" . ';   } }' . '"><p id=res>' . $ssomeof . '</p></body></html>';
   } else {
   $allselbits="<select" . $onclick . "'if (this.value.trim().length > 0) { if (2 == 2 || navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { location.href=this.value; } else { document.getElementById(\"myi\").src=this.value; }  } else { var huh=prompt(\"Tutorials regarding?\",\"" . urldecode($_GET['pm']) . "\");  if (huh != null) { if (huh != \"\") { if (huh.indexOf(\".\") == 0) { huh=String.fromCharCode(92) + huh; } location.href=\"http://www.rjmprogramming.com.au/itnewblog/match/\" + encodeURIComponent(huh); }  }  } ' size=1 id='tuts'" . $ssomeof . '</select><br><iframe name="myi" id="myi" style="width:100%;height:1400px;" src="//www.rjmprogramming.com.au/ITblog" title="Robert James Metcalfe Blog"></iframe>';
   echo '<!doctype html><html><head><title>Robert James Metcalfe Blog - Match Blog Title via RegExp</title></head><body>' . $allselbits . '</body></html>';
   }
 }
 exit;
} else if (isset($_POST['otherpm'])) {  // recall scenario
 $firstnine=true;
 $pmval=@file_get_contents("http://www.rjmprogramming.com.au/Welcome.html");
 $bits=explode("id='tuts'", $pmval);
 if (sizeof($bits) > 1) {  
   $ssomeof=someof(explode('</select>', $bits[1])[0], str_replace('+',' ',urldecode($_POST['otherpm'])));
   if (1 == 1) {
   echo '<html><body onload="if (window.parent) {  if (parent.document.getElementById(' . "'blogp'" . ')) { parent.document.getElementById(' . "'blogp'" . ').value=' . "'" . $ssomeof . "'" . ';   } }' . '"><p id=res>' . $ssomeof . '</p></body></html>';
   } else {
   $allselbits="<select" . $onclick . "'if (this.value.trim().length > 0) { if (2 == 2 || navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { location.href=this.value; } else {  document.getElementById(\"myi\").src=this.value; }  } else { var huh=prompt(\"Tutorials regarding?\",\"" . urldecode($_POST['pm']) . "\");  if (huh != null) { if (huh != \"\") { if (huh.indexOf(\".\") == 0) { huh=String.fromCharCode(92) + huh; } location.href=\"http://www.rjmprogramming.com.au/itnewblog/match/\" + encodeURIComponent(huh); }  }  } ' size=1 id='tuts'" . $ssomeof . '</select><br><iframe name="myi" id="myi" style="width:100%;height:1400px;" src="//www.rjmprogramming.com.au/ITblog" title="Robert James Metcalfe Blog"></iframe>';
   echo '<!doctype html><html><head><title>Robert James Metcalfe Blog - Match Blog Title via RegExp</title></head><body>' . $allselbits . '</body></html>';
   }
 } 
 exit;
}

function ourexplode($needle, $haystack) {
  $backsome=-3;
  $bckbit='';
  $forbit='';
  $isordinal=false;
  $intrm=explode($needle, $haystack)[0];
  if ($intrm != $haystack) {
    if (strlen($intrm) >= 4) {
      if (strtolower(substr($intrm,($backsome - 1),4)) == ' of ') {
       if (strtolower(substr($intrm,($backsome - 2),5)) >= '0 of ' && strtolower(substr($intrm,($backsome - 2),5)) <= '9 of ') {
       $isordinal=true;
       $bckbit=' ';
       } else {
       $forbit=substr($intrm,$backsome,3);
       $backsome-=3;
       }
      }
      if (substr($intrm,($backsome - 1),1) >= '0' && substr($intrm,($backsome - 1),1) <= '9') {
       if (substr($intrm,-1,1) == ' ') {
         switch (strtolower(substr($intrm,$backsome,2))) {
           case 'st':
           case 'nd':
           case 'rd':
           case 'th':
            $isordinal=true;
            break;
         
           default:
            break;
         }
       }
      }
    }
  }
  if ($isordinal) {
    //return str_replace($bckbit . substr($intrm,$backsome,3) . $forbit, ' ', str_replace($bckbit . substr($intrm,$backsome,3) . $forbit . $needle . ',', substr($intrm,$backsome,3) . $needle . ' ', str_replace($bckbit . substr($intrm,$backsome,3) . $forbit . $needle . ', ', substr($intrm,$backsome,3) . $needle . ' ', $haystack)));
    return str_replace($bckbit . substr($intrm,$backsome,3) . $forbit, ' ', str_replace($bckbit . substr($intrm,$backsome,3) . $forbit . $needle . ',', ' ' . $needle . ' ', str_replace($bckbit . substr($intrm,$backsome,3) . $forbit . $needle . ', ', ' ' . $needle . ' ', $haystack)));
  }
  return $haystack;
}

function someof($sbits, $viapm) {
 global $onclick, $firstnine;
 $intonine=0;
 $outof=',';
 $origviapm=$viapm;
 $orthere=false;
 $andthere=false;
 $ors=[];
 $ands=[];
 $orands=[];
 $previa='';
 $obits="";
 $befvia='';
 $obits=str_replace('></option>','></OPTION>',$sbits);
 $zobits=explode("</option>",$obits);
 if (sizeof($zobits) > 1) {
   $obits=str_replace("Tutorials (show blog, toggle sort order) ...","Tutorials about " . $viapm . " (or ask about another topic)",$zobits[0]) . "</option>";
   $andors=explode('&&',str_replace('||', '&&', $viapm));
   for ($ii=0; $ii<sizeof($andors); $ii++) {
   $previa='';
   if ($ii > 0) {
     if (strpos($origviapm, '&&' . $andors[$ii]) !== false) {
       array_push($ands, $orands[-1 + $ii]);
       $andthere=true;
     } else if (strpos($origviapm, '||' . $andors[$ii]) !== false) {
       array_push($ors, $orands[-1 + $ii]);
       $orthere=true;
     }
   }
   if (sizeof($andors) > 1) {
   $viapm=trim($andors[$ii]);
   } else {
   $viapm=$andors[$ii];
   }
   if ($viapm != "") {
     if (strpos(strtolower(' ' . $viapm . ' '), 'january') !== false) {
       $viapm=str_replace('January','01', str_replace('january','01', str_replace('JANUARY','01', $viapm)));
       $viapm=ourexplode('01', $viapm);
       if (substr($viapm,0,2) == '01') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), 'jan ') !== false || strpos(strtolower(' ' . $viapm . ' '), 'jan/') !== false || strpos(strtolower(' ' . $viapm . ' '), 'jan-') !== false || strpos(strtolower(' ' . $viapm . ' '), 'jan,') !== false) {
       $viapm=str_replace('Jan','01', str_replace('jan','01', str_replace('JAN','01', $viapm)));
       $viapm=ourexplode('01', $viapm);
       if (substr($viapm,0,2) == '01') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), 'february') !== false) {
       $viapm=str_replace('February','02', str_replace('february','02', str_replace('FEBRUARY','02', $viapm)));
       $viapm=ourexplode('02', $viapm);
       if (substr($viapm,0,2) == '02') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), 'feb ') !== false || strpos(strtolower(' ' . $viapm . ' '), 'feb/') !== false || strpos(strtolower(' ' . $viapm . ' '), 'feb-') !== false || strpos(strtolower(' ' . $viapm . ' '), 'feb,') !== false) {
       $viapm=str_replace('Feb','02', str_replace('feb','02', str_replace('FEB','02', $viapm)));
       $viapm=ourexplode('02', $viapm);
       if (substr($viapm,0,2) == '02') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), 'march') !== false) {
       $viapm=str_replace('March','03', str_replace('march','03', str_replace('MARCH','03', $viapm)));
       $viapm=ourexplode('03', $viapm);
       if (substr($viapm,0,2) == '03') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), ' mar ') !== false || strpos(strtolower(' ' . $viapm . ' '), 'mar/') !== false || strpos(strtolower(' ' . $viapm . ' '), 'mar-') !== false || strpos(strtolower(' ' . $viapm . ' '), 'mar,') !== false) {
       $viapm=str_replace('Mar','03', str_replace('mar','03', str_replace('MAR','03', $viapm)));
       $viapm=ourexplode('03', $viapm);
       if (substr($viapm,0,2) == '03') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), 'april') !== false) {
       $viapm=str_replace('April','04', str_replace('april','04', str_replace('APRIL','04', $viapm)));
       $viapm=ourexplode('04', $viapm);
       if (substr($viapm,0,2) == '04') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), ' apr ') !== false || strpos(strtolower(' ' . $viapm . ' '), 'apr/') !== false || strpos(strtolower(' ' . $viapm . ' '), 'apr-') !== false || strpos(strtolower(' ' . $viapm . ' '), 'apr,') !== false) {
       $viapm=str_replace('Apr','04', str_replace('apr','04', str_replace('APR','04', $viapm)));
       $viapm=ourexplode('04', $viapm);
       if (substr($viapm,0,2) == '04') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), 'may') !== false) {
       $viapm=str_replace('May','05', str_replace('may','05', str_replace('MAY','05', $viapm)));
       $viapm=ourexplode('05', $viapm);
       if (substr($viapm,0,2) == '05') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), ' may ') !== false || strpos(strtolower(' ' . $viapm . ' '), 'may/') !== false || strpos(strtolower(' ' . $viapm . ' '), 'may-') !== false || strpos(strtolower(' ' . $viapm . ' '), 'may,') !== false) {
       $viapm=str_replace('May','05', str_replace('may','05', str_replace('MAY','05', $viapm)));
       $viapm=ourexplode('05', $viapm);
       if (substr($viapm,0,2) == '05') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), 'june') !== false) {
       $viapm=str_replace('June','06', str_replace('june','06', str_replace('JUNE','06', $viapm)));
       $viapm=ourexplode('06', $viapm);
       if (substr($viapm,0,2) == '06') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), ' jun ') !== false || strpos(strtolower(' ' . $viapm . ' '), 'jun/') !== false || strpos(strtolower(' ' . $viapm . ' '), 'jun-') !== false || strpos(strtolower(' ' . $viapm . ' '), 'jun,') !== false) {
       $viapm=str_replace('Jun','06', str_replace('jun','06', str_replace('JUN','06', $viapm)));
       $viapm=ourexplode('06', $viapm);
       if (substr($viapm,0,2) == '06') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), 'july') !== false) {
       $viapm=str_replace('July','07', str_replace('july','07', str_replace('JULY','07', $viapm)));
       $viapm=ourexplode('07', $viapm);
       if (substr($viapm,0,2) == '07') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), ' jul ') !== false || strpos(strtolower(' ' . $viapm . ' '), 'jul/') !== false || strpos(strtolower(' ' . $viapm . ' '), 'jul-') !== false || strpos(strtolower(' ' . $viapm . ' '), 'jul,') !== false) {
       $viapm=str_replace('Jul','07', str_replace('jul','07', str_replace('JUL','07', $viapm)));
       $viapm=ourexplode('07', $viapm);
       if (substr($viapm,0,2) == '07') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), 'august') !== false) {
       $viapm=str_replace('August','08', str_replace('august','08', str_replace('AUGUST','08', $viapm)));
       $viapm=ourexplode('08', $viapm);
       if (substr($viapm,0,2) == '08') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), ' aug ') !== false || strpos(strtolower(' ' . $viapm . ' '), 'aug/') !== false || strpos(strtolower(' ' . $viapm . ' '), 'aug-') !== false || strpos(strtolower(' ' . $viapm . ' '), 'aug,') !== false) {
       $viapm=str_replace('Aug','08', str_replace('aug','08', str_replace('AUG','08', $viapm)));
       $viapm=ourexplode('08', $viapm);
       if (substr($viapm,0,2) == '08') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), 'september') !== false) {
       $viapm=str_replace('September','09', str_replace('september','09', str_replace('SEPTEMBER','09', $viapm)));
       $viapm=ourexplode('09', $viapm);
       if (substr($viapm,0,2) == '09') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), ' sep ') !== false || strpos(strtolower(' ' . $viapm . ' '), 'sep/') !== false || strpos(strtolower(' ' . $viapm . ' '), 'sep-') !== false || strpos(strtolower(' ' . $viapm . ' '), 'sep,') !== false) {
       $viapm=str_replace('Sep','09', str_replace('sep','09', str_replace('SEP','09', $viapm)));
       $viapm=ourexplode('09', $viapm);
       if (substr($viapm,0,2) == '09') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), 'october') !== false) {
       $viapm=str_replace('October','10', str_replace('october','10', str_replace('OCTOBER','10', $viapm)));
       $viapm=ourexplode('10', $viapm);
       if (substr($viapm,0,2) == '10') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), ' oct ') !== false || strpos(strtolower(' ' . $viapm . ' '), 'oct/') !== false || strpos(strtolower(' ' . $viapm . ' '), 'oct-') !== false || strpos(strtolower(' ' . $viapm . ' '), 'oct,') !== false) {
       $viapm=str_replace('Oct','10', str_replace('oct','10', str_replace('OCT','10', $viapm)));
       $viapm=ourexplode('10', $viapm);
       if (substr($viapm,0,2) == '10') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), 'november') !== false) {
       $viapm=str_replace('November','11', str_replace('november','11', str_replace('NOVEMBER','11', $viapm)));
       $viapm=ourexplode('11', $viapm);
       if (substr($viapm,0,2) == '11') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), ' nov ') !== false || strpos(strtolower(' ' . $viapm . ' '), 'nov/') !== false || strpos(strtolower(' ' . $viapm . ' '), 'nov-') !== false || strpos(strtolower(' ' . $viapm . ' '), 'nov,') !== false) {
       $viapm=str_replace('Nov','11', str_replace('nov','11', str_replace('NOV','11', $viapm)));
       $viapm=ourexplode('11', $viapm);
       if (substr($viapm,0,2) == '11') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), 'december') !== false) {
       $viapm=str_replace('December','12', str_replace('december','12', str_replace('DECEMBER','12', $viapm)));
       $viapm=ourexplode('12', $viapm);
       if (substr($viapm,0,2) == '12') {  $previa="\\(([0-9]{4})"; }
     } else if (strpos(strtolower(' ' . $viapm . ' '), ' dec ') !== false || strpos(strtolower(' ' . $viapm . ' '), 'dec/') !== false || strpos(strtolower(' ' . $viapm . ' '), 'dec-') !== false || strpos(strtolower(' ' . $viapm . ' '), 'dec,') !== false) {
       $viapm=str_replace('Dec','12', str_replace('dec','12', str_replace('DEC','12', $viapm)));
       $viapm=ourexplode('12', $viapm);
       if (substr($viapm,0,2) == '12') {  $previa="([0-9]{4})"; }
     } 
     
   if (preg_match('/([0-9]{4})/i', $viapm)) {
     if (!preg_match('/\(([0-9]{4})/i', $viapm)) {
      if (preg_match('/^([0-9]{4})/i', $viapm)) {
        $previa="\\(";
      }
     }
     if (preg_match('/([0-9]{1})\/([0-9]{2})\/([0-9]{4})/i', $viapm) || preg_match('/([0-9]{1})\/([0-9]{1})\/([0-9]{4})/i', $viapm)) {
       $dnums=explode('/', $viapm);
       $dnums[0]=explode(',', $dnums[0])[-1 + sizeof(explode(',', $dnums[0]))];
       $dnums[0]=explode(' ', $dnums[0])[-1 + sizeof(explode(' ', $dnums[0]))];
       $dnums[2]=explode(' ', $dnums[2])[0];
       $dnums[2]=explode(',', $dnums[2])[0];
       if (substr(('0' . $dnums[1]),-2,2) > '12') {
       $viapm=str_replace($dnums[0] . '/' . $dnums[1] . '/' . substr($dnums[2],0,4), substr($dnums[2],0,4) . substr(('0' . $dnums[0]),-2,2) . substr(('0' . $dnums[1]),-2,2), $viapm);
       } else {
       $viapm=str_replace($dnums[0] . '/' . $dnums[1] . '/' . substr($dnums[2],0,4), substr($dnums[2],0,4) . substr(('0' . $dnums[1]),-2,2) . substr(('0' . $dnums[0]),-2,2), $viapm);
       }
     } else if (preg_match('/([0-9]{1})\-([0-9]{2})\-([0-9]{4})/i', $viapm) || preg_match('/([0-9]{1})\-([0-9]{1})\-([0-9]{4})/i', $viapm)) {
       $dnums=explode('-', $viapm);
       $dnums[0]=explode(',', $dnums[0])[-1 + sizeof(explode(',', $dnums[0]))];
       $dnums[0]=explode(' ', $dnums[0])[-1 + sizeof(explode(' ', $dnums[0]))];
       $dnums[2]=explode(' ', $dnums[2])[0];
       $dnums[2]=explode(',', $dnums[2])[0];
       if (substr(('0' . $dnums[1]),-2,2) > '12') {
       $viapm=str_replace($dnums[0] . '-' . $dnums[1] . '-' . substr($dnums[2],0,4), substr($dnums[2],0,4) . substr(('0' . $dnums[0]),-2,2) . substr(('0' . $dnums[1]),-2,2), $viapm);
       } else {
       $viapm=str_replace($dnums[0] . '-' . $dnums[1] . '-' . substr($dnums[2],0,4), substr($dnums[2],0,4) . substr(('0' . $dnums[1]),-2,2) . substr(('0' . $dnums[0]),-2,2), $viapm);
       }
     } else if (preg_match('/([0-9]{1})\ ([0-9]{2})\ ([0-9]{4})/i', $viapm) || preg_match('/([0-9]{1})\ ([0-9]{1})\ ([0-9]{4})/i', $viapm)) {
       $thiszero=-1;
       for ($ik=0; $ik<strlen($viapm); $ik++) {
         if ($thiszero < 0) {
           if (substr(substr($viapm, $ik),0,1) >= '0' && substr(substr($viapm, $ik),0,1) <= '9') {
             $thiszero=$ik;
           }
         }
       }
       $dnums=explode(' ', substr($viapm, max($thiszero,0)));
       $dnums[0]=explode(',', $dnums[0])[-1 + sizeof(explode(',', $dnums[0]))];
       $dnums[0]=explode(' ', $dnums[0])[-1 + sizeof(explode(' ', $dnums[0]))];
       $dnums[2]=explode(' ', $dnums[2])[0];
       $dnums[2]=explode(',', $dnums[2])[0];
       if (substr(('0' . $dnums[1]),-2,2) > '12') {
       $viapm=str_replace($dnums[0] . ' ' . $dnums[1] . ' ' . substr($dnums[2],0,4), substr($dnums[2],0,4) . substr(('0' . $dnums[0]),-2,2) . substr(('0' . $dnums[1]),-2,2), $viapm);
       } else {
       $viapm=str_replace($dnums[0] . ' ' . $dnums[1] . ' ' . substr($dnums[2],0,4), substr($dnums[2],0,4) . substr(('0' . $dnums[1]),-2,2) . substr(('0' . $dnums[0]),-2,2), $viapm);
       }
     } else if (preg_match('/([0-9]{2})\/([0-9]{4})/i', $viapm) || preg_match('/([0-9]{1})\/([0-9]{4})/i', $viapm)) {
       $dnums=explode('/', $viapm);
       $dnums[0]=explode(',', $dnums[0])[-1 + sizeof(explode(',', $dnums[0]))];
       $dnums[0]=explode(' ', $dnums[0])[-1 + sizeof(explode(' ', $dnums[0]))];
       $dnums[1]=explode(' ', $dnums[1])[0];
       $dnums[1]=explode(',', $dnums[1])[0];
       $viapm=str_replace($dnums[0] . '/' . substr($dnums[1],0,4), substr($dnums[1],0,4) . substr(('0' . $dnums[0]),-2,2), $viapm);
     } else if (preg_match('/([0-9]{2})\-([0-9]{4})/i', $viapm) || preg_match('/([0-9]{1})\-([0-9]{4})/i', $viapm)) {
       $dnums=explode('-', $viapm);
       $dnums[0]=explode(',', $dnums[0])[-1 + sizeof(explode(',', $dnums[0]))];
       $dnums[0]=explode(' ', $dnums[0])[-1 + sizeof(explode(' ', $dnums[0]))];
       $dnums[1]=explode(' ', $dnums[1])[0];
       $dnums[1]=explode(',', $dnums[1])[0];
       $viapm=str_replace($dnums[0] . '-' . substr($dnums[1],0,4), substr($dnums[1],0,4) . substr(('0' . $dnums[0]),-2,2), $viapm);
     } else if (preg_match('/([0-9]{2})\ ([0-9]{4})/i', $viapm) || preg_match('/([0-9]{1})\ ([0-9]{4})/i', $viapm)) {
       $thiszero=-1;
       for ($ik=0; $ik<strlen($viapm); $ik++) {
         if ($thiszero < 0) {
           if (substr(substr($viapm, $ik),0,1) >= '0' && substr(substr($viapm, $ik),0,1) <= '9') {
             $thiszero=$ik;
           }
         }
       }
       $dnums=explode(' ', substr($viapm, max($thiszero,0)));
       $dnums[0]=explode(',', $dnums[0])[-1 + sizeof(explode(',', $dnums[0]))];
       $dnums[0]=explode(' ', $dnums[0])[-1 + sizeof(explode(' ', $dnums[0]))];
       $dnums[1]=explode(' ', $dnums[1])[0];
       $dnums[1]=explode(',', $dnums[1])[0];
       $viapm=str_replace($dnums[0] . ' ' . substr($dnums[1],0,4), substr($dnums[1],0,4) . substr(('0' . $dnums[0]),-2,2), $viapm);
     }
   } else if (preg_match('/([0-9]{1})\/([0-9]{1})/i', $viapm)) {
       $dnums=explode('/', $viapm);
       $dnums[0]=explode(',', $dnums[0])[-1 + sizeof(explode(',', $dnums[0]))];
       $dnums[0]=explode(' ', $dnums[0])[-1 + sizeof(explode(' ', $dnums[0]))];
       $dnums[1]=explode(' ', $dnums[1])[0];
       $dnums[1]=explode(',', $dnums[1])[0];
       if (substr(('0' . $dnums[0]),-2,2) > '12') {
       $viapm=str_replace($dnums[0] . '/' . $dnums[1], '([0-9]{4})' . substr(('0' . $dnums[1]),-2,2) . substr(('0' . $dnums[0]),-2,2), $viapm);
       } else {
       $viapm=str_replace($dnums[0] . '/' . $dnums[1], '([0-9]{4})' . substr(('0' . $dnums[0]),-2,2) . substr(('0' . $dnums[1]),-2,2), $viapm);
       }
   } else if (preg_match('/([0-9]{1})\-([0-9]{1})/i', $viapm)) {
       $dnums=explode('-', $viapm);
       $dnums[0]=explode(',', $dnums[0])[-1 + sizeof(explode(',', $dnums[0]))];
       $dnums[0]=explode(' ', $dnums[0])[-1 + sizeof(explode(' ', $dnums[0]))];
       $dnums[1]=explode(' ', $dnums[1])[0];
       $dnums[1]=explode(',', $dnums[1])[0];
       if (substr(('0' . $dnums[0]),-2,2) > '12') {
       $viapm=str_replace($dnums[0] . '-' . $dnums[1], '([0-9]{4})' . substr(('0' . $dnums[1]),-2,2) . substr(('0' . $dnums[0]),-2,2), $viapm);
       } else {
       $viapm=str_replace($dnums[0] . '-' . $dnums[1], '([0-9]{4})' . substr(('0' . $dnums[0]),-2,2) . substr(('0' . $dnums[1]),-2,2), $viapm);
       }
   } else if (preg_match('/([0-9]{1})\ ([0-9]{1})/i', $viapm)) {
       $thiszero=-1;
       for ($ik=0; $ik<strlen($viapm); $ik++) {
         if ($thiszero < 0) {
           if (substr(substr($viapm, $ik),0,1) >= '0' && substr(substr($viapm, $ik),0,1) <= '9') {
             $thiszero=$ik;
           }
         }
       }
       $dnums=explode(' ', substr($viapm, max($thiszero,0)));
       $dnums[0]=explode(',', $dnums[0])[-1 + sizeof(explode(',', $dnums[0]))];
       $dnums[0]=explode(' ', $dnums[0])[-1 + sizeof(explode(' ', $dnums[0]))];
       $dnums[1]=explode(' ', $dnums[1])[0];
       $dnums[1]=explode(',', $dnums[1])[0];
       if (substr(('0' . $dnums[0]),-2,2) > '12') {
       $viapm=str_replace($dnums[0] . ' ' . $dnums[1], '([0-9]{4})' . substr(('0' . $dnums[1]),-2,2) . substr(('0' . $dnums[0]),-2,2), $viapm);
       } else {
       $viapm=str_replace($dnums[0] . ' ' . $dnums[1], '([0-9]{4})' . substr(('0' . $dnums[0]),-2,2) . substr(('0' . $dnums[1]),-2,2), $viapm);
       }
   }
   array_push($orands, $previa . $viapm);
   }
   for ($j=1; $j<sizeof($zobits); $j++) {
     $title=explode(">",$zobits[$j])[-1 + sizeof(explode(">",$zobits[$j]))];
     //if (eregi($viapm, $title)) {
     $worryaboutlast=true;
     $worryless=false;
     if ($andthere) {
       for ($ijk=0; $ijk<sizeof($ands); $ijk++) {
         if (!preg_match('/' . $ands[$ijk] . '/i', $title)) {
           $worryaboutlast=false;
         }
       }
     }
     if ($orthere) {
       for ($ijk=0; $ijk<sizeof($ors); $ijk++) {
         if (preg_match('/' . $ors[$ijk] . '/i', $title)) {
           $worryless=true;
         }
       }
     }
     if (($worryless || preg_match('/' . $previa . $viapm . '/i', $title)) && $worryaboutlast) {
       $onclick=" onchange=";
       $obits.=str_replace('65.254.93.32','www.rjmprogramming.com.au',str_replace('65.254.95.247','www.rjmprogramming.com.au',"\n<option " . str_replace("_blank","myi",str_replace("windowopen","window.open",explode("<option ", $zobits[$j])[-1 + sizeof(explode("<option ", $zobits[$j]))]))) . "</option>");
       if (trim(explode('#',explode('&',explode("?p=","\n<option " . str_replace("_blank","myi",str_replace("windowopen","window.open",explode("<option ", $zobits[$j])[-1 + sizeof(explode("<option ", $zobits[$j]))])) . "</option>")[1])[0])[0]) != '') {
       if ($outof != ',') {  $outof.=','; } 
       $outof.=explode('#',explode('&',explode("?p=","\n<option " . str_replace("_blank","myi",str_replace("windowopen","window.open",explode("<option ", $zobits[$j])[-1 + sizeof(explode("<option ", $zobits[$j]))])) . "</option>")[1])[0])[0];
       }
     }
   }
   } 
 }
 if ($firstnine) {
   if (strlen($outof) <= 1) { return ''; }
   $sofarused=',';
   $outsof=explode(',', substr($outof,1));
   if (sizeof($outsof) > 9) {
     for ($jj=0; $jj<9; $jj++) {
      $ii=rand(0, (-1 + sizeof($outsof)));
      while (strpos(($sofarused . ','), ',' . $outsof[$ii] . ',') !== false) {
       $ii=rand(0, (-1 + sizeof($outsof)));
      }
      if ($sofarused != ',') {  $sofarused.=','; } 
      $sofarused.=$outsof[$ii];
     }
     return substr($sofarused,1);
   } else {
     return substr($outof,1);
   }
 }
 return $obits;
}

if (isset($_GET['pm'])) {  // recall scenario
 $pmval=@file_get_contents("http://www.rjmprogramming.com.au/Welcome.html");
 $bits=explode("id='tuts'", $pmval);
 if (sizeof($bits) > 1) {
   $ssomeof=someof(explode('</select>', $bits[1])[0], str_replace('+',' ',urldecode($_GET['pm'])));
   $allselbits="<select" . $onclick . "'if (this.value.trim().length > 0) { if (2 == 2 || navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { location.href=this.value; } else { document.getElementById(\"myi\").src=this.value; }  } else { var huh=prompt(\"Tutorials regarding?\",\"" . urldecode($_GET['pm']) . "\");  if (huh != null) { if (huh != \"\") { if (huh.indexOf(\".\") == 0) { huh=String.fromCharCode(92) + huh; } location.href=\"http://www.rjmprogramming.com.au/itnewblog/match/\" + encodeURIComponent(huh); }  }  } ' size=1 id='tuts'" . $ssomeof . '</select><br><iframe name="myi" id="myi" style="width:100%;height:1400px;" src="//www.rjmprogramming.com.au/ITblog" title="Robert James Metcalfe Blog"></iframe>';
   echo '<!doctype html><html><head><title>Robert James Metcalfe Blog - Match Blog Title via RegExp</title></head><body>' . $allselbits . '</body></html>';
 }
} else if (isset($_POST['pm'])) {  // recall scenario
 $pmval=@file_get_contents("http://www.rjmprogramming.com.au/Welcome.html");
 $bits=explode("id='tuts'", $pmval);
 if (sizeof($bits) > 1) {  
   $ssomeof=someof(explode('</select>', $bits[1])[0], str_replace('+',' ',urldecode($_POST['pm'])));
   $allselbits="<select" . $onclick . "'if (this.value.trim().length > 0) { if (2 == 2 || navigator.userAgent.match(/Android|BlackBerry|iPhone|iPad|iPod|Opera Mini|IEMobile/i)) { location.href=this.value; } else {  document.getElementById(\"myi\").src=this.value; }  } else { var huh=prompt(\"Tutorials regarding?\",\"" . urldecode($_POST['pm']) . "\");  if (huh != null) { if (huh != \"\") { if (huh.indexOf(\".\") == 0) { huh=String.fromCharCode(92) + huh; } location.href=\"http://www.rjmprogramming.com.au/itnewblog/match/\" + encodeURIComponent(huh); }  }  } ' size=1 id='tuts'" . $ssomeof . '</select><br><iframe name="myi" id="myi" style="width:100%;height:1400px;" src="//www.rjmprogramming.com.au/ITblog" title="Robert James Metcalfe Blog"></iframe>';
   echo '<!doctype html><html><head><title>Robert James Metcalfe Blog - Match Blog Title via RegExp</title></head><body>' . $allselbits . '</body></html>';
 } 
} else {  // got here via .htaccess in http://www.rjmprogramming.com.au/itnewblog/match/ web server directory
 echo "
<!doctype html>
<html>
<head>
<script type='text/javascript'>

var pmval='';

function atmatch() {
 var eqis,deqis='',deq=0,lh=[],rh=[],delim='/',pmthere=false,ttype='text readonly style=width:100%; ',bdelim='=';
 if (document.URL.indexOf('/itnewblog/match/') != -1) {
  if (decodeURIComponent(document.URL).indexOf(bdelim) == -1) bdelim='~';
  if (decodeURIComponent(document.URL).indexOf(bdelim) != -1) {
  eqis=decodeURIComponent(document.URL).replace('?#','&').replace('?','&').replace('#','&').split(bdelim); 
  if ('pm' == eqis[0].split(delim)[eval(-1 + eqis[0].split(delim).length)].replace('mapper.php?','').replace('mapper.php&','').toLowerCase()) { 
  pmthere=true;
  ttype='hidden';
  } else {
  deqis='<table border=12><tbody></tbody></table>';
  }
  //alert(eqis[eval(1 + deq)].split('&')[0] + ' vS ' + eqis[0].split(delim)[eval(-1 + eqis[0].split(delim).length)].replace('mapper.php?','').replace('mapper.php&','') + ' Vs ' + eqis.length + ' VS ' + document.URL + ' vs ' + decodeURIComponent(document.URL));
  for (deq=0; deq<eval(-1 + eqis.length); deq++) {
  if (pmthere) {
  deqis+=\"<input type=\" + ttype + \" id=\" + eqis[deq].split(delim)[eval(-1 + eqis[deq].split(delim).length)].replace('mapper.php?','').replace('mapper.php&','') + \" name=\" + eqis[deq].split(delim)[eval(-1 + eqis[deq].split(delim).length)].replace('mapper.php?','').replace('mapper.php&','') + \" value=''></input><br>\";
  } else {
  //alert(eqis[eval(1 + deq)].split('&')[0] + ' vS ' + eqis[0].split(delim)[eval(-1 + eqis[0].split(delim).length)].replace('mapper.php?','').replace('mapper.php&','') + ' Vs ' + eqis.length + ' VS ' + document.URL + ' vs ' + decodeURIComponent(document.URL));
  deqis=deqis.replace('</tbody>','<tr><td id=lh' + eqis[deq].split(delim)[eval(-1 + eqis[deq].split(delim).length)].replace('mapper.php?','').replace('mapper.php&','') + '></td><td id=rh' + eqis[deq].split(delim)[eval(-1 + eqis[deq].split(delim).length)].replace('mapper.php?','').replace('mapper.php&','') + '></td></tr></tbody>');
  }
  lh.push(eqis[deq].split(delim)[eval(-1 + eqis[deq].split(delim).length)].replace('mapper.php?','').replace('mapper.php&',''));
  rh.push(eqis[eval(1 + deq)].split('&')[0]);
  //alert(lh[deq] + '=' + rh[deq]);
  delim='&';
  }
  document.getElementById('dpm').innerHTML=deqis;
  for (deq=0; deq<eval(-1 + eqis.length); deq++) {
  if (pmthere) {
  document.getElementById(lh[deq]).value=rh[deq];
  } else if (1 == 1) {   
  document.getElementById('lh' + lh[deq]).innerHTML='<b>' + lh[deq].replace(/_/g,' ').replace(/-/g,'/') + '</b>';
  document.getElementById('rh' + lh[deq]).innerHTML=rh[deq];
  } else {
  document.getElementById(lh[deq]).value=lh[deq].replace(/_/g,' ').replace(/-/g,'/') + ': ' + rh[deq];
  }
  }
  if (pmthere) {
    document.getElementById('sm').click();
  } else {
    document.getElementById('myform').style.display='block';
  }
  pmval='';
  } else if (location.hash.indexOf('~') != -1) {
  eqis=location.hash.replace('#','').split('~');  
  for (deq=0; deq<eval(-1 + eqis.length); deq++) {
  deqis+=\"<input type=hidden id=\" + eqis[deq] + \" name=\" + eqis[deq] + \" value=''></input>\";
  lh.push(eqis[deq].split('|')[eval(-1 + eqis[deq].split('|').length)]);
  rh.push(eqis[eval(1 + deq)].split('|')[0]);
  }
  document.getElementById('dpm').innerHTML=deqis;
  for (deq=0; deq<eval(-1 + eqis.length); deq++) {
  document.getElementById(lh[deq]).value=rh[deq];
  }
  document.getElementById('sm').click();
  pmval='';
  } else if (location.hash.indexOf('=') != -1) {
  eqis=location.hash.replace('#','').split('=');  
  for (deq=0; deq<eval(-1 + eqis.length); deq++) {
  deqis+=\"<input type=hidden id=\" + eqis[deq] + \" name=\" + eqis[deq] + \" value=''></input>\";
  lh.push(eqis[deq].split('&')[eval(-1 + eqis[deq].split('&').length)]);
  rh.push(eqis[eval(1 + deq)].split('&')[0]);
  }
  document.getElementById('dpm').innerHTML=deqis;
  for (deq=0; deq<eval(-1 + eqis.length); deq++) {
  document.getElementById(lh[deq]).value=rh[deq];
  }
  document.getElementById('sm').click();
  pmval='';
  } else if (location.hash.indexOf('pm=') != -1) {
  pmval=location.hash.split('pm=')[1];
  if (pmval.indexOf('.') == 0) pmval=String.fromCharCode(92) + pmval;
  document.getElementById('dpm').innerHTML=\"<input type=hidden id=pm name=pm value=''></input>\";
  document.getElementById('pm').value=pmval;
  document.getElementById('sm').click();
  pmval='';
  } else {
  pmval=document.URL.split('/itnewblog/match/')[1].split('#')[0];
  }
 } else if (document.URL.indexOf('/ITblog/match/') != -1) {
  pmval=document.URL.split('/ITblog/match/')[1].split('#')[0];
 } else if (location.hash.indexOf('pm=') == 0) {
  pmval=location.hash.replace('pm=','');
 } else if (location.hash.indexOf('pm') == 0) {
  pmval=location.hash.replace('pm','');
 }
 if (pmval.indexOf('.') == 0) pmval=String.fromCharCode(92) + pmval;
 if (pmval != '') {
  location.href='http://www.rjmprogramming.com.au/itnewblog/match/mapper.php?pm=' + encodeURIComponent(pmval);
 }
}

</script>
</head>
<body onload=' atmatch(); '>
<form action='./mapper.php' method='POST' id='myform' style='display:none;'>
<div id='dpm' style='width:100%;'>
</div>
<input type=submit id=sm value=Submit style='display:none;'></input>
</form>
</body>
</html>
";
}
?>

