Location: PHPKode > projects > Network Asset Management Archive > nama/liaso/printtabl.php
<?php
include "../connect.php";
print '<body bgcolor="#FFFFCC">';
$now = date("j/m/y h:i:s",time());
$submit = $_POST['Submit'];
$EMAIL = $_POST['EMAIL'];
$MESSAGE = $_POST['MESSAGE'];
$SUBJECT = $_POST['SUBJECT'];
$IPLIST = $_POST['IPLIST'];
$SLIASO = $_POST['SLIASO'];
$MESSAGE = stripslashes($MESSAGE);
$MESSAGE = str_replace("\n", "<br>", $MESSAGE);

$ips = explode("\n",$IPLIST);
$mylist =  "'";
for ($i=0; $i<count($ips); $i++) {
  $ip = trim($ips[$i]);
  $mylist = $mylist . $ip;
  if ($i<count($ips)-2) {
     $mylist = $mylist . "','" ;
  }
}
$mylist = $mylist . "'";

$headers  = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: " . $EMAIL;

$tablerow = "style='border-color:#DBB748; border-width:1px; border-right: 2px solid #DBB748; border-collapse: collapse; border-style:solid;'";

$stmt = 'select distinct o.display_name, o.phone, o.email_address, o2.email_address as liaso, a.ip_address, a.netbios_name, a.dns_name, a.building, a.room, a.barcode, a.last_seen, a.md5, a.os from arp_table a, owner o, owner o2, lab l, subnets s where (o2.serial=l.liaso) and (l.serial=s.lab) and (a.subnet=s.subnet) and (o.serial=a.iaso) and (a.ip_address in (' . $mylist . ')) order by o.display_name, a.ipnum';

//echo $stmt;
$sth = ibase_query($dbh, $stmt);
$i = -1;
$first = 1;
$iaso="";
$iasoemail="";
$liasoemail="";
$mymsg = "";
$myhtml = '<html><body text="#000000" bgcolor="#F9F3E0" link="#0000EE" vlink="#551A8B" alink="#FF0000">';
$ip="";
$atleastone=0;
while ($row = ibase_fetch_object($sth)) {
$atleastone=1;
if ($iaso!=$row->DISPLAY_NAME . '   ' . $row->PHONE) {
  if ($first != 1) {
     if ($MESSAGE!='') { 
            $mymsg = '<b>' . $MESSAGE . '</b><BR>' . $mymsg;
     }
//     $mymsg = '<br><b>' . $iaso  . '</b><BR>' . $mymsg;
     $mymsg .= '</table>';
     echo $mymsg;
     $mymsg = $myhtml . $mymsg;
     echo 'Sent Email to ' . $iasoemail ; 
     if (SLIASO != '') {
         echo ', ' . $liasoemail  ;
     }
     echo  ' --------------------------------------------------<br>';
     mail($iasoemail,$SUBJECT, $mymsg, $headers);
     if ($iasoemail != $liasoemail) {
        if (SLIASO != '') {
               mail($liasoemail,$SUBJECT, $mymsg, $headers);
        }
     }
  $mymsg = '';
  }
   $first = 0;
   $i = -1;
   $mymsg .= '<table style="border-color:#DBB748; border-width:3px; border-right: 3px solid #DBB748; border-collapse: collapse; border-style:solid;" width="700" border="2">';
   $mymsg .= "<tr BGCOLOR='#DBB748' ALIGN=left><th " . $tablerow . ">IP</th><th " . $tablerow . ">Name</th><th " . $tablerow . ">Building</th><th " . $tablerow . ">Room</th><th " . $tablerow . ">Bar Code</th><th " . $tablerow . ">OS</th><th " . $tablerow . ">Last Seen</th></tr>";
}
if ($i%2) {
   $mymsg .= "<tr BGCOLOR='#F5EACB'>";
} else {
   $mymsg .= "<tr>";
}
list ($lastseendate, $lastseentime) = split(" ", $row->LAST_SEEN);

if ($ip!=$row->IP_ADDRESS) {
 $i = $i + 1;
if ($i%2) {
   $mymsg .= "<tr BGCOLOR='#F5EACB'>";
} else {
   $mymsg .= "<tr>";
}
   $mymsg .= '<td ' . $tablerow . 'width="15%"><a href="/right.php?SERIAL=' . $row->MD5 . '" target = "_blank">' . $row->IP_ADDRESS . '</a></td>';
   if ($row->NETBIOS_NAME!='') {
      $mymsg .= '<td ' . $tablerow . '>' . $row->NETBIOS_NAME . '</td>';
   } else {
      $mymsg .= '<td ' . $tablerow . '>' . $row->DNS_NAME . '</td>';
   }
   $mymsg .= '<td ' . $tablerow . '>' . $row->BUILDING . '</td>';
   $mymsg .= '<td ' . $tablerow . '>' . $row->ROOM . '</td>';
   $mymsg .= '<td ' . $tablerow . '>' . $row->BARCODE . '</td>';
   $mymsg .= '<td ' . $tablerow . '>' . $row->OS . '</td>';
   $mymsg .= '<td ' . $tablerow . '>' . $lastseendate . '</td>';
} else {
if ($i%2) {
   $mymsg .= "<tr BGCOLOR='#F5EACB'>";
} else {
   $mymsg .= "<tr>";
}
   $mymsg .= '<td ' . $tablerow . '>&nbsp</td><td ' . $tablerow . '>&nbsp</td>';
}



$mymsg .= '</tr>';
//$i = $i + 1;
$iaso=$row->DISPLAY_NAME . '   ' . $row->PHONE;
$iasoemail=$row->EMAIL_ADDRESS;
$liasoemail=$row->LIASO;
$ip=$row->IP_ADDRESS;
}
if ($atleastone==1) {
     if ($MESSAGE!='') { $mymsg = '<b>' . $MESSAGE . '</b><BR>' . $mymsg;}
//     $mymsg = '<br><b>' . $iaso  . '</b><BR>' . $mymsg;
     $mymsg .= '</table>';
     echo $mymsg;
     $mymsg = $myhtml . $mymsg;
     echo 'Sent Email to ' . $iasoemail . ' , ' . $liasoemail . ' --------------------------------------------------<br>';
     mail($iasoemail,$SUBJECT, $mymsg, $headers);
     if ($iasoemail != $liasoemail) {
         mail($liasoemail,$SUBJECT, $mymsg, $headers);
     }
}
?>

Return current item: Network Asset Management Archive