Dr. Mark Humphrys

School of Computing. Dublin City University.

Home      Blog      Teaching      Research      Contact

Search:

CA249      CA318      CA425      CA651

w2mind.computing.dcu.ie      w2mind.org


PHP demo

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

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) DAV/2 mod_ssl/2.2.3 OpenSSL/0.9.8l PHP/5.2.6 SVN/1.6.12  
PHP datestamp (needs PHP 5.1.0) 1329047270  
Seconds since 1 Jan 1970 1329047270  
Time now - microsecond within the current second 391323  
Unique id based on time in microseconds 4f37a6e6606c1  
Human-readable datestamp Sun, 12 Feb 2012 11:47:50 +0000  
Process ID 20070  


The PHP code used


<?php 

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

     $originalip=$_SERVER['HTTP_X_FORWARDED_FOR'];

 $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 "<tr> <td> Original IP address                                        </td> <td> $originalip        &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"; 

?>



Feeds      HumphrysFamilyTree.com

Bookmark and Share           On Internet since 1987.