<?php
// cowsay.php
// RJM Programming
// February, 2025
   $suff='';
   if (isset($_GET['inwords'])) {
     if (isset($_GET['chr'])) {
       $suff=' -c "' . str_replace('+',' ',urldecode($_GET['chr'])) . '" ';
     }
     exec('cowsay' . $suff . ' -t "' . str_replace('+',' ',urldecode($_GET['inwords'])) . '" > /tmp/cowsay.txt');
     echo "<html><head><title>Cow Says ... thanks to https://pypi.org/project/cowsay</title><meta charset='UTF-8'/></head><body onload=\"if (window.parent) { if (parent.document.getElementById('result')) {  parent.document.getElementById('result').value=decodeURIComponent('" . urlencode(file_get_contents('/tmp/cowsay.txt')) . "').replace(/\+/g,' '); parent.document.getElementById('result').style.fontFamilt='Courier New';  parent.document.getElementById('result').style.fontSize='8px';  parent.document.getElementById('result').title='Double click for more ... thanks to https://pypi.org/project/cowsay'; parent.document.getElementById('result').ondblclick=function(){ window.open('/cowsay.php','_blank','top=100,left=100,width=600,height=600'); };   }  }\"><textarea title='Double lick for another Cow Says pearl of wisdom.' ondblclick=\"location.href='/cowsay.php';\" style='width:90%;height:90%;border:2px dotted red;'>" . file_get_contents('/tmp/cowsay.txt') . "</textarea></body></html>";
     exit;
   } else if (isset($_POST['inwords'])) {
     if (isset($_POST['chr'])) {
       $suff=' -c "' . str_replace('+',' ',urldecode($_POST['chr'])) . '" ';
     }
     exec('cowsay' . $suff . ' -t "' . str_replace('+',' ',urldecode($_POST['inwords'])) . '" > /tmp/cowsay.txt');
     echo "<html><head><title>Cow Says ... thanks to https://pypi.org/project/cowsay</title><meta charset='UTF-8'/></head><body onload=\"if (window.parent) { if (parent.document.getElementById('result')) {   parent.document.getElementById('result').value=decodeURIComponent('" . urlencode(file_get_contents('/tmp/cowsay.txt')) . "').replace(/\+/g,' '); parent.document.getElementById('result').style.fontFamilt='Courier New';  parent.document.getElementById('result').style.fontSize='8px';  parent.document.getElementById('result').title='Double click for more ... thanks to https://pypi.org/project/cowsay'; parent.document.getElementById('result').ondblclick=function(){ window.open('/cowsay.php','_blank','top=100,left=100,width=600,height=600'); };   }  }\"><textarea title='Double click for another Cow Says pearl of wisdom.' ondblclick=\"location.href='/cowsay.php';\" style='width:90%;height:90%;border:2px dotted red;'>" . file_get_contents('/tmp/cowsay.txt') . "</textarea></body></html>";
     exit;
   }
   
   echo "<html><head><title>Cow Says ... thanks to https://pypi.org/project/cowsay</title><meta charset='UTF-8'/></head><body><h1>Cow Says ...</h1><h3>RJM Programming - February, 2025</h3><h4>Thanks to <a target=_blank title='https://pypi.org/project/cowsay/' href='//pypi.org/project/cowsay/'>https://pypi.org/project/cowsay/</a></h4><form method=POST action='/cowsay.php'><textarea id=myta name=inwords></textarea><br><select name=chr>
<option value='cow'>Cow</option>
<option value='beavis'>Beavis</option>
<option value='cheese'>Cheese</option>
<option value='daemon'>Daemon</option>
<option value='dragon'>Dragon</option>
<option value='fox'>Fox</option>
<option value='ghostbusters'>Ghostbusters</option>
<option value='kitty'>Kitty</option>
<option value='meow'>Meow</option>
<option value='miki'>Miki</option>
<option value='milk'>Milk</option>
<option value='octopus'>Octopus</option>
<option value='pig'>Pig</option>
<option value='stegosaurus'>Stegosaurus</option>
<option value='stimpy'>Stimpy</option>
<option value='trex'>TRex</option>
<option value='turkey'>Turkey</option>
<option value='turtle'>Turtle</option>
<option value='tux'>Tux</option>
   </select><br><br><input type=submit value='Cow Says ...' style=background-color:yellow;></input></form></body></html>";
?>