<?php
  // Firefox home page idea via MAMP via ...
  // http://localhost:8888/ps_ef.php

function tab2space($line, $tab = 4, $nbsp = FALSE) {  // thanks to https://stackoverflow.com/questions/14308168/using-php-to-convert-tabs-to-spaces-for-html-display
    while (($t = mb_strpos($line,"\t")) !== FALSE) {
        $preTab = $t?mb_substr($line, 0, $t):'';
        $line = $preTab . str_repeat($nbsp?chr(7):' ', $tab-(mb_strlen($preTab)%$tab)) . mb_substr($line, $t+1);
    }
    return  $nbsp?str_replace($nbsp?chr(7):' ', '&nbsp;', $line):$line;
}

  exec("ps -ef > /tmp/x.x");
  $reportis=file_get_contents("/tmp/x.x");
  echo "<html>
<head>
<script type='text/javascript'> 
 function doit() { 
  if (('' + location.hash).toLowerCase().replace('#','').indexOf('http') == 0) {  
    var urls=('' + location.hash).replace('#','').split('#');
    for (var iurls=0; iurls<urls.length; iurls++) {
     document.getElementById('blanka').href=urls[iurls]; 
     document.getElementById('blanka').click(); 
    }
  } 
 } 
</script>
</head>
<body onload=\" setTimeout(doit,70); \">
<textarea style='background-color:#f0f0f0;width:100%;height:1200px;font-family:Courier New;'>" . $reportis . "</textarea>
<a target=_blank style=display:none; id=blanka href=''>New</a>
</body>
</html>";
  if (file_exists("/tmp/x.x")) {
    unlink("/tmp/x.x");
  }
  exit;
?>