<?php
// journal.php
// Maintain a journal
// RJM Programming
// January, 2025

$aname="";
$adob="";
$asecret="";
$vsb="visible";
  
function server_remote_addr($howlong) {
    $rma = $_SERVER['REMOTE_ADDR'];
    if ($howlong > 0) {
      $endthing='';
      $fromstart=true;
      $charnum=1;
      $idea=str_replace('.','_',$rma);
      while (strlen($endthing) < $howlong) {
        $thisc=0;
        $lastn="0";
        if ($fromstart) {
          for ($i=0; $i<strlen($idea); $i++) {
           if (substr(substr($idea,$i),0,1) >= '0' && substr(substr($idea,$i),0,1) <= '9') {
             $thisc++;
             if ($thisc == $charnum) {  $lastn=substr(substr($idea,$i),0,1); }
           }
          }
          $fromstart=false;
        } else {
          for ($i=(-1 + strlen($idea)); $i>=0; $i--) {
           if (substr(substr($idea,$i),0,1) >= '0' && substr(substr($idea,$i),0,1) <= '9') {
             $thisc++;
             if ($thisc == $charnum) {  $lastn=substr(substr($idea,$i),0,1); }
           }
          }
          $fromstart=true;
          $charnum++;
        }
        $endthing.=$lastn;
      }
      return $endthing;
    }
    return str_replace('.','_',$rma);
}

if (isset($_POST['nearby']) && isset($_POST['wascont']) && isset($_POST['nowcont']) && isset($_POST['relfile'])) {
  if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_POST['relfile'])) . '.html'))) {
    $origcont=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_POST['relfile'])) . '.html'));
    $ocont=$origcont;
    $tsis=str_replace('+',' ',urldecode($_POST['nearby']));
    if (strpos($tsis, ' ') === false) {
    $tsis=base64_decode($_POST['nearby']);
    $wasc=base64_decode($_POST['wascont']);
    $nowc=base64_decode($_POST['nowcont']);
    } else {
    $wasc=str_replace('+',' ',urldecode($_POST['wascont']));
    $nowc=str_replace('+',' ',urldecode($_POST['nowcont']));
    }
    //file_put_contents('xa.xa', $tsis . "\n" . $wasc . "\n" . $nowc . "\n" . $origcont . "\n" . urlencode($wasc) . "\n" . urlencode($nowc) . "\n" . urlencode($origcont));
    if (strpos($origcont, $tsis) !== false) {
      $relcont=$tsis . explode($tsis, $origcont)[1];
            if (strpos($origcont, trim($relcont)) !== false) {
    //file_put_contents('xa.xa2z', $relcont . "\nvs\n" . $wasc);
            }
      //$relcont=explode($tsis, $origcont)[1];
    //file_put_contents('xa.xa2', $relcont . "\nvs\n" . $wasc);
    if (9 == 9) {
      if (strpos(trim($relcont), trim($wasc)) === false || (strpos($relcont, explode("\n",$wasc)[0]) !== false && strpos($relcont, $wasc) === false)) {
    //file_put_contents('xa.xa2g', $relcont . "\nvs\n" . $wasc);
        $wsc=''; //explode("\n",$wasc)[0];
    //file_put_contents('xa.xa2h', $relcont . "\nvs\n" . $wasc);
        $afterrel=explode($tsis . $wsc, $origcont)[-1 + sizeof(explode($tsis . $wsc, $origcont))]; //$relcont)[1];
    //file_put_contents('xa.xa2j', $afterrel);
        $tsl=strlen($tsis);
    //file_put_contents('xa.xa2k', $tsl);
        $tslws=explode(' ',$tsis);
    //file_put_contents('xa.xa2m', sizeof($tslws));
        $afs=explode("\n", $afterrel);
    //file_put_contents('xa.xa2n', sizeof($afs));
        $ndone=false;
        for ($jj=0; $jj<sizeof($afs); $jj++) {
          if (!$ndone && (strlen($tsl) != strlen($afs[$jj]) || sizeof($tslws) != sizeof(explode(' ',$afs[$jj])))) {
            $wsc.=$afs[$jj] . "\n";
          } else if (strlen($tsl) == strlen($afs[$jj]) && sizeof($tslws) == sizeof(explode(' ',$afs[$jj]))) {
            $ndone=true;
          }
        }
    //file_put_contents('xa.xa2p', $relcont . "\nvs\n" . $wasc);
        $wasc=trim($wsc);
    //file_put_contents('xa.xa2aa', $relcont . "\nvs\n" . $wasc);
      }
      }
      //if (strpos($relcont, explode("\n",$wasc)[0]) !== false) {
      if (strpos($origcont, trim($wasc)) !== false && strpos(trim($relcont), trim($wasc)) === false) {
        $relcont=$origcont;
      }
      if (strpos(trim($relcont), trim($wasc)) !== false) {
    //file_put_contents('xa.xa2a', $relcont);
        if (strpos($origcont, trim($wasc) . "\n") !== false && strpos($origcont, trim($relcont) . "\n") !== false) {
    //file_put_contents('xa.xa2y', $relcont);
        $origcont=str_replace(trim($relcont) . "\n", str_replace(trim($wasc) . "\n",trim($nowc) . "\n",trim($relcont) . "\n"), $origcont);
        } else {
        $origcont=str_replace(trim($relcont), str_replace(trim($wasc),trim($nowc),trim($relcont)), $origcont);
        }
            if (strpos($relcont, trim($wasc)) !== false) {
    //file_put_contents('xa.xa3z', $relcont . "\nvs\n" . $wasc);
            }
    //file_put_contents('xa.xa3', $relcont);
        if ($origcont != $ocont) {
    //file_put_contents('xa.xa4', $relcont);
         file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_POST['relfile'])) . '.html'), $origcont);
         echo "<html><body><p>Did change</p></body></html>";
         exit;
        }
      }
    }
  }
  echo "<html><body></body></html>";
  exit;
}

