<?php
 // whatis.php
 // Supervise whatis command
 // November, 2020
 
 $meth="POST";
 if (strpos(("~" . strtolower($_SERVER['SERVER_NAME'])), '~localhost') !== false) { $meth="GET"; }  
 
 $gb="";
 try {
  if (strpos(('~' . $_SERVER['HTTP_USER_AGENT']), '~curl') === false) {
    $gb="y";
  }
 } catch (Exception $ee) {
 }
 
 $pins='';
 if (isset($_POST['insearch']) && strpos(strtolower('' . $_SERVER['HTTP_REFERER']), "rjmprogramming.com.au") !== false) {
   $pins=$_POST['insearch'];
 } else if (isset($_GET['insearch']) && strpos(strtolower('' . $_SERVER['HTTP_REFERER']), "/localhost") !== false) {
   $pins=$_GET['insearch'];
 } else if ($meth == "GET" && isset($_GET['insearch'])) {
   $pins=$_GET['insearch'];
 } else if ($meth == "GET") {
   $pins=' ';
 }
 
 if (trim($pins) != '' && !isset($argv)) {
   if (urldecode($pins) == '') {
     echo "<html><body onload=\" document.getElementById('insearch').focus(); \"><h1>Supervise whatis command</h1><h3>RJM Programming - November, 2020</h3><br><br><form action=./whatis.php method=" . $meth . "><input placeholder='Enter whatis object' type=text id=insearch name=insearch value=''></input>&nbsp;<input type=submit value=Go></input></form></body></html>";
   } else if ($meth == "GET" && $gb == "") {
     passthru("whatis " . explode("\n",explode("\r",explode(";",explode("<",explode(">",explode("|",str_replace("+"," ",urldecode($pins)))[0])[0])[0])[0])[0])[0]);
   } else {
     ob_start();
     passthru("whatis " . explode("\n",explode("\r",explode(";",explode("<",explode(">",explode("|",str_replace("+"," ",urldecode($pins)))[0])[0])[0])[0])[0])[0]);
     $var = ob_get_contents();
     ob_end_clean();
     echo "<html><body onload=\" document.getElementById('insearch').focus(); \"><pre>$ whatis " . explode("\n",explode("\r",explode(";",explode("<",explode(">",explode("|",str_replace("+"," ",urldecode($pins)))[0])[0])[0])[0])[0])[0] . "<br>" . str_replace("\n", "<br>", $var) . "</pre><br><br><h1>Supervise whatis command</h1><h3>RJM Programming - November, 2020</h3><br><br><form action=./whatis.php method=" . $meth . "><input placeholder='Enter whatis object' type=text id=insearch name=insearch value=''></input>&nbsp;<input type=submit value=Go></input></form></body></html>";
     exit;
   }
 } else if (!isset($argv) && ($pins == '' || (trim($pins) == '' && $meth == "GET")) && !isset($_GET[$insh]) && $gb != "") {
   echo "<html><body onload=\" document.getElementById('insearch').focus(); \"><h1>Supervise whatis command</h1><h3>RJM Programming - November, 2020</h3><br><br><form action=./whatis.php method=" . $meth . "><input placeholder='Enter whatis object' type=text id=insearch name=insearch value=''></input>&nbsp;<input type=submit value=Go></input></form></body></html>";
 }


?>
