<?php
// cow_says_insertion.php
// RJM Programming - November, 2026

  $posted="";
  $lmcss="";
  $rmcss="";
  $lmcssinit="";
  $rmcssinit="";
  $lfontc="black";
  $rfontc="black";
  $lbc="#f9f9f9";
  $rbc="#f9f9f9";
  $wper="100";
  $hval="400";
  $bs="1.0";
  if (isset($_POST['lhdiag']) || isset($_GET['lhdiag'])) {
  $posted="yes";
  if (isset($_GET['lfontc'])) {
    $lfontc=str_replace('+',' ',urldecode($_GET['lfontc']));
  }
  if (isset($_GET['rfontc'])) {
    $rfontc=str_replace('+',' ',urldecode($_GET['rfontc']));
  }
  if (isset($_POST['lfontc'])) {
    $lfontc=str_replace('+',' ',urldecode($_POST['lfontc']));
  }
  if (isset($_POST['rfontc'])) {
    $rfontc=str_replace('+',' ',urldecode($_POST['rfontc']));
  }
  if (isset($_GET['lbc'])) {
    $lbc=str_replace('+',' ',urldecode($_GET['lbc']));
  }
  if (isset($_GET['rbc'])) {
    $rbc=str_replace('+',' ',urldecode($_GET['rbc']));
  }
  if (isset($_POST['lbc'])) {
    $lbc=str_replace('+',' ',urldecode($_POST['lbc']));
  }
  if (isset($_POST['rbc'])) {
    $rbc=str_replace('+',' ',urldecode($_POST['rbc']));
  }
  if (isset($_GET['lmcss'])) {
    $lmcss=str_replace('+',' ',urldecode($_GET['lmcss']));
    if (trim($lmcss) != "") { $lmcssinit=" title=\"" . $lmcss . "\" ";   }
  }
  if (isset($_GET['rmcss'])) {
    $rmcss=str_replace('+',' ',urldecode($_GET['rmcss']));
    if (trim($rmcss) != "") { $rmcssinit=" title=\"" . $rmcss . "\" ";   }
  }
  if (isset($_POST['lmcss'])) {
    $lmcss=str_replace('+',' ',urldecode($_POST['lmcss']));
    if (trim($lmcss) != "") { $lmcssinit=" title=\"" . $lmcss . "\" ";   }
  }
  if (isset($_POST['rmcss'])) {
    $rmcss=str_replace('+',' ',urldecode($_POST['rmcss']));
    if (trim($rmcss) != "") { $rmcssinit=" title=\"" . $rmcss . "\" ";   }
  }
  $wper="125";
  $hval="800";
  $bs="0.75";
  }
  if (!isset($_POST['lhdiag']) && isset($_GET['lhdiag'])) {
    if (substr(str_replace('+',' ',urldecode($_GET['lhdiag'])),0,7) == 'cowsay ') {
      $_POST['lhdiag']=$_GET['lhdiag'];
    }
  }
  if (!isset($_POST['rhdiag']) && isset($_GET['rhdiag'])) {
    if (substr(str_replace('+',' ',urldecode($_GET['rhdiag'])),0,7) == 'cowsay ') {
      $_POST['rhdiag']=$_GET['rhdiag'];
    }
  }
  $cb="For stegosaurus enter -c \"stegosaurus\" ";
  $sb=" -c \"stegosaurus\" ";
  $sbtwo=" -t ";
  $lts='|';
  $gts='|';
  $clist="beavis, cheese, cow, daemon, dragon, fox, ghostbusters, kitty, meow, miki, milk, octopus, pig, stegosaurus, stimpy, trex, turkey, turtle, tux";
  $clistsw="-c";
if (strtoupper(PHP_OS) == "DARWIN") {
$lts='<';
$gts='>';
$revstr="";
$sb=" -r -g -p ";
$sbtwo=" ";
$cb="For random greedy paranoid enter -r -g -p";
$clist="actually, alpaca, beavis.zen, blowfish, bong, bud-frogs, bunny, cheese, cower, cupcake, daemon, default, dragon, dragon-and-cow, elephant, elephant-in-snake, eyes, flaming-sheep, fox, ghostbusters, head-in, hellokitty, kiss, kitty, koala, kosh, llama, luke-koala, mech-and-cow, meow, milk, moofasa, moose, mutilated, ren, sheep, skeleton, small, stegosaurus, stimpy, supermilker, surgery, sus, three-eyes, turkey, turtle, tux, udder, vader, vader-koala, www";
$clistsw="-f";
}

