Location: PHPKode > projects > Network Asset Management Archive > nama/printsubnet.php
<html>
<head>
<title>ERDC Subnet Assignment</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<?php
include('datediff.inc');
$now = date("m/j/y H:i:s",time());
include "connect.php";

$now = date("m/j/y h:i:s",time());
ibase_timefmt("%m/%d/%Y %H:%M:%S",IBASE_TIMESTAMP);
$currenttime = time();
$SUBNET = $_GET['SUBNET'];
$fromdate = date("m/j/y",time()-(45*60*60*24));
$stmt = "Select * FROM arp_table where (SUBNET='$SUBNET') and (LAST_SEEN>'$fromdate') order by IPNUM;";
echo "$now<BR>";
$sth = ibase_query($dbh, $stmt);
?>
<body text="#000000" bgcolor="#FFFFCC" link="#0000EE" vlink="#551A8B" alink="#FF0000">
<table BORDER=3>
<tr ALIGN=CENTER BGCOLOR="#999999">
<td><b><font face="Times New Roman,Times">IP ADDRESS</font></b></td>

<td><b><font face="Times New Roman,Times">MAC ADDRESS</font></b></td>

<td><b><font face="Times New Roman,Times">NETBIOS NAME</font></b></td>

<td><b><font face="Times New Roman,Times">DNS NAME</font></b></td>

<td><b><font face="Times New Roman,Times">CONTACT</font></b></td>

<td><b><font face="Times New Roman,Times">LAST SEEN</font></b></td>

</tr>
<?
while ($row = ibase_fetch_object($sth)) {
 $lasttime = strtotime($row->LAST_SEEN);
//echo $lasttime . '-->' . strtotime($now) . '-->' . (strtotime($now)-$lasttime) . '<br>';
 $diff = - DateDiff ("d",$currenttime , $lasttime);
 $days = floor($diff);
 $diffh = ($diff - $days) * 24;
//echo $diff . "  " . $days . "  " . $diffh;
 $hours = floor($diffh);
 $diffm = ($diffh - $hours) * 60;
 $mins = floor($diffm);
 $diffs = ($diffm - $mins) * 60;
 $secs = floor($diffs);

$mydiff = '';
if ($days >= 1) {
   if ($days == 1) {
      $mydiff = $days . ' day';
   } else {
      $mydiff = $days . ' days';
   }
} 
if ($hours=12) {$hours=0;}
if ($hours >= 1) {
    if ($hours == 1) {
      $mydiff = $mydiff . ' ' . $hours . ' hour';
    } else {
      $mydiff = $mydiff . ' ' . $hours . ' hours';
    }
}  
if ($mins >= 1) {
    if ($mins > 9) {
        $mydiff = $mydiff . ' ' . $mins . ' min';
    } else {
        $mydiff = $mydiff . ' 0' . $mins . ' min';
    }
}
if ($secs >= 1) {
    if ($secs > 9) {
       $mydiff = $mydiff . ' ' . $secs . ' sec';
    } else {
       $mydiff = $mydiff . ' 0' . $secs . ' sec';
    }
}
$row2 = '';
   if ($row->OWNER > 0) {
      $stmt2 = "select * from owner where serial='$row->OWNER';";
      $sth2 = ibase_query($dbh,$stmt2);
      $row2 = ibase_fetch_object($sth2);
   }
   if ($diff>30) {
      print '<tr bgcolor="D3EED3">';
   } else {
     if ($diff>15) {
        print '<tr bgcolor="EED3D6">';
     } else {
        print '<tr>';
     }
   }
   print '<td>' . $row->IP_ADDRESS . '&nbsp</td>';
   print '<td>' . $row->MAC_ADDRESS . '&nbsp</td>';
   print '<td>' . $row->NETBIOS_NAME . '&nbsp</td>';
   print '<td>' . $row->DNS_NAME . '&nbsp</td>';
   print '<td>' . $row2->FIRST_NAME . ' ' . $row2->LAST_NAME . '&nbsp;</td>';
//   print '<td>' . $row->LAST_SEEN . '</td>';
//   print '<td>' . $currenttime . '</td>';
//   print '<td>' . $lasttime . '</td>';
   print '<td><div align="right">';
//   printf("%6.4f", $diff); 
   print $mydiff;
   print '</div></td>';

   print '</tr>';
}
?>
</table>
Return current item: Network Asset Management Archive