if ((isset($_GET['isname']) && isset($_GET['isdob']) && isset($_GET['issecret'])) || (isset($_POST['name']) && isset($_POST['dob']) && isset($_POST['snum']))) {
  $fcnt=0;
  $gcnt=-1;
  $fillins="";
  $fsuff="";
  $afnd='';
  $isdone=false;
  if (!$isdone && strlen($_POST['name']) > 0) {
    if (strlen($_POST['dob']) > 0 && strlen($_POST['snum']) > 0) {
      if (isset($_POST['posting']) && isset($_POST['timestamp'])) {
       if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_POST['name']))) . '-' . $_POST['dob'] . '-' . $_POST['snum'] . '.html')) {
        $sofar=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_POST['name']))) . '-' . $_POST['dob'] . '-' . $_POST['snum'] . '.html');
        file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_POST['name']))) . '-' . $_POST['dob'] . '-' . $_POST['snum'] . '.html', $sofar . "\n\n" . str_replace('+',' ',urldecode($_POST['timestamp'])) . "\n" . str_replace('+',' ',urldecode($_POST['posting'])));
        $fsuff=" if (1 == 1) { parent.document.getElementById('fjnamemore').value='" . explode('.',basename($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_POST['name']))) . '-' . $_POST['dob'] . '-' . $_POST['snum'] . '.html'))[0] . "'; parent.document.getElementById('subfjnamemore').click();  } else { parent.location.href='./journal.php?fjname=" . urlencode(explode('.',basename($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_POST['name']))) . '-' . $_POST['dob'] . '-' . $_POST['snum'] . '.html'))[0]) . "'; } "; 
        $fillins.=" var allbef=(('' + window.localStorage.getItem(windowbtoa('list_journal'))).replace(/^null/g,'').replace(/^undefined/g,'')), bef=(('' + window.localStorage.getItem(windowbtoa('unique_journal'))).replace(/^null/g,'').replace(/^undefined/g,'')), vsbef=windowbtoa('" . explode('.',basename($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_POST['name']))) . '-' . $_POST['dob'] . '-' . $_POST['snum'] . '.html'))[0] . "'); parent.document.getElementById('ysecret').value='" . $_POST['snum'] . "';  parent.document.getElementById('ysecret').disabled=true;  parent.document.getElementById('yname').disabled=true;   parent.document.getElementById('ydob').disabled=true; if (bef == '') {  window.localStorage.setItem(windowbtoa('unique_journal'), windowbtoa('" . explode('.',basename($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_POST['name']))) . '-' . $_POST['dob'] . '-' . $_POST['snum'] . '.html'))[0] . "'));  } else if (bef != vsbef) { if (allbef == '') {  window.localStorage.setItem(windowbtoa('list_journal'), (bef == '' ? '' : windowbtoa(windowatob(bef) + (',') + ('" . explode('.',basename($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_POST['name']))) . '-' . $_POST['dob'] . '-' . $_POST['snum'] . '.html'))[0] . "'))));  } else {     window.localStorage.setItem(windowbtoa('list_journal'), (allbef == '' ? '' : windowbtoa(windowatob(allbef) + (',') + ('" . explode('.',basename($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_POST['name']))) . '-' . $_POST['dob'] . '-' . $_POST['snum'] . '.html'))[0] . "'))));   }  } " . $fsuff . " ";
       }
   $jcont=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_POST['name']))) . '-' . $_POST['dob'] . '-' . $_POST['snum'] . '.html');
   $jtitle=explode('.',basename($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_POST['name']))) . '-' . $_POST['dob'] . '-' . $_POST['snum'] . '.html'))[0];
   $none="block";
   $open=" open";
   $doneanddusted=true;
      }
      $isdone=true;
    } 
  } else if (!$isdone && strlen($_GET['isname']) > 0) {
    if (strlen($_GET['isdob']) > 0 && strlen($_GET['issecret']) > 0) {
      $isdone=true;
    } else if (strlen($_GET['isdob']) > 0 && strlen($_GET['issecret']) == 0) {
        //file_put_contents('xx.xxx', $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_GET['isname']))) . '-' . $_GET['isdob'] . '-*.*');
      foreach (glob($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_GET['isname']))) . '-' . $_GET['isdob'] . '-*.*') as $fln) {
        $afnd=$fln;
        $fcnt++;
      }
      if ($fcnt == 1) {
        if (isset($_GET['fillif'])) { $fsuff=" if (1 == 1) { parent.document.getElementById('fjnamemore').value='" . explode('.',basename($afnd))[0] . "'; parent.document.getElementById('subfjnamemore').click();  } else {  parent.location.href='./journal.php?fjname=" . urlencode(explode('.',basename($afnd))[0]) . "'; } ";  }
        //file_put_contents('xx.x', $fsuff);
        $fillins.=" parent.document.getElementById('ysecret').value='" . explode('.', explode($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_GET['isname']))) . '-' . $_GET['isdob'] . '-', $fln)[1])[0] . "'; " . $fsuff . " ";
        //file_put_contents('xx.xx', $fillins);
      } else if ($fcnt == 0 && !isset($_GET['fillif'])) {
        $sug=server_remote_addr(6);
        if (!file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_GET['isname']))) . '-' . $_GET['isdob'] . '-' . $sug . '.html')) {
        $rand=$sug;
        } else {
        while ($gcnt != 0) {
          $gcnt=0;
          $rand=rand(100000, 999999);
          foreach (glob($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_GET['isname']))) . '-*-' . $rand . '.*') as $fln) {
           $gcnt++;
          }
        }
        }
        file_put_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_GET['isname']))) . '-' . $_GET['isdob'] . '-' . $rand . '.html', '');
        $fillins.=" var allbef=(('' + window.localStorage.getItem(windowbtoa('list_journal'))).replace(/^null/g,'').replace(/^undefined/g,'')), bef=(('' + window.localStorage.getItem(windowbtoa('unique_journal'))).replace(/^null/g,'').replace(/^undefined/g,'')), vsbef=windowbtoa('" . explode('.',basename($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_GET['isname']))) . '-' . $_GET['isdob'] . '-' . $rand . '.html'))[0] . "'); parent.document.getElementById('ysecret').value='" . $rand . "';  parent.document.getElementById('ysecret').disabled=true;  parent.document.getElementById('yname').disabled=true;   parent.document.getElementById('ydob').disabled=true; if (bef == '') {    window.localStorage.setItem(windowbtoa('unique_journal'), windowbtoa('" . explode('.',basename($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_GET['isname']))) . '-' . $_GET['isdob'] . '-' . $rand . '.html'))[0] . "'));  } else if (bef != vsbef) { if (allbef == '') {   window.localStorage.setItem(windowbtoa('list_journal'), (bef == '' ? '' : windowbtoa((windowatob(bef) + (',') + ('" . explode('.',basename($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_GET['isname']))) . '-' . $_GET['isdob'] . '-' . $rand . '.html'))[0] . "'))));  } else {    window.localStorage.setItem(windowbtoa('list_journal'), (allbef == '' ? '' : windowbtoa(windowatob(allbef) + (',') + ('" . explode('.',basename($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_GET['isname']))) . '-' . $_GET['isdob'] . '-' . $rand . '.html'))[0] . "'))));   }  }  ";
      }
    } else if (strlen($_GET['isdob']) == 0 && strlen($_GET['issecret']) > 0) {
       foreach (glob($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_GET['isname']))) . '-*-' . $_GET['issecret'] . '.*') as $fln) {
        $fcnt++;
        $afnd=$fln;
      }
      if ($fcnt == 1) {
        if (isset($_GET['fillif'])) { $fsuff=" if (1 == 1) { parent.document.getElementById('fjnamemore').value='" . explode('.',basename($afnd))[0] . "'; parent.document.getElementById('subfjnamemore').click();  } else {  parent.location.href='./journal.php?fjname=" . urlencode(explode('.',basename($afnd))[0]) . "'; } ";  }
        $fillins.=" parent.document.getElementById('ydob').value='" . explode('-', explode($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_GET['isname']))) . '-', $fln)[1])[0] . "'; " . $fsuff . " ";
      }
   } else if (strlen($_GET['isdob']) == 0 && strlen($_GET['issecret']) == 0) {
      foreach (glob($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_GET['isname']))) . '-*.*') as $fln) {
        $fcnt++;
        $afnd=$fln;
      }
      if ($fcnt == 1) {
        $fillins.=" parent.document.getElementById('ydob').value='" .    explode('-', explode($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_GET['isname']))) . '-', $fln)[1])[0] . "'; ";
        $fillins.=" parent.document.getElementById('ysecret').value='" . explode('.', explode($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_GET['isname']))) . '-' .explode('-', explode($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . str_replace(' ','_',str_replace('+',' ', urldecode($_GET['isname']))) . '-', $fln)[1])[0] . '-', $fln)[1])[0] . "'; ";
      }
    }
  }
  if (!$isdone && strlen($_GET['isdob']) > 0) {
    if (strlen($_GET['isname']) > 0 && strlen($_GET['issecret']) > 0) {
      $isdone=true;
    }
  }
  if (!$isdone && strlen($_GET['issecret']) > 0) {
    if (strlen($_GET['isname']) > 0 && strlen($_GET['isdob']) > 0) {
      $isdone=true;
    }
  }
  echo "<html><head><meta charset=UTF-8/><scr" . "ipt type=text/javascript>  
  
