<?php
// remote_files.php
// RJM Programming
// March, 2023
// Thanks to https://php-legacy-docs.zend.com/manual/php5/en/features.remote-files

error_reporting(E_ERROR | E_PARSE);

$lines=[];
$jline=-1;
$atstart=true;
$isjson=false;

function lastjson($intl) {
  global $isjson;
  $outtl=$intl;
  if ($isjson) {
   $huhs=explode(']"', $intl);
   if (sizeof($huhs) > 1) {
     if (trim($huhs[1]) != "") {
       $outtl="";
       for ($i=0; $i<sizeof($huhs); $i++) {
         $outtl.='"' . str_replace("\\" . 'n', '<br>', str_replace("\\" . 'r' . "\\" . 'n', '<br>',  explode('"', explode(']"', $intl)[$i] )[-1 + sizeof(explode('"', explode(']"', $intl)[$i]))]   )) . ']"<br>';
       }
     }
   }
  }
  return $outtl;
}

function fixforjson($iln) {
  global $isjson;
  if ($isjson) {
    $wasiln=$iln;
    $iln=str_replace('},{','</td></tr><tr><td>',$iln);
    $iln=str_replace('}]}','</td></tr></table>',$iln);
    $iln=str_replace('{[{','<table><tr><td>',$iln);
    $iln=str_replace(':[{',':</td></tr></thead><tr><td>',$iln);
    if (substr($iln,0,1) == '{') { $iln='<table><thead><tr><td>' . substr($iln,1); }
    $iln=str_replace('":{','":<span>',$iln);
    $iln=str_replace('},','</span>,',$iln);
    $iln=str_replace(',"','</td><td>"',$iln);
    $iln=str_replace('>"',' class="',$iln);
    $iln=str_replace('":','">',$iln);
    //if (file_exists('iln.html')) {
    //file_put_contents('iln.html', file_get_contents('iln.html') . "\n\n" . $iln . "\n\n" . $wasiln);
    //} else {
    //file_put_contents('iln.html', $iln . "\n\n" . $wasiln);
    //}
  }
  return $iln;
}

function antiline($inlis) {
  global $line, $isjson;
  if (strpos($inlis, "<!--") !== false) {
    return '';
  }
  //if ($isjson) { return $inlis; }
  //echo "inlis=" . str_replace('<','&lt;',str_replace('>','&gt;',$inlis)) . "<br><br> and line=" . str_replace('<','&lt;',str_replace('>','&gt;',$line)) . "<br><br>";
  $bline=trim(explode("</", $line)[0]);
  if (strpos($bline, ">") !== false) {
    $fchar=substr($bline,0,1);
    $pchars=trim(explode(">", $bline)[-1 + sizeof(explode(">", $bline))]);
    if ($fchar < "0" || $fchar > 'z') {
      if ($fchar != substr($pchars,-1,1)) {
        if (strpos(substr($bline,1), $fchar) !== false) {
          $pchars=str_replace("<br/>","\n",str_replace("<br>","\n",$fchar . explode($fchar, substr($bline,1))[0] . $fchar));
        }
      } 
    }
    $fline=$pchars;
    if (strlen(explode("<", $inlis)[0]) > strlen($fline)) { return explode('<br', $inlis)[0]; }
    if ($fline != '' || (strpos($inlis, ">") !== false && strpos($inlis, ">") === false)) { return explode('<br', $fline)[0]; }
  }
  return explode('<br', $inlis)[0];
}

function huhit($insg) {
  global $isjson;
  $outsg=$insg;
  if (strpos($outsg, "<!--") !== false) {
    return '';
  }
  if (strpos($outsg, "</") !== false) {
    $outsg=explode("</", $outsg)[0];
  }
  if (strpos($outsg, ">") !== false) {
    $outsg=explode(">", $outsg)[-1 + sizeof(explode(">", $outsg))];
  }
  return str_replace("<","",explode('<br', $outsg)[0]);
}