function otherwayaround($instuff) {
  global $revstr, $lts, $gts;
  $outstuff=$instuff;
  if (strpos($instuff,$lts) !== false && strpos($instuff,$gts) !== false) {
    $revstr=explode($gts, explode($lts, $instuff)[1])[0];
    if (trim($revstr) != "") {
      $outstuff=str_replace($lts . $revstr . $gts, $lts . strrev($revstr) . $gts, $instuff);
    }
  }
  return $instuff;
}

$lhthingo=(isset($_POST['lhdiag']) ? shell_exec( (substr(str_replace('+',' ',urldecode($_POST['lhdiag'])),0,7) != 'cowsay ' ? '' : explode("`",explode(";",explode("\n",str_replace('+',' ',urldecode($_POST['lhdiag'])))[0])[0])[0] )   ) : (isset($_GET['lhdiag']) ? str_replace('+',' ',urldecode($_GET['lhdiag'])) : "
 ____________________
" . $lts . "  Left Hand comment " . $gts . "
 --------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
"));


$lhthingo=otherwayaround($lhthingo);


$rhthingo=(isset($_POST['rhdiag']) ? shell_exec( (substr(str_replace('+',' ',urldecode($_POST['rhdiag'])),0,7) != 'cowsay ' ? '' : explode("`",explode(";",explode("\n",str_replace('+',' ',urldecode($_POST['rhdiag'])))[0])[0])[0] )  ) : (isset($_GET['rhdiag']) ? str_replace('+',' ',urldecode($_GET['rhdiag'])) : "
 _____________________
" . $lts . "  Right Hand comment " . $gts . "
 ---------------------
        \   ^__^
         \  (oo)\_______
            (__)\       )\/\
                ||----w |
                ||     ||
"));



echo "<html>
<head>
<title>Cow Says Cartoon - RJM Programming - November, 2026</title>
<style>

input {  color: blue;  }
input[type=text] {  background-color: #ffecf2;   }

input[type=button] {  border-radius: 100px; padding: 15 15 15 15;  }
input[type=submit] {  border-radius: 100px; padding: 15 15 15 15;  }


textarea { background-color: #f9f9f9;  font-weight: bold; }

/* Thanks to https://www.google.com/search?q=hide+vertical+scroller&sca_esv=28ba29a10f60894c&rlz=1C5OZZY_en&sxsrf=AKL5yDhDhuXcCcipvfxuwIlsw7XRFis8cA%3A1793564144145&ei=8J3nauS6CMP91e8PqN_9oAw&biw=1427&bih=698&uact=5&oq=hide+vertical+scroller&gs_lp=Egxnd3Mtd2l6LXNlcnAiFmhpZGUgdmVydGljYWwgc2Nyb2xsZXIyBxAAGIAEGA0yBhAAGBYYHjIGEAAYFhgeMgYQABgWGB4yBhAAGBYYHjIIEAAYBRgeGA0yCBAAGAUYHhgNMggQABgFGB4YDTIIEAAYBRgeGA0yCBAAGAUYHhgNSMxBUJYFWLs3cAF4AZABAJgB5AGgAf4SqgEFMC44LjS4AQPIAQD4AQGYAgigAtgMwgIKEAAYRxjWBBiwA8ICBRAAGO8FwgIIEAAYiQUYogTCAggQABgIGB4YDcICCxAAGIAEGIoFGIYDmAMA4gMFEgExIECIBgGQBgiSBwUxLjAuN6AH7UeyBwMyLTe4B70MwgcDMy04yAdJgAgB&sclient=gws-wiz-serp */
/* Chrome, Safari, and Opera */
#lhxta::-webkit-scrollbar {
  display: none;
}

/* Firefox */
#lhxta {
  scrollbar-width: none;
}

/* Internet Explorer and Edge */
#lhxta {
  -ms-overflow-style: none;
}
</style>
<scr" . "ipt type=text/javascript>
  var initl='', changedl=0, extral=''; 
  var initr='', changedr=0, extrar=''; 

  function emailit() {
     document.getElementById('es').href='mailto:?subject=Cow%20Says%20Cartoon&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '?lhdiag=' + encodeURIComponent(document.getElementById('lhdiag').value) + '&rhdiag=' + encodeURIComponent(document.getElementById('rhdiag').value) + '&lfontc=' + encodeURIComponent(document.getElementById('lfontc').value) + '&rfontc=' + encodeURIComponent(document.getElementById('rfontc').value) + '&lbc=' + encodeURIComponent(document.getElementById('lbc').value) + '&rbc=' + encodeURIComponent(document.getElementById('rbc').value) + extral + extrar);
     document.getElementById('es').click();
     document.getElementById('mysub').click();
  }
  
  function smsit() {
     document.getElementById('es').href='sms:&body=' + encodeURIComponent(document.URL.split('?')[0].split('#')[0] + '?lhdiag=' + encodeURIComponent(document.getElementById('lhdiag').value) + '&rhdiag=' + encodeURIComponent(document.getElementById('rhdiag').value) + '&lfontc=' + encodeURIComponent(document.getElementById('lfontc').value) + '&rfontc=' + encodeURIComponent(document.getElementById('rfontc').value) + '&lbc=' + encodeURIComponent(document.getElementById('lbc').value) + '&rbc=' + encodeURIComponent(document.getElementById('rbc').value) + extral + extrar);
     document.getElementById('es').click();
     document.getElementById('mysub').click();
  }
  
  function checkcp(ocp) {
    if (ocp.id == 'lbc') {
      if (initl != ocp.value) {
        changedl++;
        if (changedl == 1) {
          document.getElementById('lmcss').value='text-shadow:-1px 1px 1px ' + ocp.value + ';';
        } else if (changedl >= 2) {
          document.getElementById('lmcss').name='lmcss';
          document.getElementById('lmcss').style.display='inline-block';
          document.getElementById('lmcss').title=document.getElementById('lmcss').placeholder;
          document.getElementById('lmcss').ontouchmove=function(event){  alert(event.target.title); };
          extrait(document.getElementById('lmcss'));
        }
        initl=ocp.value;
      }
    } else if (ocp.id == 'rbc') {
      if (initr != ocp.value) {
        changedr++;
        if (changedr == 1) {
          document.getElementById('rmcss').value='text-shadow:-1px 1px 1px ' + ocp.value + ';';
        } else if (changedr >= 2) {
          document.getElementById('rmcss').name='rmcss';
          document.getElementById('rmcss').style.display='inline-block';
          document.getElementById('rmcss').title=document.getElementById('rmcss').placeholder;
          document.getElementById('rmcss').ontouchmove=function(event){  alert(event.target.title); };
          extrait(document.getElementById('rmcss'));
        }
        initr=ocp.value;
      }
    }
  }
  
  function extrait(ocp) {
    if (ocp.id == 'lmcss') {
      if (ocp.value.trim() == '') {
        extral=''; 
      } else if (ocp.id == ('' + ocp.name)) {
        extral='&lmcss=' + encodeURIComponent(ocp.value);
      }
    } else if (ocp.id == 'rmcss') {
      if (ocp.value.trim() == '') {
        extrar=''; 
      } else if (ocp.id == ('' + ocp.name)) {
        extrar='&rmcss=' + encodeURIComponent(ocp.value);
      }
    }
  }
  
  function initit() {
     if (('' + document.getElementById('lmcss').title).indexOf('text-shadow:') != -1) {
       document.getElementById('lmcss').value=document.getElementById('lmcss').title;
       document.getElementById('lmcss').style.display='inline-block';
       document.getElementById('lmcss').name='lmcss';
       document.getElementById('lmcss').title=document.getElementById('lmcss').placeholder;
     }
     if (('' + document.getElementById('rmcss').title).indexOf('text-shadow:') != -1) {
       document.getElementById('rmcss').value=document.getElementById('rmcss').title;
       document.getElementById('rmcss').name='rmcss';
       document.getElementById('rmcss').style.display='inline-block';
       document.getElementById('rmcss').title=document.getElementById('rmcss').placeholder;
     }
     initl=document.getElementById('lbc').value;
     initr=document.getElementById('rbc').value;
     if (window.self != window.parent) {
        if (document.getElementById('lhdiag').value.indexOf('\"stegosaurus\"') != -1 && '" . $posted . "' == '') {
          document.getElementById('lhdiag').value=document.getElementById('lhdiag').value.replace('stegosaurus','tux');
        }
        if (document.getElementById('rhdiag').value.indexOf('\"stegosaurus\"') != -1 && '" . $posted . "' == '') {
          document.getElementById('rhdiag').value=document.getElementById('rhdiag').value.replace('stegosaurus','tux');
        }
     }
  }

</scr" . "ipt>
</head>
<body onload=initit(); style='transform:scale(" . $bs . ");transform-origin: 0 0;'>
<table style=width:" . $wper . "%;height:" . $hval . "px;>
<tr><td style=width:50%;height:" . $hval . "px;vertical-align:top;>
<textarea style='width:100%;height:32px;text-align:right;border-bottom:1px solid transparent;color:" . $lfontc . ";background-color:" . $lbc . ";" . $lmcss . "' id=lhxta>" . explode($lts . $revstr . $gts,$lhthingo)[0] . $lts . $revstr . $gts . "</textarea><textarea id=lhta style='width:100%;height:" . (-32 + $hval) . "px;transform:scaleX(-1);border-top:1px solid transparent;color:" . $lfontc . ";background-color:" . $lbc . ";" . $lmcss . "'>" . explode($lts . $revstr . $gts,$lhthingo)[1] . "</textarea></td><td style='width:50%;height:" . $hval . "px;vertical-align:top;'><textarea style=width:100%;height:" . $hval . "px;color:" . $rfontc . ";background-color:" . $rbc . ";" . $rmcss . ">" . $rhthingo . "</textarea></td></tr></table><br><h1>Cow Says Cartoon</h1><h3>RJM Programming - November, 2026</h3>
<form method=POST action=./cow_says_insertion.php>
<input type=text ontouchmove='event.preventDefault(); alert(this.title);' title=' " . $clistsw . " \"characters\" can be among " . $clist . " ... to right are font colour and background colour pickers (and with background one double valuing can allow the first value selection be a text shadow colour applied onto Font Colour)' style=width:70%; id=lhdiag name=lhdiag placeholder=\"Eg. " . $cb . " \" value='" . (substr(str_replace('+',' ',urldecode($_POST['lhdiag'])),0,7) != 'cowsay ' ? 'cowsay ' . $sb . ' ' . $sbtwo . ' "Left Hand comment"' : str_replace('+',' ',urldecode($_POST['lhdiag']))) . "'></input>&nbsp;<input id=lfontc type=color title='Font Colour' name=lfontc value='" . $lfontc . "'></input>&nbsp;<input onchange=checkcp(this); onblur=checkcp(this); id=lbc type=color title='Background Colour' name=lbc value='" . $lbc . "'></input><br><input " . $lmcssinit . " onblur=extrait(this); placeholder='Additional CSS' type=text id=lmcss value='' style=display:none;width:70%;></input><br>
<input type=text ontouchmove='event.preventDefault(); alert(this.title);' title=' " . $clistsw . " \"characters\" can be among " . $clist . " ... to right are font colour and background colour pickers (and with background one double valuing can allow the first value selection be a text shadow colour applied onto Font Colour)' style=width:70%; id=rhdiag name=rhdiag placeholder=\"Eg. " . $cb . " \" value='" . (substr(str_replace('+',' ',urldecode($_POST['rhdiag'])),0,7) != 'cowsay ' ? 'cowsay ' . $sb . ' ' . $sbtwo . ' "Right Hand comment"' : str_replace('+',' ',urldecode($_POST['rhdiag']))) . "'></input>&nbsp;<input id=rfontc type=color title='Font Colour' name=rfontc value='" . $rfontc . "'></input>&nbsp;<input onchange=checkcp(this); onblur=checkcp(this); id=rbc type=color title='Background Colour' name=rbc value='" . $rbc . "'></input><br><input " . $rmcssinit . " onblur=extrait(this); placeholder='Additional CSS' type=text id=rmcss value='' style=display:none;width:70%;></input><br>
<input id=mysub style=background-color:yellow; type=submit value='Draw above ...'></input>&nbsp;&nbsp;<input onclick='emailit();' style=background-color:orange; type=button value='Email as well ...'></input>&nbsp;&nbsp;<input style=background-color:lightgreen; onclick='smsit();' type=button value='SMS as well ...'></input>
</form>
<a id=es style=display:none; target=_top href='#'>Email or SMS</a>
</body></html>";

?>