/**
 * Convert a string to HTML entities ... Thanks to https://zditect.com/code/javascript/easy-solution-to-encode-html-entities-in-javascript.html
 */
String.prototype.toHtmlEntities = function() {
    return this.replace(/./gm, function(s) {
        return (s.match(/[a-z0-9" . "\\" . "s]+/i)) ? s : '&#' + s.charCodeAt(0) + ';';
    });
};

   function windowatob(astr) { // decodes
    if (astr.indexOf('_') != -1 || astr.indexOf('-') != -1) {
      //alert(astr + ' decodes as ' + window.atob(astr));
      return astr;
    }
    //alert(astr + ' ' + window.atob(window.atob(astr)));
    var atb='';
    try {
      atb=window.atob(astr);
    } catch(fhyg) {
      if (1 == 4) { alert('Bad ' + astr); }
    }
    if (atb.indexOf('_') == -1 && atb.indexOf('-') == -1) { 
      try {
        var xcv=window.atob(atb);
      } catch(hyg) {
        if (1 == 4) { alert('bad ' + atb); }
        atb=astr;
      }
      return window.atob(atb); 
    }
    return window.atob(astr);
  }
  
  function windowbtoax(astr) { 
      return astr;
  }
  
  function windowbtoa(astr) { // encodes
    if ((astr.indexOf('_') != -1 || astr.indexOf('-') != -1) && astr != 'list_journal' && astr != 'unique_journal' && 2 == 5) {
      //alert(astr + ' encodes as ' + window.btoa(astr));
      return astr;
    }
    return window.btoa(astr);
  }
</scr" . "ipt></head><body onload=\"" . $fillins . "\"></body></html>";
  exit;
}

$none="none";
$jtitle="";
$jcont="";
$suffnum="";
if (isset($_GET['snum'])) {
  $suffnum=$_GET['snum'];
} else if (isset($_POST['snum'])) {
  $suffnum=$_POST['snum'];
} 
$dob="";
$yname="";
$open="";
$doneanddusted=false;

if (isset($_GET['fjname'])) {
  if (strlen($_GET['fjname']) > 0) {
  if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['fjname']))))) {
   $jcont=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['fjname']))));
   $jtitle=explode('.',basename(str_replace('+',' ',urldecode($_GET['fjname']))))[0];
   $none="block";
   $open=" open";
   $doneanddusted=true;
   if (sizeof(explode('-',$jtitle)) == 3) {
   $aname=str_replace('_',' ',explode('-', $jtitle)[0]);
   $adob=str_replace('_',' ',explode('-', $jtitle)[1]);
   $asecret=explode('.',str_replace('_',' ',explode('-', $jtitle)[2]))[0];
   }
  } else if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['fjname'])) . ".html"))) {
   $jcont=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['fjname'])) . ".html"));
   $jtitle=basename(str_replace('+',' ',urldecode($_GET['fjname'])));
   $none="block";
   $open=" open";
   $doneanddusted=true;
   if (sizeof(explode('-',$jtitle)) == 3) {
   $aname=str_replace('_',' ',explode('-', $jtitle)[0]);
   $adob=str_replace('_',' ',explode('-', $jtitle)[1]);
   $asecret=explode('.',str_replace('_',' ',explode('-', $jtitle)[2]))[0];
   }
  }
  }
}


if (isset($_POST['fjname'])) {
  if (strlen($_POST['fjname']) > 0) {
  if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_POST['fjname']))))) {
   $jcont=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_POST['fjname']))));
   $jtitle=explode('.',basename(str_replace('+',' ',urldecode($_POST['fjname']))))[0];
   $none="block";
   $open=" open";
   $vsb="hidden";   
   $doneanddusted=true;
   if (sizeof(explode('-',$jtitle)) == 3) {
   $aname=str_replace('_',' ',explode('-', $jtitle)[0]);
   $adob=str_replace('_',' ',explode('-', $jtitle)[1]);
   $asecret=explode('.',str_replace('_',' ',explode('-', $jtitle)[2]))[0];
   }
  } else if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_POST['fjname'])) . ".html"))) {
   $jcont=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_POST['fjname'])) . ".html"));
   $jtitle=basename(str_replace('+',' ',urldecode($_POST['fjname'])));
   $none="block";
   $open=" open";
   $vsb="hidden";   
   $doneanddusted=true;
   if (sizeof(explode('-',$jtitle)) == 3) {
   $aname=str_replace('_',' ',explode('-', $jtitle)[0]);
   $adob=str_replace('_',' ',explode('-', $jtitle)[1]);
   $asecret=explode('.',str_replace('_',' ',explode('-', $jtitle)[2]))[0];
   }
  }
  }
}