function maybemore($inl, $inf) {
   global $bodyfound, $lines, $jline, $isjson;
   $ilrecs=-1;
   $aline="";
   $eletype="";
   $j=1;
   $k=1;
   $vsk=explode("<", $inl);
   //if (strpos($inl, '<body>') !== false || strpos($inl, '<body ') !== false) { $bodyfound=true;  }
   if (strpos($inl, "</") === false && strpos($inl, ">") !== false && strpos($inl, "<") !== false) {
     if ($bodyfound || 1 == 1) { 
       while ($eletype == "") {
        $eletype=str_replace('link','',str_replace('meta','',str_replace('head','',str_replace('html','',str_replace('!DOCTYPE','',str_replace('!--','',str_replace('body','',explode('>',explode('/>',explode(' ',explode("<", $inl)[$k])[0])[0])[0]))))))); 
        if (strpos($inl, "<" . $eletype . ' ') !== false && $eletype != "") { if (1 == 6) { echo "<br>" . $j . " good " . $eletype . "<br>"; }  break; } else { if (1 == 7) { echo "<br>" . $j . " nogood " . $eletype . "<br>"; } $eletype=""; }
        $k++;
        if ($k >= sizeof($vsk)) { if (1 == 5) { echo "<br>" . $k . " gt " . sizeof($vsk) . " why " . str_replace('<','&lt;',str_replace('>','&gt;',$inl)) . $eletype . "<br>"; }   break; }
       }
     }
     while (!feof ($inf) && strpos($inl, "</" . str_replace('!--','JUNK',str_replace("body","JUNK",$eletype))) === false && strpos($inl, ">") !== false) {
      $inl.=$aline;
      $aline = fgets ($inf, 1024);
      if ($isjson) { $aline=fixforjson($aline); }
      $j++;
      if (isset($_GET['maybe']) && !isset($_POST['maybe'])) { echo "<br>" . $j . " " . $eletype . "<br>"; }
      if (strpos($aline, "</" . str_replace('!--','JUNK',str_replace("body","JUNK",$eletype))) !== false) { break; }
     }
     //echo str_replace('<','&lt;',str_replace('>','&gt;',$inl . $aline . "<br><br>"));
     //exit;
   }
   $inl.=$aline;
   $vsk=explode("<", $inl);
   if (($bodyfound || 1 == 1) && $eletype == "") { 
       while ($eletype == "") {
        $eletype=str_replace('link','',str_replace('meta','',str_replace('head','',str_replace('html','',str_replace('!DOCTYPE','',str_replace('!--','',str_replace('body','',explode('>',explode('/>',explode(' ',explode("<", $inl)[$k])[0])[0])[0]))))))); 
        if (strpos($inl, "<" . $eletype . ' ') !== false && $eletype != "") { if (1 == 2) { echo "<br>" . $j . " good " . $eletype . "<br>"; }  break; } else { if (1 == 4) { echo "<br>" . $j . " nogood " . $eletype . "<br>"; } $eletype=""; }
        $k++;
        if ($k >= sizeof($vsk)) { if (1 == 7) { echo "<br>" . $k . " gt " . sizeof($vsk) . " why " . str_replace('<','&lt;',str_replace('>','&gt;',$inl)) . $eletype . "<br>"; }   break; }
       }
   }
   if (str_replace("body","",$eletype) != "") {
       $lrecs=explode("</" . str_replace('!--','JUNK',str_replace("body","JUNK",$eletype)) . ">", $inl);
       $ilrecs=sizeof($lrecs);
       if ($ilrecs > 1 && explode("\n", $lrecs[-1 + sizeof($lrecs)])[0] == "") { $ilrecs--;  }
       if ($ilrecs > 1) { 
         $lines=[];
         for ($jk=0; $jk<$ilrecs; $jk++) {
           array_push($lines, $lrecs[$jk] . "</" . str_replace("body","",$eletype) . ">");
         }
         $jline=1;
   if (!$bodyfound && 1 == 2) { $jline=-1; $lines=[]; return ''; }
         if (isset($_GET['maybe']) && !isset($_POST['maybe'])) { echo str_replace('<','&lt;',str_replace('>','&gt;',$lines[0] . "<br><br>")); }
         return $lines[0];
       }
   }
   if (!$bodyfound && 1 == 2) { $jline=-1; $lines=[]; return ''; }
   if ($j > 1) {
     if (isset($_GET['maybe']) && !isset($_POST['maybe'])) { echo str_replace('<','&lt;',str_replace('>','&gt;',$inl . $aline . "<br><br>")); }
   }
   return $inl;
}

$bodyfound=false;
$preblurb="<h1>Remote Files</h1><h3>RJM Programming - March, 2023</h3><hr><br>";
$conditional=false;
$uval="";
$tval="";
$cval="";
$sval="";
$oval="1";
$blurb="";
$pblurb="";
$preplus="";
$plus="+";
$z=0;
$y=0;
$cfor="For ";
$title="";
$pregt="@\<title\>(.*)\</title\>@i";
$matcho=1;
$curo=0;
$fcont='';
$fn='';
$ofn='';
$tdate='' . date('Y-m-d');
$tsis=explode('-', $tdate);
$dis=$tsis[2];
$udis=0;
if (substr($dis,0,1) == '0') {
  $udis=intval(substr($dis,1));
} else {
  $udis=intval($dis);
}
if ($udis > 1) {
  $tdate=$tsis[0] . '-' . $tsis[1] . '-' . substr(('0' . (-1 + $udis)),-2,2);
} else {
  date_default_timezone_set('UTC');
  $tdate='' . date('Y-m-d');
  date_default_timezone_set('Australia/Perth');
}
if (isset($_POST['url']) && $_POST['url'] != '') {
$fn="http:" . str_replace("http:","",str_replace("https:","",str_replace("+"," ",urldecode($_POST['url']))));
if ($fn != str_replace('dateymd','',$fn)) {
  if (file_exists('dateymd.txt')) {
    $fcont=file_get_contents('./dateymd.txt');
    if (strpos($fcont, str_replace('dateymd','' . $tdate,$fn)) !== false) {
      $ofn=str_replace('dateymd','' . $tdate,$fn) . "\n";
      $fn='./dateymd.txt';
    } else {
      $ofn=str_replace('dateymd','' . $tdate,$fn) . "\n";
      $pc=file_get_contents(str_replace('dateymd','' . $tdate,$fn));
      if (strpos($pc, '[') !== false) {
      file_put_contents('./dateymd.txt', '' . str_replace('dateymd','' . $tdate,$fn) . "\n" . str_replace(']"},',']"},' . "\n",$pc));
      }
      $fcont=file_get_contents('./dateymd.txt');
      $fn='./dateymd.txt';
    }
  } else {
    $ofn=str_replace('dateymd','' . $tdate,$fn) . "\n";
    $pc=file_get_contents(str_replace('dateymd','' . $tdate,$fn));
    if (strpos($pc, '[') !== false) {
    file_put_contents('./dateymd.txt', '' . str_replace('dateymd','' . $tdate,$fn) . "\n" . str_replace(']"},',']"},' . "\n",$pc));
    }
    $fcont=file_get_contents('./dateymd.txt');
    $fn='./dateymd.txt';
  }
}
$file = fopen ($fn, "r");
$pblurb="Looking in <a target=_blank href='" . str_replace("+"," ",urldecode($_POST['url'])) . "' title='" . str_replace("+"," ",urldecode($_POST['url'])) . "'>" . str_replace("+"," ",urldecode($_POST['url'])) . "</a> ";
$uval=str_replace("+"," ",urldecode($_POST['url']));
$cfor="for ";
} else if (isset($_GET['url']) && $_GET['url'] != '') {
$fn="http:" . str_replace("http:","",str_replace("https:","",str_replace("+"," ",urldecode($_GET['url']))));
if ($fn != str_replace('dateymd','',$fn)) {
  if (file_exists('dateymd.txt')) {
    $fcont=file_get_contents('./dateymd.txt');
    if (strpos($fcont, str_replace('dateymd','' . $tdate,$fn)) !== false) {
      $ofn=str_replace('dateymd','' . $tdate,$fn) . "\n";
      $fn='./dateymd.txt';
    } else {
      $ofn=str_replace('dateymd','' . $tdate,$fn) . "\n";
      $pc=file_get_contents(str_replace('dateymd','' . $tdate,$fn));
      if (strpos($pc, '[') !== false) {
      file_put_contents('./dateymd.txt', '' . str_replace('dateymd','' . $tdate,$fn) . "\n" . str_replace(']"},',']"},' . "\n",$pc));
      }
      $fcont=file_get_contents('./dateymd.txt');
      $fn='./dateymd.txt';
    }
  } else {
    $ofn=str_replace('dateymd','' . $tdate,$fn) . "\n";
    $pc=file_get_contents(str_replace('dateymd','' . $tdate,$fn));
    if (strpos($pc, '[') !== false) {
    file_put_contents('./dateymd.txt', '' . str_replace('dateymd','' . $tdate,$fn) . "\n" . str_replace(']"},',']"},' . "\n",$pc));
    }
    $fcont=file_get_contents('./dateymd.txt');
    $fn='./dateymd.txt';
  }
}
$file = fopen ($fn, "r");
$pblurb="Looking in <a target=_blank href='" . str_replace("+"," ",urldecode($_GET['url'])) . "' title='" . str_replace("+"," ",urldecode($_GET['url'])) . "'>" . str_replace("+"," ",urldecode($_GET['url'])) . "</a> ";
$uval=str_replace("+"," ",urldecode($_GET['url']));
$cfor="for ";
} else {
$file = fopen ("http://www.rjmprogramming.com.au/index.php", "r");
$cfor="Looking in " . "http://www.rjmprogramming.com.au/index.php" . " for ";
}

