[ PHPXref.com ] [ Generated: Sun Jul 20 19:01:46 2008 ] [ Nulog 1.1.7 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/ -> host.php (source)

   1  <?php
   2  #
   3  # Copyright(C) 2003-2005 INL
   4  # Written by Eric Leblond <regit@inl.fr>
   5  #            Vincent Deffontaines <gryzor@inl.fr>
   6  #
   7  # This program is free software; you can redistribute it and/or modify
   8  # it under the terms of the GNU General Public License as published by
   9  # the Free Software Foundation, version 2 of the License.
  10  #
  11  #  This program is distributed in the hope that it will be useful,
  12  # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13  #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14  # GNU General Public License for more details.
  15  #
  16  # You should have received a copy of the GNU General Public License
  17  # along with this program; if not, write to the Free Software
  18  # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19  #
  20  $state=-1;
  21  $state=$_GET['state'];
  22  if ($state==4 || $state==1 || $state==2)
  23    $restrict_menu="yes";
  24   
  25  require ("include/header.inc");
  26  $restrict_menu="no";
  27  
  28  $host=$_GET['host'];
  29  
  30  if (!preg_match('/^[a-zA-Z0-9.]+$/',$host))
  31    $host='';
  32  
  33  if ($nufw_enabled == "yes"){
  34    if (!(($state>=-1) and ($state<=4)))
  35      $state=-1;
  36    if (!preg_match('/^[0-9-]+$/',$state))
  37      $state=-1;
  38  }
  39  
  40  $and_state_query=build_and_state_query($state);
  41  
  42  if (isset($query)){
  43      #convert
  44      if ( ! preg_match("/\d+\.\d+\.\d+\.\d+/",$host) ) {
  45          $iphost=gethostbyname($host);
  46  
  47      if($iphost == $host){
  48          print "<div class=mainarray><h2>Unknown host</H2></div>";
  49          exit;
  50      } else {
  51          $host = $iphost;
  52      }
  53      }
  54      $host=ip2long(preg_replace("/\s+/","",$host));
  55      if ($host<0)
  56      $host=$host+4294967296;
  57  }
  58  
  59  $query_order=$_GET['query_order'];
  60  if (isset($query_order)){
  61      if ( $query_order == "s" )
  62          $resp_order="d";
  63      elseif ($query_order == "d")
  64          $resp_order="d";
  65      else {
  66      $query_order="s";
  67      $resp_order="d";
  68      }
  69          
  70  } else {
  71      $query_order="s";
  72      $resp_order="d";
  73  }
  74  
  75  $start=$_GET['start'];
  76  $start=check_start($start);
  77  if (! isset($start)) {
  78           $start=0;
  79       }
  80  
  81  if ($conntrack_enabled == "yes") {
  82    $query="(select $packet_query_info from $table_ulog where ip_".$query_order."addr=$host $and_state_query) UNION (select $packet_query_info from $table_conntrack where ip_".$query_order."addr=$host $and_state_query order by oob_time_sec DESC,oob_time_usec DESC) limit $start,$number";
  83  } else {
  84     $query="select $packet_query_info from $table_ulog where ip_".$query_order."addr=$host $and_state_query order by oob_time_sec DESC,oob_time_usec DESC limit $start,$number";
  85  }
  86  
  87  echo "<div class=mainarray><h2><img src=\"images/host32.gif\" alt=\"host\" border=0> Stats for host ".gethostbyaddr(long2ip($host))."</h2>";
  88  
  89  $header="<tr><td colspan=9 type=header>";
  90  $header.="<table class=div_header  width=100% cellpadding=0 cellspacing=0>";
  91  $header.="<thead><tr><td ><h3>Host ".long2ip($host)." packets :</h3></td><td align=right> ( $start, ".($start+$number-1)." )</td></tr></thead>\n";
  92  $header.="</table></td></tr>";
  93  
  94  packet_query($header,$query,"host.php?start=".max($start-$number,0)."&host=$host&state=$state","host.php?query_order=$query_order&start=".($start+$number)."&host=$host&state=$state",$state);
  95  
  96  
  97  require ("include/footer.inc");
  98  echo "</div>";
  99  if ($footer_file){
 100      require($footer_file);
 101      }
 102  ?>
 103  </body>
 104  </html>


[ Powered by PHPXref - Served by Debian GNU/Linux ]