if (!$doneanddusted) {
if (isset($_GET['name']) && isset($_GET['dob'])) {
  if ($suffnum == '') {
  } else {
  }

} else if (isset($_GET['name'])) {

} else if (isset($_GET['dob'])) {
} else if (isset($_GET['fjname'])) {
  if (strlen($_GET['fjname']) > 0) {
  if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['fjname']))))) {
   $jcont=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['fjname']))));
   $jtitle=explode('.',basename(str_replace('+',' ',urldecode($_GET['fjname']))))[0];
   $none="block";
   $open=" open";
  } else if (file_exists($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['fjname'])) . ".html"))) {
   $jcont=file_get_contents($_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . basename(str_replace('+',' ',urldecode($_GET['fjname'])) . ".html"));
   $jtitle=basename(str_replace('+',' ',urldecode($_GET['fjname'])));
   $none="block";
   $open=" open";
  }
  }
}
}

echo "<html>
<head>
<title>Personal Journal - RJM Programming - January, 2026</title>
<meta charset=UTF-8/>
<style>
  button { color: blue; }
  input[type=\"submit\"] { color: blue; }
</style>
<scr" . "ipt type=text/javascript>

  var thissuff='';
  var nextsuff='2';
  var xfill='';
  var acontod=null, divelem=null, gtao=null;
  var startid='s0', endid='s';
  var thissid='';
  var canedit=false;
  var contprefix='', contsuffix='';
  var notfirsttime=true;
  var spanolast=null;
  

/**
 * Convert a string to HTML entities ... Thanks to https://zditect.com/code/javascript/easy-solution-to-encode-html-entities-in-javascript.html
 */
String.prototype.toHtmlEntities = function() {
    return this.replace(/./gm, function(s) {
        return (s.match(/[a-z0-9" . "\\" . "s]+/i)) ? s : '&#' + s.charCodeAt(0) + ';';
    });
};

  
  function setcanedit(tow) {
    if (tow) {
      contprefix=('<span>').replace('<span>','');
      contsuffix='</span>';
    } else {
      contprefix='';
      contsuffix='';
    }
    canedit=tow;
  }
  
  function windowatob(astr) { // decodes
    if (astr.indexOf('_') != -1 || astr.indexOf('-') != -1) {
      //alert(astr + ' decodes as ' + window.atob(astr));
      return astr;
    }
    //alert(astr + ' ' + window.atob(window.atob(astr)));
    var atb='';
    try {
      atb=window.atob(astr);
    } catch(fhyg) {
      if (1 == 4) { alert('Bad ' + astr); }
    }
    if (atb.indexOf('_') == -1 && atb.indexOf('-') == -1) { 
      try {
        var xcv=window.atob(atb);
      } catch(hyg) {
        if (1 == 4) { alert('bad ' + atb); }
        atb=astr;
      }
      return window.atob(atb); 
    }
    return window.atob(astr);
  }
  
  function windowbtoax(astr) { 
      return astr;
  }
  
  function windowbtoa(astr) { // encodes
    if ((astr.indexOf('_') != -1 || astr.indexOf('-') != -1) && astr != 'list_journal' && astr != 'unique_journal' && 2 == 5) {
      //alert(astr + ' encodes as ' + window.btoa(astr));
      return astr;
    }
    return window.btoa(astr);
  }

  function checkls() {
    document.getElementById('ytimestamp').value=('' + new Date());
    document.getElementById('posting').placeholder='Journal Entry for ' + document.getElementById('ytimestamp').value + ' goes here ...';
    var allbef=(('' + window.localStorage.getItem(windowbtoa('list_journal'))).replace(/^null/g,'').replace(/^undefined/g,''));
    var bef=(('' + window.localStorage.getItem(windowbtoa('unique_journal'))).replace(/^null/g,'').replace(/^undefined/g,''));
    if (allbef != '') {
      document.getElementById('divlist').style.display='block';
      document.getElementById('divlist').innerHTML=\"<select style=background-color:yellow; id=mysel onchange=gto(this);><option value=''>Optionally select a Journal of interest</option></select>\";
//alert('0:' + windowatob(allbef));
      var ljs=windowatob(allbef).split(',');
      for (var jls=0; jls<ljs.length; jls++) {
      if (document.getElementById('mysel').innerHTML.indexOf('>' + ljs[jls].split('-')[0].replace(/\_/g,' ') + '</option>') == -1) {
        document.getElementById('mysel').innerHTML+='<option value=' + ljs[jls] + '>' + ljs[jls].split('-')[0].replace(/\_/g,' ') + '</option>';
      }
      }
    } else if (bef != '') {
      document.getElementById('divlist').style.display='block';
      document.getElementById('uniquej').style.display='block';
      document.getElementById('uniquej').innerHTML='Display Default Journal for ' + windowatob(bef).split('-')[0].replace(/\_/g,' ');
      document.getElementById('uniquej').title=windowatob(bef).split('-')[0].replace(/\_/g,' ');
    }
    
    setTimeout(function(){
      if (document.getElementById('sc').value == document.getElementById('ysecret').value || document.getElementById('sc').value == document.getElementById('ysecret').placeholder) {
       canedit=true;
       contprefix=('<span>').replace('<span>','');
       contsuffix='</span>';
      }
    }, 3000);
  }
  
  function getu() {
    document.getElementById('yname').value=document.getElementById('uniquej').title;
    setTimeout(function(){
    var eight=8;
    var allbef=(('' + window.localStorage.getItem(windowbtoa('list_journal'))).replace(/^null/g,'').replace(/^undefined/g,''));
    var bef=(('' + window.localStorage.getItem(windowbtoa('unique_journal'))).replace(/^null/g,'').replace(/^undefined/g,''));
    var huh=prompt('Please enter relevant 8 digit date of birth ( eg, 20041231 ) or 6 digit secret number', '');
    if (huh == null) { huh=''; }
    if (eval('' + huh.length) == 8 && (windowatob(bef) + windowatob(allbef)).indexOf(document.getElementById('yname').value.replace(/\ /g,'_') + '-' + huh + '-' + document.getElementById('sc').value) == -1 && (windowatob(bef) + windowatob(allbef)).indexOf(document.getElementById('yname').value.replace(/\ /g,'_') + '-' + huh + '-') != -1) {
      eight=-1;
      huh=prompt('Please enter 6 digit secret number', '');
      if (huh == null) { huh=''; }
    }
    if (eval('' + huh.length) == eight) {
      xfill='&fillif=ok';
      document.getElementById('ydob').value=huh;
      validatename(document.getElementById('yname'));
      xfill='';
    } else if (eval('' + huh.length) == 6) {
      xfill='&fillif=ok';
      document.getElementById('ysecret').value=huh;
      validatename(document.getElementById('yname'));
      xfill='';
    }
    }, 1000);
  }
  
  function gto(osel) {
    if (osel.value.trim() != '') {
    document.getElementById('yname').value=osel.value.split('-')[0].replace(/\_/g,' ')
    setTimeout(function(){
    var eight=8;
    var allbef=(('' + window.localStorage.getItem(windowbtoa('list_journal'))).replace(/^null/g,'').replace(/^undefined/g,''));
    var bef=(('' + window.localStorage.getItem(windowbtoa('unique_journal'))).replace(/^null/g,'').replace(/^undefined/g,''));
    var huh=prompt('Please enter relevant 8 digit date of birth ( eg, 20041231 ) or 6 digit secret number', '');
    if (huh == null) { huh=''; }
    if (eval('' + huh.length) == 8 && (windowatob(bef) + windowatob(allbef)).indexOf(document.getElementById('yname').value.replace(/\ /g,'_') + '-' + huh + '-' + document.getElementById('sc').value) == -1 && (windowatob(bef) + windowatob(allbef)).indexOf(document.getElementById('yname').value.replace(/\ /g,'_') + '-' + huh + '-') != -1) {
      eight=-1;
      huh=prompt('Please enter 6 digit secret number', '');
      if (huh == null) { huh=''; }
    }
    if (eval('' + huh.length) == eight) {
      xfill='&fillif=ok';
      document.getElementById('ydob').value=huh;
      validatename(document.getElementById('yname'));
      xfill='';
    } else if (eval('' + huh.length) == 6) {
      xfill='&fillif=ok';
      document.getElementById('ysecret').value=huh;
      validatename(document.getElementById('yname'));
      xfill='';
    }
    }, 1000);
    }
  }
  
  function preform() {
    document.getElementById('yname').value=document.getElementById('yname').value.replace(/\-/g,' ').replace(/\./g,' ').replace(/\,/g,' ').replace(/\'/g,'`').replace(/^\"/g,'').replace(/\"$/g,'').replace(/\"/g,'`');
    if (document.getElementById('yname').placeholder != '' && '" . $aname . "' != '' && document.getElementById('yname').value == '') {
      document.getElementById('yname').value=document.getElementById('yname').placeholder;
    }
    if (document.getElementById('ydob').placeholder != '' && '" . $adob . "' != '' && document.getElementById('ydob').value == '') {
      document.getElementById('ydob').value=document.getElementById('ydob').placeholder;
    }
    if (document.getElementById('ysecret').placeholder != '' && '" . $asecret . "' != '' && document.getElementById('ysecret').value == '') {
      document.getElementById('ysecret').value=document.getElementById('ysecret').placeholder;
    }
  }
  
  function afterscrutiny() {
    document.getElementById('yname').value=document.getElementById('yname').value.replace(/\-/g,' ').replace(/\./g,' ').replace(/\,/g,' ').replace(/\'/g,'`').replace(/^\"/g,'').replace(/\"$/g,'').replace(/\"/g,'`');
    if (document.getElementById('yname').placeholder != '' && '" . $aname . "' != '' && document.getElementById('yname').value == '') {
      document.getElementById('yname').value=document.getElementById('yname').placeholder;
    }
    if (document.getElementById('ydob').placeholder != '' && '" . $adob . "' != '' && document.getElementById('ydob').value == '') {
      document.getElementById('ydob').value=document.getElementById('ydob').placeholder;
    }
    if (document.getElementById('ysecret').placeholder != '' && '" . $asecret . "' != '' && document.getElementById('ysecret').value == '') {
      document.getElementById('ysecret').value=document.getElementById('ysecret').placeholder;
    }
    
    if (eval('' + document.getElementById('posting').value).length > 5000) {
      alert('Sorry, please make journal entry smaller ... up to 5000 characters');
      return false;
    }
  
    return true;
  }
  
  function domore() {
  }
  
  function validatename(otb) {
    document.getElementById('yname').value=document.getElementById('yname').value.replace(/\-/g,' ').replace(/\./g,' ').replace(/\,/g,' ').replace(/\'/g,'`').replace(/^\"/g,'').replace(/\"$/g,'').replace(/\"/g,'`');
    document.getElementById('helpout').src='./journal.php?isname=' + encodeURIComponent(otb.value.replace(/\ /g,'_')) + '&isdob=' + encodeURIComponent(document.getElementById('ydob').value) + '&issecret=' + encodeURIComponent(document.getElementById('ysecret').value) + xfill;
  }
  
  function validatedob(otb) {
    document.getElementById('helpout').src='./journal.php?isdob=' + encodeURIComponent(otb.value.replace(/\ /g,'_')) + '&isname=' + encodeURIComponent(document.getElementById('yname').value.replace(/\ /g,'_')) + '&issecret=' + encodeURIComponent(document.getElementById('ysecret').value) + xfill;
  }
  
  function validatesecret(otb) {
    document.getElementById('helpout').src='./journal.php?issecret=' + encodeURIComponent(otb.value.replace(/\ /g,'_')) + '&isdob=' + encodeURIComponent(document.getElementById('ydob').value) + '&isname=' + encodeURIComponent(document.getElementById('yname').value.replace(/\ /g,'_')) + xfill;
  }
  
  function wbt(taow,tao) {
    //alert(tao.value);
    if (acontod && tao) {
     if (!divelem) {
     document.getElementById('helpout').style.backgroundColor='yellow';
     document.getElementById('dcont').style.backgroundColor='yellow';
     divelem = acontod.getElementById('djc');
     gtao=tao;
     var recto = tao.getBoundingClientRect();
     if (divelem) { // thanks to ideas off http://stackoverflow.com/questions/12266320/copy-div-content-to-textarea-or-text-with-the-same-font-family-style
      divelem.style.display='flex';
    //divelem.style.alignItems='flex-end';
      divelem.style.overflowY='scroll';
      //divelem.style.flexFlow='column nowrap';
      divelem.style.flexDirection='column-reverse';
      divelem.style.fontFamily = window.getComputedStyle(tao,null).fontFamily || tao.style.fontFamily || tao.currentStyle.getCurrentProperty('font-family');
      divelem.style.fontSize = window.getComputedStyle(tao,null).fontSize || tao.style.fontSize || tao.currentStyle.getCurrentProperty('font-size');
      divelem.style.border = window.getComputedStyle(tao,null).border || tao.style.border || tao.currentStyle.getCurrentProperty('border');
      divelem.style.padding = window.getComputedStyle(tao,null).padding || tao.style.padding || tao.currentStyle.getCurrentProperty('padding');
      divelem.style.margin = window.getComputedStyle(tao,null).margin || tao.style.margin || tao.currentStyle.getCurrentProperty('margin');
      divelem.style.overflow = window.getComputedStyle(tao,null).overflow || tao.style.overflow || tao.currentStyle.getCurrentProperty('overflow');
      divelem.style.position='absolute';
      divelem.style.left='' + recto.left + 'px';
      divelem.style.width='' + eval(0 + recto.width) + 'px';
      divelem.style.height='' + recto.height + 'px';
      divelem.style.top='' + eval(-12 + recto.top) + 'px';
      //alert('' + recto.top + ' ' + recto.height + ' ' + ' ... ' + 'eval(-12 + recto.top + recto.height)=' + eval(-12 + recto.top + recto.height));
      //divelem.style.bottom='' + eval(-12 + recto.top + recto.height) + 'px';
      divelem.style.zIndex='999';
      divelem.scrollTop=divelem.scrollHeight;
      tao.style.color='transparent';
     }
     }
     var taovalue=tao.value.replace(/\</g,'&lt;').replace(/\>/g,'&gt;');
     while (taovalue.indexOf(String.fromCharCode(10)) != -1) {
      taovalue=taovalue.replace(String.fromCharCode(10),'<br>');
     }
     acontod.getElementById('djc').innerHTML='<div id=indiv title=\"Journal\" style=\"text-shadow:-0.5px 0.5px 0.5px #ff0000;background: linear-gradient(to right, #e0eafc, #ffffff);margin-top: auto !important;\">' + massage(taovalue) + '</div>';
     var sps=acontod.getElementsByTagName('span');
     for (var isps=0; isps<sps.length; isps++) {
       if (('' + sps[isps].className) == 'sed') {
         sps[isps].setAttribute('data-oit', encodeURIComponent(sps[isps].innerText.toHtmlEntities()).replace(/\%0A$/g,''));
       }
     }
    }
    return '';
  }
  
  function documentgetElementById(insid) {
    if (acontod.getElementById(insid)) {
     thissid=insid;
     acontod.getElementById(insid).style.backgroundColor='#daddfa';
     setTimeout(function(){ acontod.getElementById(thissid).style.backgroundColor='#fadadd'; }, 1500); 
    }
    return acontod.getElementById(insid);
  }
  
  function sedit(spano) {
    if (spano.innerText != decodeURIComponent(('' + spano.getAttribute('data-oit')).replace(/^null/g,'').replace(/^undefined/g,''))) {
      try {
      document.getElementById('nearby').value=window.btoa(('' + spano.getAttribute('data-ts')).replace(/^null/g,'').replace(/^undefined/g,'').replace(/\_/g, ' '));
      } catch(hy) {
      document.getElementById('nearby').value=('' + spano.getAttribute('data-ts')).replace(/^null/g,'').replace(/^undefined/g,'').replace(/\_/g, ' ');
      }
      try {
      document.getElementById('wascont').value=window.btoa(decodeURIComponent(('' + spano.getAttribute('data-oit')).replace(/^null/g,'').replace(/^undefined/g,'')));
  //alert('0:' + document.getElementById('wascont').value);
      } catch(hdfy) {
      document.getElementById('wascont').value=decodeURIComponent(('' + spano.getAttribute('data-oit')).replace(/^null/g,'').replace(/^undefined/g,''));
  //alert('10:' + document.getElementById('wascont').value);
      }
      spano.setAttribute('data-oit', encodeURIComponent(spano.innerText));
      try {
      document.getElementById('nowcont').value=window.btoa(spano.innerText);
      } catch(hdy) {
      document.getElementById('nowcont').value=spano.innerText;
      }
      spanolast=spano;
      document.getElementById('editsub').click();
    }
  }
  
  function massage(tv) {
    var tscnt=0, itv=0;
    var tlls=tv.split('<br>');
    if (document.getElementById('sc').value == document.getElementById('ysecret').value || document.getElementById('sc').value == document.getElementById('ysecret').placeholder) {
       canedit=true;
       contprefix=('<span>').replace('<span>','');
       contsuffix='</span>';
    } else {
       canedit=false;
       contprefix=('<span>').replace('<span>','');
       contsuffix='';
    }
    var proposedcs=contsuffix.replace('</span>','<span>');
    var tslist=[], selis='<select style=background-color:#fadadd; id=thesel onchange=\"if (this.value.length > 0) {  parent.documentgetElementById(this.value).scrollIntoView();  } this.value=this.getAttribute(' + \"'data-orv'\" + ');\"><option value=></option></select>';
    for (itv=0; itv<tlls.length; itv++) {
      if (tlls[itv].indexOf(' GMT') != -1 && eval('' + tlls[itv].split(':').length) >= 3) {
        tslist.push(tlls[itv]);
        selis=selis.replace('</select>', '<option value=s' + tscnt + '>' + tlls[itv].replace(/\ /g,'  ') + '</option></select>');
        parent.endid='s' + tscnt;
        tscnt++;
      }
    }
    tscnt=0;
    var bprev='<button onclick=\"parent.documentgetElementById(' + \"'s'\" + ').scrollIntoView();\">&#x2196;&#xFE0F;</button>&nbsp;';
    var baftr='<button onclick=\"parent.documentgetElementById(' + \"'s'\" + ').scrollIntoView();\">&#x2198;&#xFE0F;</button>';
    for (itv=0; itv<tlls.length; itv++) {
      if (tlls[itv].indexOf(' GMT') != -1 && eval('' + tlls[itv].split(':').length) >= 3) {
        if ( tv.indexOf('<br>' + tlls[itv] + '<br>') != -1 && canedit) {
        if (proposedcs != '') { contprefix=proposedcs; }
        proposedcs='';
        tv=tv.replace('<br>' + tlls[itv] + '<br>', contsuffix + '<br><button onclick=\"parent.documentgetElementById(parent.startid).scrollIntoView();\">&#x2196;&#xFE0F; &#x2196;&#xFE0F;</button>&nbsp;' + bprev.replace('s',('s' + eval(-1 + tscnt)).replace('s-1','s0')) + selis.replace('thesel', 's' + tscnt + ' data-orv=s' + tscnt).replace('>' +  tlls[itv].replace(/\ /g,'  ') + '<', ' selected>' + tlls[itv].replace(/\ /g,'  ') + '<').replace('></', \"''>\" + (tlls[itv].replace(/\ /g,'  ') == '' ? tlls[itv].replace(/\ /g,'  ') : 'Journal timestamps ...') + '</') + '&nbsp;' + baftr.replace('s',('s' + eval(1 + tscnt))) + '&nbsp;<button onclick=\"parent.documentgetElementById(parent.endid).scrollIntoView();\">&#x2198;&#xFE0F; &#x2198;&#xFE0F;</button>' + '<br>' + contsuffix.replace('</span>', '<span class=sed data-ts=' + tlls[itv].replace(/\ /g,'_') + ' id=t' + tscnt + ' onblur=parent.sedit(this); contenteditable=true>'));
        } else if (tv.indexOf(tlls[itv] + '<br>') != -1 && canedit) {
        tv=tv.replace(tlls[itv] + '<br>', '<button onclick=\"parent.documentgetElementById(parent.startid).scrollIntoView();\">&#x2196;&#xFE0F; &#x2196;&#xFE0F;</button>&nbsp;' + bprev.replace('s',('s' + eval(-1 + tscnt)).replace('s-1','s0')) + selis.replace('thesel', 's' + tscnt + ' data-orv=s' + tscnt).replace('>' +  tlls[itv].replace(/\ /g,'  ') + '<', ' selected>' + tlls[itv].replace(/\ /g,'  ') + '<').replace('></', \"''>\" + (tlls[itv].replace(/\ /g,'  ') == '' ? tlls[itv].replace(/\ /g,'  ') : 'Journal timestamps ...') + '</') + '&nbsp;' + baftr.replace('s',('s' + eval(1 + tscnt))) + '&nbsp;<button onclick=\"parent.documentgetElementById(parent.endid).scrollIntoView();\">&#x2198;&#xFE0F; &#x2198;&#xFE0F;</button>' + '<br>' + contsuffix.replace('</span>', '<span class=sed data-ts=' + tlls[itv].replace(/\ /g,'_') + ' id=t' + tscnt + ' onblur=parent.sedit(this); contenteditable=true>'));
        proposedcs='';
        } else if (tv.indexOf('<br>' + tlls[itv]) != -1 && canedit) {
        if (proposedcs != '') { contprefix=proposedcs; }
        proposedcs='';
        tv=tv.replace('<br>' + tlls[itv], '<br>', contsuffix + '<br><button onclick=\"parent.documentgetElementById(parent.startid).scrollIntoView();\">&#x2196;&#xFE0F; &#x2196;&#xFE0F;</button>&nbsp;' + bprev.replace('s',('s' + eval(-1 + tscnt)).replace('s-1','s0')) + selis.replace('thesel', 's' + tscnt + ' data-orv=s' + tscnt).replace('>' +  tlls[itv].replace(/\ /g,'  ') + '<', ' selected>' + tlls[itv].replace(/\ /g,'  ') + '<').replace('></', \"''>\" + (tlls[itv].replace(/\ /g,'  ') == '' ? tlls[itv].replace(/\ /g,'  ') : 'Journal timestamps ...') + '</') + '&nbsp;' + baftr.replace('s',('s' + eval(1 + tscnt))) + '&nbsp;<button onclick=\"parent.documentgetElementById(parent.endid).scrollIntoView();\">&#x2198;&#xFE0F; &#x2198;&#xFE0F;</button>' + '' + contsuffix.replace('</span>', '<span class=sed data-ts=' + tlls[itv].replace(/\ /g,'_') + ' id=t' + tscnt + ' onblur=parent.sedit(this); contenteditable=true>'));
        proposedcs='';
        } else {
        tv=tv.replace(tlls[itv], '<button onclick=\"parent.documentgetElementById(parent.startid).scrollIntoView();\">&#x2196;&#xFE0F; &#x2196;&#xFE0F;</button>&nbsp;' + bprev.replace('s',('s' + eval(-1 + tscnt)).replace('s-1','s0')) + selis.replace('thesel', 's' + tscnt + ' data-orv=s' + tscnt).replace('>' +  tlls[itv].replace(/\ /g,'  ') + '<', ' selected>' + tlls[itv].replace(/\ /g,'  ') + '<').replace('></', \"''>\" + (tlls[itv].replace(/\ /g,'  ') == '' ? tlls[itv].replace(/\ /g,'  ') : 'Journal timestamps ...') + '</') + '&nbsp;' + baftr.replace('s',('s' + eval(1 + tscnt))) + '&nbsp;<button onclick=\"parent.documentgetElementById(parent.endid).scrollIntoView();\">&#x2198;&#xFE0F; &#x2198;&#xFE0F;</button>');
        proposedcs='';
        }
        tscnt++;
      }
    }
    return contprefix + tv + contsuffix;
  }
  
  function rez(ota) {
     if (divelem && ota == gtao) { // thanks to ideas off http://stackoverflow.com/questions/12266320/copy-div-content-to-textarea-or-text-with-the-same-font-family-style
//alert(1);
      var recto = gtao.getBoundingClientRect();
      var jrecto = document.getElementById('jcont').getBoundingClientRect();
      var drecto = document.getElementById('dcont').getBoundingClientRect();
//alert(12);
//alert(31);
      if (eval('' + recto.width) > eval('' + drecto.width)) {
//alert(31);
        document.getElementById('dcont').style.width='' + eval(30 + eval('' + recto.width)) + 'px';
      }
       if (eval('' + recto.height) > eval('' + drecto.height)) {
//alert(31);
        document.getElementById('dcont').style.height='' + eval(30 + eval('' + recto.height)) + 'px';
      }
      if (eval('' + recto.width) > eval('' + jrecto.width)) {
//alert(41);
        document.getElementById('jcont').style.width='' + eval(20 + eval('' + recto.width)) + 'px';
      }
      if (eval('' + recto.height) > eval('' + jrecto.height)) {
//alert(41);
        document.getElementById('jcont').style.height='' + eval(20 + eval('' + recto.height)) + 'px';
      }
      divelem.style.left='' + recto.left + 'px';
//alert(41);
      divelem.style.width='' + eval(0 + recto.width) + 'px';
//alert(51);
      divelem.style.height='' + recto.height + 'px';
//alert(61);
      //divelem.style.top='' + eval(-12 + recto.top) + 'px';
      divelem.style.bottom='' + eval(-12 + recto.top + recto.height) + 'px';
      divelem.style.zIndex='999';
//alert(71);
      gtao.style.color='transparent';
//alert(81);
     }
  }
  
  function analtwo(vorh) {
    if (document.getElementById('vspan')) {
      document.getElementById('vspan').style.visibility=vorh;
    }
    return vorh;
  }
  
  function anal(vorh) {
    var lstf='';
    if (vorh.toLowerCase() == 'hidden' && document.getElementById('scont')) {
      if (document.getElementById('scont').innerHTML.indexOf('-') != -1) {
        lstf=document.getElementById('scont').innerHTML.split('-')[eval(-1 + document.getElementById('scont').innerHTML.split('-').length)];
        document.getElementById('scont').innerHTML=(document.getElementById('scont').innerHTML + '~').split('-' + lstf + '~')[0] + '-<span style=visibility:hidden; id=vspan>' + lstf + '</span>';
      }
    }
    return vorh;
  }

</scr" . "ipt>
</head>
<body onload=checkls();>
<table style=width:100%;><tr><td>
<details id=dcont style=width:98%;display:" . $none . ";" . $open . "><summary id=scont>" . $jtitle . "</summary> 
<iframe onload=\"acontod = (this.contentWindow || this.contentDocument);  if (acontod != null) {  if (acontod.document) { acontod = acontod.document; } } setTimeout(function(){ window.wbt(acontod,acontod.getElementById('jc'));  acontod.getElementById('jc').scrollTop=acontod.getElementById('jc').scrollHeight; }, 2000);\" frameborder=1 style='display:" . $none . ";width:98%;height:350px;' id=jcont name=jcont srcdoc=\"" . ($jcont == '' ? $jcont : '<html><head><meta charset=UTF-8 /><style> button { background-color:lightgreen; } </style></head><body><textarea onmousemove=parent.rez(this); id=jc style=width:98%;height:320px;background-color:#f0f0f0;>' . str_replace('"','&#34;',str_replace('>','&gt;',str_replace('<','&lt;',$jcont))) . '</textarea><div id=djc onmousemove=parent.rez(this);></div></body></html>') . "\"></iframe>
</details></td><td style='vertical-align:top;width:20%;background-color:#f5f5f5;'>
<h1>Journal</h1>
<h3>RJM Programming - February, 2026</h3>
<div id=divlist style=display:none;><button style=display:none;background-color:yellow; id=uniquej onclick=getu();></button></div>
</td></tr></table>
<br>
<hr>
<br>
<form style=background-color:#f9f9f9; onsubmit='return afterscrutiny();' action='./journal.php' method=POST target=jcont><input type=hidden name=fjname id=fjname value=''></input>
<input onfocus=\"document.getElementById('ysecret').style.visibility=analtwo('visible');\" style=background-color:lightgreen;width:30%; pattern='[^\.\,\-]+' onblur='validatename(this);' type=text id=yname name=name title='Journal Owner Name' placeholder='" . ($aname != '' ? $aname : 'Journal Owner Name') . "' value='' style=width:40%></input><br>
<input onfocus=\"document.getElementById('ysecret').style.visibility=analtwo('visible');\" style=background-color:lightgreen;width:30%; onblur='validatedob(this);' type=text pattern='[0-9]{8}' min=19700101 step=1 id=ydob name=dob title='Journal Owner Date of Birth eg. 20210112' placeholder='" . ($adob != '' ? $adob : 'Journal Owner Date of Birth eg. 20210112') . "' value='' style=width:40% required></input>&nbsp;&nbsp;<input type=submit value='Post to Journal' style=background-color:yellow; required></input><br>
<input style=background-color:lightgreen;width:30%;visibility:visible; onblur='validatesecret(this);' type=text pattern='[0-9]{6}' id=ysecret name=snum title='Journal Owner Secret 6 digit Number' placeholder='" . ($asecret != '' ? $asecret : 'Journal Owner Secret 6 digit Number') . "' value='' style=width:40% required></input><br>
<hr>
<input type=text id=ytimestamp name=timestamp placeholder='Journal Entry Timestamp' value='' style=width:40%;background-color:lightblue;></input><br><br>
<textarea oninput=\"if (eval('' + this.value.length) > eval('' + this.maxlength)) { alert('Content will be truncated to ' + this.maxlength + ' characters.');  }\" maxlength=5000 onblur='preform();' name=posting placeholder='' id=posting value='' style=width:80%;background-color:lightblue; rows=5></textarea>&nbsp;&nbsp;<button id=plus onclick=domore(); style=background-color:lightgreen;display:none;>+</button>
<div id=andmore></div>
</form>
<input type=hidden id=sc value='" . server_remote_addr(6) . "'></input>
<iframe onload=\"setTimeout(function(){ document.getElementById('ysecret').style.visibility=anal('" . $vsb . "'); }, 20000);\" src='./journal.php' id=helpout style='display:none;'></iframe>
<form style=display:none; action='./journal.php' method=POST target=_top><input type=hidden name=fjname id=fjnamemore value=''></input><input type=submit id=subfjnamemore value='Submit' style='display:none;'></input></form>
<form id=editf style=display:none; action='./journal.php' method=POST target=jjcont>
<input type=hidden name=nearby id=nearby value=''></input>
<input type=hidden name=wascont id=wascont value=''></input>
<input type=hidden name=nowcont id=nowcont value=''></input>
<input type=hidden name=relfile id=relfile value='" . $jtitle . "'></input>
<input type=submit id=editsub style=display:none; value='Submit'></input>
</form>
<iframe onload=\"if (!notfirsttime) { if (4 == 5) { setTimeout(function(){ location.href='./journal.php?fjname=" . $jtitle . "'; }, 20000); } } notfirsttime=false;\" src='/About_Us.html' id=jjcont name=jjcont style='display:none;'></iframe>
</body></html>
";
?>