$pt="";
$at="@";
$ptp="";
$opt="";
if (isset($_POST['url']) || isset($_GET['url'])) {
if (isset($_POST['type']) && $_POST['type'] != '' && strpos(str_replace(" ","=",urldecode($_POST['type'])), '=') !== false) {
  $pt=str_replace("+"," ",urldecode($_POST['type']));
  $opt=$pt;
  if (strpos(explode(" ", trim($pt))[0], "=") === false && explode(" ", trim($pt))[0] != "") { // && strpos(str_replace("+"," ",urldecode($_POST['type'])), '=') !== false) {
    $pt=substr($pt, strlen(explode(" ", $pt)[0]));
    $_POST['type']=urlencode(explode(" ", $opt)[0]);
    if (substr($pt,0,1) == " " && strpos(str_replace("+"," ",urldecode($_POST['type'])), '=') !== false) {
      $ptp=explode(" ", $opt)[0] . "[^" . substr($pt,0,1) . "]+\\" . substr($pt,0,1);
      $pt=substr($pt,1);
      $_POST['type']=' ';
    } else {
      $ptp=explode(" ", $opt)[0];
      $_POST['type']=' ';
    }
    $at="@[^<]+\\<" . $ptp . "[^" . substr($pt,0,1) . "]+" . $pt . "[^>]+";
  } else {
    $_POST['type']='';
    if (substr($pt,0,1) == " " && 1 == 2) {
      $ptp="[^" . substr($pt,0,1) . "]+\\" . substr($pt,0,1);
      $pt=substr($pt,1);
    }
    //$at="@" . $ptp . "[^" . substr($pt,0,1) . "]+" . $pt . "[^>]+";
    $at="@\\" . $pt . "[^>]+";
    //$at="@\\" . $pt . "[^>]+(.*)";
  }
$pblurb.=$cfor . " " . $opt . " element ";
$cfor=" ";
} else if (isset($_GET['type']) && $_GET['type'] != '' && strpos(str_replace(" ","=",urldecode($_GET['type'])), '=') !== false) {
  $pt=str_replace("+"," ",urldecode($_GET['type']));
  $opt=$pt;
  if (strpos(explode(" ", trim($pt))[0], "=") === false && explode(" ", trim($pt))[0] != "") { // && strpos(str_replace("+"," ",urldecode($_GET['type'])), '=') !== false) {
//  echo explode(" ", $pt)[0];
//  exit;
    $pt=substr($pt, strlen(explode(" ", $pt)[0]));
    $_GET['type']=urlencode(explode(" ", $opt)[0]);
    if (substr($pt,0,1) == " ") {
      $ptp=explode(" ", $opt)[0] . "[^" . substr($pt,0,1) . "]+\\" . substr($pt,0,1);
      $pt=substr($pt,1);
      $_GET['type']=' ';
    } else {
      $ptp=explode(" ", $opt)[0];
      $_GET['type']=' ';
    }
    $at="@[^<]+\\<" . $ptp . "[^" . substr($pt,0,1) . "]+" . $pt . "[^>]+";
//  echo str_replace('<','&lt;',str_replace('>','&gt;',$at));
//  exit;
  } else {
    $_GET['type']='';
    if (substr($pt,0,1) == " " && 1 == 2) {
      $ptp="[^" . substr($pt,0,1) . "]+\\" . substr($pt,0,1);
      $pt=substr($pt,1);
    }
    //$at="@" . $ptp . "[^" . substr($pt,0,1) . "]+" . $pt . "[^>]+";
    $at="@\\" . $pt . "[^>]+";
    //$at="@\\" . $pt . "[^>]+(.*)";
//  echo str_replace('<','&lt;',str_replace('>','&gt;',$at));
//  exit;
  }
$pblurb.=$cfor . " " . $opt . " element ";
$cfor=" ";
}

if (isset($_POST['type']) && trim($_POST['type']) != '') {
$pregt=$at . "\\<" . str_replace("+"," ",urldecode($_POST['type'])) . "\\>(.*)\\</" . str_replace("+"," ",urldecode($_POST['type'])) . "\\>@i";
$pregt=$at . "\\>(.*)\\</" . str_replace("+"," ",urldecode($_POST['type'])) . "\\>@i";
$tval=str_replace("+"," ",urldecode($_POST['type']));
$pblurb.=$cfor . str_replace("+"," ",urldecode($_GET['type'])) . " element ";
$cfor=" ";
} else if (isset($_GET['type']) && trim($_GET['type']) != '') {
$pregt=$at . "\\<" . str_replace("+"," ",urldecode($_GET['type'])) . "\\>(.*)\\</" . str_replace("+"," ",urldecode($_GET['type'])) . "\\>@i";
$pregt=$at . "\\>(.*)\\</" . str_replace("+"," ",urldecode($_GET['type'])) . "\\>@i";
$tval=str_replace("+"," ",urldecode($_GET['type']));
$pblurb.=$cfor . str_replace("+"," ",urldecode($_GET['type'])) . " element ";
$cfor=" ";
} else if ($at == "@") {
$pregt="@\<title\>(.*)\</title\>@i";
$cfor.="title " . "element ";
} else if (strpos($opt, "=") !== false) {
$tval=$opt;
$pregt=$at . "\\>(.*)\\</" . "@i";
          $conditional=true;
} else if ($opt != "") {
$tval=$opt;
$pregt=$at . "\\>(.*)\\</" . "@i";
$conditional=true;
}

if (isset($_POST['ord']) && $_POST['ord'] != '') {
$matcho=intval(str_replace("+"," ",urldecode($_POST['ord'])));
$oval="$matcho";
$pblurb.=$cfor . "number " . $matcho . " ... <br>";
} else if (isset($_GET['ord']) && $_GET['ord'] != '') {
$matcho=intval(str_replace("+"," ",urldecode($_GET['ord'])));
$oval="$matcho";
$pblurb.=$cfor . "number " . $matcho . " ... <br>";
} else {
$matcho=1;
$cfor.="number " . $matcho . " ... <br>";
}

if (isset($_POST['containing']) && $_POST['containing'] != '') {
if ($pregt == "@\<title\>(.*)\</title\>@i") {
$pregt="@\\>(.*)" . str_replace("+"," ",urldecode($_POST['containing'])) . "\\</@i";
} else {
$pregt=str_replace("(.*)", "(.*)" . str_replace("+"," ",urldecode($_POST['containing'])), $pregt);
}
$cval=str_replace("+"," ",urldecode($_POST['containing']));
$pblurb=str_replace(" ... <br>","",$pblurb);
if ($tval == "") {
$pblurb=str_replace(" numbering up to 1 "," in unlimited search ",str_replace(" number "," numbering up to ",$pblurb));
}
$pblurb=str_replace(" numbering up to 1 "," in unlimited search ",$pblurb) . " containing " . str_replace("+"," ",urldecode($_POST['containing'])). " ... <br>";
$cfor=" ";
} else if (isset($_GET['containing']) && $_GET['containing'] != '') {
if ($pregt == "@\<title\>(.*)\</title\>@i") {
$pregt="@\\>(.*)" . str_replace("+"," ",urldecode($_GET['containing'])) . "\\</@i";
} else {
$pregt=str_replace("(.*)", "(.*)" . str_replace("+"," ",urldecode($_GET['containing'])), $pregt);
}
$cval=str_replace("+"," ",urldecode($_GET['containing']));
$pblurb=str_replace(" ... <br>","",$pblurb);
if ($tval == "") {
$pblurb=str_replace(" numbering up to 1 "," in unlimited search ",str_replace(" number "," numbering up to ",$pblurb));
}
$pblurb=str_replace(" numbering up to 1 "," in unlimited search ",$pblurb) . " containing " . str_replace("+"," ",urldecode($_GET['containing'])). " ... <br>";
$cfor=" ";
}

if (isset($_GET['starting']) && $_GET['starting'] != '') {
if ($pregt == "@\<title\>(.*)\</title\>@i") {
if ($cval != '') {
$pregt="@[^\>]+\\>" .  str_replace("] ","]+",str_replace("+"," ",urldecode($_GET['starting']))) . "[^" . $cval . "]+[" . $cval . "]\\</@i";
} else {
if (strpos(str_replace("+"," ",urldecode($_GET['starting'])), "] ") !== false) { $y=0; }
$pregt="@[^\>]+\\>" . str_replace("] ","]+",str_replace("+"," ",urldecode($_GET['starting']))) . "(.*)[^<]+\\</@i";
//echo urldecode($_GET['starting']) . " heRE" . str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
//exit;
// good is @[^\>]+\>R[^<]+\</@i
// bad is  @[^\>]+\>[RS][^<]+\</@i
}
} else {
   if ($cval != '') {
//echo urldecode($_GET['starting']) . " heRE" . str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
//exit;

   // @\ class[^>]+\>[^s]+(.*)s\</@i

   if (strpos($pregt, "(.*)[^<]+") !== false) {
   $pregt="@[^>]+" . str_replace("(.*)[^<]+", "" . str_replace("] ","]+",str_replace("+"," ",urldecode($_GET['starting']))) . "[^" . $cval . "]+[" . $cval . "]", substr($pregt,1));
   } else if (strpos($pregt, "+(.*)[") !== false) {
//echo "(.*)[" . " preHERE" . str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
//exit;
   if (strpos(str_replace("+"," ",urldecode($_GET['starting'])), "[") === false) { $preplus="\\"; $plus=""; } 
   $pregt=str_replace("+${cval}", "+(.*)${cval}",   "@[^>]+" . str_replace("+(.*)[", "+\>" . $preplus . str_replace("] ","]+",str_replace("+"," ",urldecode($_GET['starting']))) . $plus . str_replace('[','[^',$cval) . "+[", str_replace("\\>(.*)${cval}\\", "", substr($pregt,1))));
$preplus="";
$plus="+";
//echo "(.*)[" . " HERE" . str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
//exit;
   } else if (strpos($pregt, ">(.*)") !== false) {
   $pregt="@[^>]+" . str_replace(">(.*)", ">" . str_replace("] ","]+",str_replace("+"," ",urldecode($_GET['starting']))) . "" . str_replace('[','[^',str_replace("]]","]",str_replace("[[","[","[${cval}]"))) . "+(.*)", substr($pregt,1));
//echo "(.*)[" . " tHeRE" . str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
//exit; // (.*)[ HeRE@\ class[^>]+(.*)s\>(.*)s\</@i
   } else { // @\ class[^>]+\>(.*)s\</@i
//echo "(.*)[" . " HeRE" . str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
//exit; // (.*)[ HeRE@\ class[^>]+(.*)s\>(.*)s\</@i
   $pregt="@[^>]+" . str_replace("(.*)[", "" . str_replace("] ","]+",str_replace("+"," ",urldecode($_GET['starting']))) . "+" . str_replace('[','[^',$cval) . "+(.*)[", substr($pregt,1));
//echo "(.*)[" . " HeRE" . str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
//exit; // (.*)[ HeRE@\ class[^>]+(.*)s\>(.*)s\</@i
   }
//echo urldecode($_GET['starting']) . " heRE" . str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
//exit;
   } else {
   $pregt="@[^>]+" . str_replace("(.*)", "" . str_replace("] ","]+",str_replace("+"," ",urldecode($_GET['starting']))) . "[^<]+", substr($pregt,1));
   }
}
$sval=str_replace("+"," ",urldecode($_GET['starting']));
$pblurb=str_replace(" ... <br>","",$pblurb);
if ($tval == "") {
$pblurb=str_replace(" numbering up to 1 "," in unlimited search ",str_replace(" number "," numbering up to ",$pblurb));
}
$pblurb=str_replace(" numbering up to 1 "," in unlimited search ",$pblurb) . " starting " . str_replace("+"," ",urldecode($_GET['starting'])). " ... <br>";
$cfor=" ";
} else if (isset($_POST['starting']) && $_POST['starting'] != '') {
if ($pregt == "@\<title\>(.*)\</title\>@i") {
if ($cval != '') {
$pregt="@[^\>]+\\>" . str_replace("+"," ",urldecode($_POST['starting'])) . "[^" . $cval . "]+[" . $cval . "]\\</@i";
} else {
$pregt="@[^\>]+\\>" . str_replace("+"," ",urldecode($_POST['starting'])) . "[^<]+\\</@i";
//echo str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
//exit;
}
} else {
if ($cval != '') {
$pregt="@[^>]+\\>" . str_replace("+"," ",urldecode($_POST['starting'])) . "[^" . $cval . "]+[" . $cval . "]\\</@i";
// echo str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
// exit;
} else {
   if ($cval != '') {
   $pregt="@[^>]+" . str_replace("(.*)[^<]+", "" . str_replace("+"," ",urldecode($_POST['starting'])) . "[^" . $cval . "]+[" . $cval . "]", substr($pregt,1));
   } else {
   $pregt="@[^>]+" . str_replace("(.*)", "" . str_replace("+"," ",urldecode($_POST['starting'])) . "[^<]+", substr($pregt,1));
   }
//   $pregt="@[^>]+" . str_replace("(.*)", "" . str_replace("+"," ",urldecode($_POST['starting'])) . "[^<]+", substr($pregt,1));
}
}
$sval=str_replace("+"," ",urldecode($_POST['starting']));
$pblurb=str_replace(" ... <br>","",$pblurb);
if ($tval == "") {
$pblurb=str_replace(" numbering up to 1 "," in unlimited search ",str_replace(" number "," numbering up to ",$pblurb));
}
$pblurb=str_replace(" numbering up to 1 "," in unlimited search ",$pblurb) . " starting " . str_replace("+"," ",urldecode($_POST['starting'])). " ... <br>";
$cfor=" ";
}


if (isset($_POST['middling']) && $_POST['middling'] != '') {

$mval=str_replace("+"," ",urldecode($_POST['middling']));
$cfor=" ";

// @[^>]+\>(.*)!\</@i

// @\>(.*)!\</@i

$pregt=str_replace("@\>(.*)", "@[^>]+\>(.*)", $pregt);
$pregt=str_replace("@\<title\>(.*)\</title\>@i", "@[^>]+\>(.*)\</@i", $pregt);

if ($cval != '') {
$pregt=str_replace("@[^>]+\>(.*)", "@[^>]+\>(.*)[^" . substr($mval,0,1) . "]+" . $mval . "[^" . $cval . "]+", $pregt);
if (strpos($pblurb, " containing ") === false) { 
$pblurb=str_replace(" element "," element containing " . $mval . " ",$pblurb); 
} else {
$pblurb=str_replace(" containing "," containing " . $mval . " ending with ",$pblurb);
}
} else {
if (strpos($pblurb, " containing ") === false) { 
$pblurb=str_replace(" element "," element containing " . $mval . " ",$pblurb); 
} else {
$pblurb=str_replace(" containing "," containing " . $mval . " ending with ",$pblurb);
}
//@[^>]+\>(.*)[^3]+3[^>]+\</p\>@i
//$pregt=str_replace("@[^>]+\>(.*)", "@[^>]+\>(.*)[^" . substr($mval,0,1) . "]+" . $mval, $pregt);
  $pregt=str_replace("@[^>]+\\>(.*)", "@[^>]+\\>[^" . substr($mval,0,1) . "]+(.*)" . $mval, $pregt);
//echo "Sval=$sval and Cval=$cval conditional=$conditional " . str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
//exit;
}
$pblurb=str_replace(" number 1 "," in unlimited search ",$pblurb);
} else if (isset($_GET['middling']) && $_GET['middling'] != '') {

$mval=str_replace("+"," ",urldecode($_GET['middling']));
$cfor=" ";

// @[^>]+\>(.*)!\</@i

// @\>(.*)!\</@i

$pregt=str_replace("@\>(.*)", "@[^>]+\>(.*)", $pregt);
$pregt=str_replace("@\<title\>(.*)\</title\>@i", "@[^>]+\>(.*)\</@i", $pregt);

if ($cval != '') {
$pregt=str_replace("@[^>]+\>(.*)", "@[^>]+\>(.*)[^" . substr($mval,0,1) . "]+" . $mval . "[^" . $cval . "]+", $pregt);
if (strpos($pblurb, " containing ") === false) { 
$pblurb=str_replace(" element "," element containing " . $mval . " ",$pblurb); 
} else {
$pblurb=str_replace(" containing "," containing " . $mval . " ending with ",$pblurb);
}
} else {
if (strpos($pblurb, " containing ") === false) { 
$pblurb=str_replace(" element "," element containing " . $mval . " ",$pblurb); 
} else {
$pblurb=str_replace(" containing "," containing " . $mval . " ending with ",$pblurb);
}
//@[^>]+\>(.*)[^3]+3[^>]+\</p\>@i
  //$pregt=str_replace("@[^>]+\>(.*)", "@[^>]+\>(.*)[^" . substr($mval,0,1) . "]+" . $mval . "[^>]+", $pregt);
  $pregt=str_replace("@[^>]+\\>(.*)", "@[^>]+\\>[^" . substr($mval,0,1) . "]+" . $mval . "[^<]+(.*)", $pregt);
//echo "Sval=$sval and Cval=$cval conditional=$conditional " . str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
//exit;
}
$pblurb=str_replace(" number 1 "," in unlimited search ",$pblurb);

}

if ($tval == "") {
  $pblurb=str_replace("for title element", "for any element", $pblurb);
}

//echo "Sval=$sval and Cval=$cval conditional=$conditional " . str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
//exit;

//   echo str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
//   exit;

//   sval= and cval= conditional= @[^>]+\>(.*)[^3]+3[^>]+\</p\>@i ... is mval scenario 

if (strpos($pregt, "@[^>]+") !== false && ('' . $_POST['type'] . $_GET['type']) == '' && ($conditional || strpos($pregt, "=") !== false)) {
  //if ($mval != "") {  echo "2"; exit;  }
  $pregt=str_replace("@[^>]+", "@", $pregt);
}


if (strpos($pregt, "+(.*)${cval}\\>(.*)${cval}") !== false && (9 == 9 || strpos($cval,"[") === false) && $cval != "") { //} && strpos($pregt, "=") !== false) {
  //if ($mval != "") {  echo "3"; exit;  }
  $pregt=str_replace('=','\=', str_replace('"','\"', str_replace("[^]+(.*)","[^<]+(.*)",str_replace("+(.*)${cval}\\>(.*)${cval}", "+\>" . str_replace('[','[^',str_replace("]]","]",str_replace("[[","[","[${cval}]"))) . "+(.*)${cval}", $pregt))));
}

// +(.*)\>(.*)\</
if (strpos($pregt, "(.*)\\>(.*)") !== false && strpos($pregt, "=") !== false) {
  //if ($mval != "") {  echo "4"; exit;  }
  $pregt=str_replace("(.*)\\>(.*)", "\\>[^<]+(.*)", $pregt);
}

//+(.*)s\>(.*)s

// bad @\ class[^>]+(.*)[e-s]\>(.*)[e-s]\</@i

if (strpos($pregt, ">${cval}+(.*)${cval}\\<") !== false && strpos($pregt, "=") !== false && strpos($cval, "[") === false) {
   //if ($mval != "") {  echo "5"; exit;  }
 $pregt=str_replace(">${cval}+(.*)${cval}\\<", ">[^${cval}]+(.*)${cval}\\<", $pregt);
}

if (strpos($pregt, ">(.*)\\") !== false) {
  //if ($mval != "") {  echo "6"; exit;  }
  $pregt=str_replace('=','\=', str_replace('"','\"', str_replace(">(.*)\\", ">[^<]+(.*)\\", $pregt)));
}


}

