PHP demo

Just insert PHP code in a normal web page, mixed with HTML code:

<html>
<body>

html code

<?php 
php code 
?>

more html code

Result:

Client IP address 38.107.191.87  
Client hostname as environment variable (prob. not set up)  
Client hostname (done manually) 38.107.191.87  
Query hostname

Client browser CCBot/1.0 (+http://www.commoncrawl.org/bot.html)  
Referring page  
Result of shell command
     USER    RUSER
webdaemon webdaemon
 

Server software Apache/2.2.3 (Unix) PHP/5.2.6  
PHP datestamp (needs PHP 5.1.0) 1258808889  
Seconds since 1 Jan 1970 1258808889  
Time now - microsecond within the current second 921569  
Unique id based on time in microseconds 4b07e639e1f3c  
Human-readable datestamp Sat, 21 Nov 2009 13:08:09 +0000  
Process ID 2996  

The PHP code used:


<?php 

       $clientip=$_SERVER['REMOTE_ADDR'];
 $clienthostname=$_SERVER['REMOTE_HOST'];
$clienthostname2=gethostbyaddr($clientip);

 $clientbrowser=$_SERVER['HTTP_USER_AGENT'];
   $refererpage=$_SERVER['HTTP_REFERER'];
$serversoftware=$_SERVER['SERVER_SOFTWARE'];
      $php_date=$_SERVER['REQUEST_TIME'];

// seconds since 1970:
     $seconds=time();                   

$t=gettimeofday();              // returns array of seconds since 1970, plus microseconds 
//   $seconds=$t["sec"];
$microseconds=$t["usec"];       

   $human_date=date("r");

$microsecondid=uniqid();
          $pid=getmypid();


// execute a shell command
// show what user the current process $$ is running as
        $output=shell_exec("ps -p $$ -o user,ruser");      


print "<table border=1 CELLPADDING=5 cellspacing=0  bgcolor=#eeeeee>\n"; 
print "<tr> <td> Client IP address                                          </td> <td> $clientip        &nbsp; </td> </tr>\n";  
print "<tr> <td> Client hostname as environment variable (prob. not set up) </td> <td> $clienthostname  &nbsp; </td> </tr>\n";  
print "<tr> <td> Client hostname (done manually)                            </td> <td> $clienthostname2 &nbsp; </td> </tr>\n";  

print "</table><p>\n"; 


print "<table border=1 CELLPADDING=5 cellspacing=0  bgcolor=#eeeeee>\n"; 
print "<tr> <td> Client browser             </td> <td> $clientbrowser                        &nbsp; </td> </tr>\n";  
print "<tr> <td> Referring page             </td> <td> <a href=$refererpage>$refererpage</a> &nbsp; </td> </tr>\n";  
print "<tr> <td> Result of shell command    </td> <td> <pre> $output </pre>                         </td> </tr>\n"; 
print "</table><p>\n"; 

print "<table border=1 CELLPADDING=5 cellspacing=0  bgcolor=#eeeeee>\n"; 
print "<tr> <td> Server software                                    </td> <td> $serversoftware  &nbsp; </td> </tr>\n"; 
print "<tr> <td> PHP datestamp (needs PHP 5.1.0)                    </td> <td> $php_date        &nbsp; </td> </tr>\n"; 
print "<tr> <td> Seconds since 1 Jan 1970                           </td> <td> $seconds         &nbsp; </td> </tr>\n"; 
print "<tr> <td> Time now - microsecond within the current second   </td> <td> $microseconds    &nbsp; </td> </tr>\n"; 
print "<tr> <td> Unique id based on time in microseconds            </td> <td> $microsecondid   &nbsp; </td> </tr>\n"; 
print "<tr> <td> Human-readable datestamp                           </td> <td> $human_date      &nbsp; </td> </tr>\n"; 
print "<tr> <td> Process ID                                         </td> <td> $pid             &nbsp; </td> </tr>\n"; 
print "</table><p>\n"; 

?>