if (isset($_GET['pregt'])) {
   $pregt=urldecode($_GET['pregt']);
}

// bad @\ class\=[^>]+\>[^<]+(.*)\</@i
//good @\ class[^>]+\>[^<]+(.*)\</@i

// bad @\ class="[^>]+\>\W[^e-s]+(.*)[e-s]</@i
//good @\   class[^>]+\>[^e-s]+(.*)[e-s]\</@i
// bad @\   class[^>]+\>W+[^e-s]+(.*)[e-s]</@i
//GOOD @[^>]+\>W+[^e-s]+(.*)[e-s]\</@i

//  BAD sval= and cval= conditional=0 @\ class\=\"[^>]+\>[^<]+(.*)\</@i
// GooD sval= and cval= conditional=1 @\ class[^>]+\>[^<]+(.*)\</@i

// GOOd sval=[A-N] and cval=s   conditional=1 @\ class="[^>]+\>[A-N][^s]+(.*)s\</@i
//  BAD sval=[A-N] and cval=[s] conditional=1 @\ class="[^>]+\>[A-N][^[^s]]+(.*)[s]\</@i

// another good "@\ class[^q]+quoteText[^>]+\>[^<]+(.*)\</@i"
// another bad @\ class\=\"quoteText\"[^>]+\>[^<]+(.*)\</@i


//echo "Sval=$sval and cval=$cval conditional=$conditional " . str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
//exit;
// @\ class\=\"[^>]+\>[^<]+(.*)\</@i

if (strpos($pregt, '\=\"[^>') !== false) {
  $pregt=str_replace('\=\"[^>','[^>', $pregt);
} else if (strpos($pregt, '\=\"') !== false) {
  $oos=explode('\=\"', $pregt);
  if (sizeof($oos) > 1) {
    $pregt=str_replace('\=\"','[^' . substr($oos[1],0,1) . "]+", $pregt);
    if (strpos($pregt, '\"[^>]') !== false) {
      $pregt=str_replace('\"[^>]','[^>]', $pregt);
    }
  }
}

// @\ class[^[]+[^>]+\>[^<]+(.*)\</@i

//echo "sval=$sval and cval=$cval conditional=$conditional " . str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
//exit;

if (!$file) {
    echo "<p>Unable to open remote file.\n";
    exit;
}
if ($conditional && $cval == "" && $sval == "" && $mval == "") {
  if (1 == 1) { $cval="<"; $z=1; }
//echo str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
//exit;
}


while (!feof ($file)) {
    if (sizeof($lines) == 0) {
     $line = fgets ($file, 1024);
     if ($atstart) {
      if ($fcont != '') { if (strpos($line, $ofn) === false) { $onebad=explode('{', $line)[0]; $line=str_replace($onebad,'',$line);  } else { $line=str_replace($ofn,'',$line); } $fcont=''; $isjson=true; }
      if (substr($line,0,1) == "[" || substr($line,0,1) == "{") {
        $isjson=true;
      }
      $atstart=false;
     }
     if ($isjson) { $line=fixforjson($line); }
     if (!isset($_GET['nomaybe']) && !isset($_POST['nomaybe'])) { $line = maybemore($line, $file); }
    } else if (sizeof($lines) > $jline) {
     $line = $lines[$jline];
     if (isset($_GET['maybe']) && !isset($_POST['maybe'])) { echo str_replace('<','&lt;',str_replace('>','&gt;',$line . "<br><br>")); }
     $jline++;
    } else {
     $lines=[];
     $line = fgets ($file, 1024);
     if ($isjson) { $line=fixforjson($line); }
     if (!isset($_GET['nomaybe']) && !isset($_POST['nomaybe'])) { $line = maybemore($line, $file); }
    }
    /* This only works if the title and its tags are on one line */
    if (preg_match ($pregt, str_replace("\n"," ",$line), $out)) {
    
    //if (huhit($out[0]) != '') {
    //echo "zhere " . str_replace('<','&lt;',str_replace('>','&gt;',$line));
    //exit;
    //}
        
        if ($cval == "" && $sval == "" && $mval == "") {
        if ($conditional) {
        if (strpos($out[0], ">") !== false) {
        if ($title == "" || $matcho > 1 || !("$cval$sval$mval" != "" && ($tval == "" || $cval == "<") && $matcho == 1)) {
          if (huhit(explode("<", explode(">", $out[0])[1])[0]) != '') { $title = huhit(explode("<", explode(">", $out[0])[1])[0]); $curo++; } 
        } else {
        if (huhit(explode("<", explode(">", $out[0])[1])[0]) != '') {
        $title .= "<br>" . huhit(explode("<", explode(">", $out[0])[1])[0]);
          $curo++; 
          }
        }
        
        } else {
        
        if ($title == "" || $matcho > 1 || !("$cval$sval$mval" != "" && ($tval == "" || $cval == "<") && $matcho == 1)) {
        if (huhit($out[0]) != '') {
        $title = huhit($out[0]);
          $curo++; 
          }
        } else {
        if (huhit($out[0]) != '') {
        $title .= "<br>" . huhit($out[0]);
          $curo++; 
          }
        }        
        }
        } else if ($title == "" || $matcho > 1 || !("$cval$sval$mval" != "" && ($tval == "" || $cval == "<") && $matcho == 1)) {
        //echo "wHere " . $out[1] . sizeof($out);
        //exit;
        $oneis=1;
        if (trim($out[1]) == '') { $oneis=0;  }
        if (huhit($out[$oneis]) != '') {
        $title = huhit($out[$oneis]);
          $curo++; 
          }
        } else {
        $oneis=1;
        if (trim($out[1]) == '') { $oneis=0;  }
        if (huhit($out[$oneis]) != '') {
        $title .= "<br>" . huhit($out[$oneis]);
          $curo++; 
          }
        }
        } else {
        //echo "tHere";
        //exit;

        if ($sval != "" && $cval != "") {
        if ($mval != '') {
        if (($out[1] . $mval . $out[2] . str_replace('<','',$cval)) != ($mval . str_replace('<','',$cval)) && strpos($out[1] . substr(explode($mval,$line)[0],-1,1) . $mval . explode('<', explode($mval,$line)[1])[0], $sval) !== false) { 
        if (strpos(huhit($out[1] . substr(explode($mval,$line)[0],-1,1) . $mval . explode('<', explode($mval,$line)[1])[0]), $mval) !== false) {
        $curo++; 
        $title .= "<br>" . huhit($out[1] . substr(explode($mval,$line)[0],-1,1) . $mval . explode('<', explode($mval,$line)[1])[0]); 
        }
        }
        } else {
        
       // echo "here";
        //exit;
        
        if (explode(">" . $sval,$out[0 + $y])[1] != "" || antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))])) != "") { 
        $curo++; 
        
        if (1 == 1 && (strpos($line, ">" . $sval) === false || strpos($line, $cval . "<") === false) && antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))])) != "") {
        $title .= "<br>" . antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))])); 
        } else {
        $title .= "<br>" . huhit($sval . explode(">" . $sval,$out[0 + $y])[1] . str_replace('<','',$cval)); 
        }
        
        }
        }
        } else if ($sval != "") {
        if ($mval != '') {
        
        if (huhit($out[1] . substr(explode($mval,$line)[0],-1,1) . $mval . explode('<', explode($mval,$line)[1])[0]) == '' && strpos(antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))])), $mval) !== false) {
        $title .= "<br>" . antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))]));
        } else {
        $title .= "<br>" . huhit($out[1] . substr(explode($mval,$line)[0],-1,1) . $mval . explode('<', explode($mval,$line)[1])[0]);
        }

        } else if (1 == 1 && strpos($line, ">" . $sval) === false && antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))])) != "") {
        $title .= "<br>" . antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))]));
        } else {
        //echo str_replace('<','&lt;',str_replace('>','&gt;',$pregt)) . "<br>00" . $out[0] . "<br>" . str_replace('<','&lt;',str_replace('>','&gt;',$pregt));
        //exit;
        $title .= "<br>" . huhit($sval . explode("<", explode(">" . $sval,$out[0 + $y])[1])[0]); // . "*" . antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))]));
        }
        $curo++;
        } else if ($cval != "") {
        if ($mval != '') {
        if (strpos($out[1 - $z], ">") !== false || antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))])) != "") {

        
        if (huhit(explode("<", explode(">", $out[1 - $z])[1])[0] . substr(explode($mval,$line)[0],-1,1) . $mval . explode('<', explode($mval,$line)[1])[0]) == '' && strpos(antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))])), $mval) !== false) {
        $title .= "<br>" . antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))]));
        } else {
        $title .= "<br>" . huhit(explode("<", explode(">", $out[1 - $z])[1])[0] . substr(explode($mval,$line)[0],-1,1) . $mval . explode('<', explode($mval,$line)[1])[0]);
        }

        $curo++;
        } else {
       //echo "HeREy";
        //exit;

        if (1 == 1 && strpos($line, $cval . "<") === false && antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))])) != "") {
      // echo "HeRE";
       // exit;
        $title .= "<br>" . antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))]));
        } else {
        //echo "HerE";
        //exit;
        $title .= "<br>" . huhit($out[1 - $z] . substr(explode($mval,$line)[0],-1,1) . $mval . explode('<', explode($mval,$line)[1])[0]);
        }
        $curo++;
        }
        } else {
        if (strpos($out[1 - $z], ">") !== false) {
       //echo "HeREa";
        //exit;
        if (1 == 1 && strpos($line, $cval . "<") === false && antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))])) != "") {
        $title .= "<br>" . antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))]));
        $curo++;
        } else {
        $title .= "<br>" . huhit(explode("<", explode(">", $out[1 - $z])[1])[0] . str_replace('<','',$cval));
        if (explode("<", explode(">", $out[1 - $z])[1])[0] . str_replace('<','',$cval) != "") { $curo++; }
        }
        } else {
      // echo "HeREb";
        //exit;
        if (1 == 1 && strpos($line, $cval . "<") === false && antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))])) != "") {
        $title .= "<br>" . huhit(antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))])));
        $curo++;
        } else {

        //echo "PREheRE";
        //exit;

        $title .= "<br>" . huhit($out[1 - $z] . str_replace('<','',$cval));
        if ($out[1 - $z] . str_replace('<','',$cval) != "") { $curo++; }
        }
        }
        }
        //$curo++;
        } else if (strpos($line, $mval) !== false) {

        //echo "PREHerE";
        //exit;

        if ($mval != '' && (strpos(antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))])), $mval) !== false || huhit($out[1] . substr(explode($mval,$line)[0],-1,1) . $mval . explode('<', explode($mval,$line)[1])[0]) == '') && strpos(antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))])), $mval) !== false) {
        if (strpos(antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))])), $mval) !== false) {
        $title .= "<br>" . antiline(trim(explode(">",explode("</",$line)[0])[1 + 0 * (-1 + sizeof(explode(">",explode("</",$line)[0])))]));
        $curo++;
        }
        } else {
        $title .= "<br>" . huhit($out[1] . substr(explode($mval,$line)[0],-1,1) . $mval . explode('<', explode($mval,$line)[1])[0]);
        $curo++;
        }
        }
        }
        if ($curo >= $matcho) { $blurb=str_replace(" numbering up to 1 starting "," in unlimited search starting  ",str_replace(" numbering up to 1 containing "," in unlimited search containing ",$pblurb)); if ("$cval$sval$mval" != "" && ($tval == "" || $cval == "<") && $matcho == 1) { $curo=$curo; } else { break; } }
    }
}
fclose($file);

$postblurb="<hr><br><form action=./remote_files.php method=GET><input ondblclick=\"if (this.value.length == 0) { this.value='http://www.rjmprogramming.com.au/index.php'; }\" style=width:96%;' type=url name=url value='" . $uval . "' title='URL [http://www.rjmprogramming.com.au/index.php]' placeholder='URL [http://www.rjmprogramming.com.au/index.php]'></input><br><input onkeypress=\"return validateKey(event);\" onkeyup=\"checkeq(event);\" ondblclick=\"if (this.value.length == 0) { this.value='title'; }\" style=width:96%;' type=text id=itval name=type value='" . $tval . "' title='Element type [title] or attribute= entries' placeholder='Element type [title] or attribute= entries ... Number [1] below ...'></input><br><input style=width:96%;' type=number name=ord value='" . $oval . "' min=1 step=1 title='Number [1]' placeholder='Number [1]'></input><br><input style=width:96%;' type=text name=starting value='" . $sval . "' title='Starting with []' placeholder='Starting with []'></input><br><input style=width:96%;' type=text name=middling value='" . $mval . "' title='In the Middle with []' placeholder='In the Middle with []'></input><br><input style=width:96%;' type=text name=containing value='" . str_replace('<','',$cval) . "' title='Ending with []' placeholder='Ending with []'></input><br><br><input type=submit value=Search></input></form>";
echo "<html><head><meta charset='UTF-8'/><style> div { width:100%; background-color:rgba(255,255,159,0.5);  }</style><title>Remote Files - RJM Programming - March, 2023</title><scr" . "ipt type='text/javascript'> function validateKey(evt) {  if (evt.keyCode == 187) { return false; } return true; } function ait() { document.getElementById('itval'),value+=String.fromCharCode(34); } function checkeq(evt) { if (evt.keyCode == 187) { evt.target.value+=String.fromCharCode(34); } } </scr" . "ipt></head><body onload=\" if (window.parent) { if (parent.document.getElementById('results')) {  parent.document.getElementById('results').innerHTML+=document.getElementById('dresults').innerHTML;  }   }\">${preblurb}<div id=dresults>${blurb}" . str_replace('<!--!<br-->','<br>',str_replace('</!','',lastjson($title))) . "</div>${postblurb}</body></html>";
exit;
?>