Location: PHPKode > projects > IPTables log analyzer > iptablelog/utils/Layout.php
<?php

require_once("$file_base/utils/Misc.php");

function pageHeader() {
  global $chain;
  global $first;
  global $number;
  global $debug;
  global $date;
  global $dateToString;
  global $ignored_ports;
  global $css_style;
  global $css_styles;
  global $file_base;
  global $url_base;

  if ($debug) { print_session(); }
   ?>
<html>
<head>
   <title>IPTables logs</title>   
   <meta content="text/html;charset=UTF-8" http-equiv="content-type">
   <link rel="stylesheet" type="text/css" href="<? print $url_base . "/themes/" . $css_styles[$css_style] . "/" . $css_styles[$css_style]; ?>.css" />

<script language="JavaScript">
  function add_sidebar()
    { if ((typeof window.sidebar == "object") && 
         (typeof window.sidebar.addPanel == "function"))
    { window.sidebar.addPanel ("IPTables","http://<?php print $GLOBALS["HTTP_HOST"].$url_base."/sidebar/index.php"; ?>",""); } } 
</script>   

</head>
<body>

    <? include("$file_base/themes/$css_styles[$css_style]/header.inc"); ?>


<!--<table width="100%" class="ToolBar"><tr><td>-->
<table class="ToolBar">
<tr class="ToolBar">
 <td class="ToolBarTD"><form method="link" action="<? print $url_base; ?>"><input type="image" src="<? echo $url_base; ?>/images/home.gif"></form></td>
 <td class="ToolBarTD"><a href="<? echo $url_base; ?>/reports/index.php" class="TitleLink">R&nbsp;e&nbsp;p&nbsp;o&nbsp;r&nbsp;t&nbsp;s</a></td>
 <td class="ToolBarTD"><a href="<? echo $url_base; ?>/admin/index.php" class="TitleLink">A&nbsp;d&nbsp;m&nbsp;i&nbsp;n</a></td>
 <td class="ToolBarTD" width="100%">&nbsp;</td>
 <td class="ToolBarTD"><a href="help.php" class="TitleLink">H&nbsp;e&nbsp;l&nbsp;p&nbsp;</a></td>
</tr>
</table>
<!--</tr></td></table>-->

<br>
<br>

<table width="100%"><tr>
<td width="75%" valign='top'>

   <?php
}










function pageFooter() {
  global $link;
  global $chain;
  global $debug;
  global $date;
  global $dateToString;
  global $module_display;
  global $css_style;
  global $css_styles;
  global $domain_len;
  if (debug) {
    global $time_start;
    global $timings;
  }
?>  
</td> <!-- end of first main columm -->
<td width="25%" valign='top'>

<table width="100%">
<tr><td>
<?php
    beginModule("Packet selection","PacketSelection");
  $packetSelector = new PacketSelector();
  $packetSelector->display();
  endModule("PacketSelection");
?>
</td></tr>
<tr><td>
<br>
<?php
    $name="DatabaseStats";
    if ($module_display[$name]) {
      beginModule("Database stats",$name);
      $databaseStats = new DatabaseStats($date);
      $databaseStats->display();
      endModule("Database stats");
    } else {
        $module_display_string="?";
	foreach (array_keys($module_display) as $module) {
	  if (!($module == $name)) {
	    $module_display_string=$module_display_string."_module_display[".$module."]=".$module_display[$module]."&";
	  }	  
	}	
	$module_display_string=$module_display_string."_module_display[".$name."]=1";
	print "<a class=\"AddButton\" href=\"$module_display_string\">Display Database Stats</a>";
    }
?>
</td></tr>
<tr><td>
<br>
<?php
    $name="TopHosts";
    if ($module_display[$name]) {
      beginModule("Top Hosts [$chain] [${dateToString[$date]}]",$name);
      $topHosts = new TopHosts();
      $topHosts->display();
      endModule("Top Hosts [$chain] [${dateToString[$date]}]");
    } else {
        $module_display_string="?";
	foreach (array_keys($module_display) as $module) {
	  if (!($module == $name)) {
	    $module_display_string=$module_display_string."_module_display[".$module."]=".$module_display[$module]."&";
	  }	  
	}	
	$module_display_string=$module_display_string."_module_display[".$name."]=1";
	print "<a class=\"AddButton\" href=\"$module_display_string\">Display Top Hosts</a>";
    }
    
?>
</td></tr>
<tr><td>
<br>
<?php
    $name="TopProto";
    if ($module_display[$name]) {
      beginModule("Top Proto [ALL] [${dateToString[$date]}]",$name);
      $topProto = new TopProto();
      $topProto->display();
      endModule("Top Proto [ALL] [${dateToString[$date]}]");
    } else {
        $module_display_string="?";
	foreach (array_keys($module_display) as $module) {
	  if (!($module == $name)) {
	    $module_display_string=$module_display_string."_module_display[".$module."]=".$module_display[$module]."&";
	  }	  
	}	
	$module_display_string=$module_display_string."_module_display[".$name."]=1";
	print "<a class=\"AddButton\" href=\"$module_display_string\">Display Top Proto</a>";
    }
?>
</td></tr>
<tr><td>
<br>
<?php
    $name="TopPorts";
    if ($module_display[$name]) {
      beginModule("Top Ports [${dateToString[$date]}]",$name);
      $topPorts = new TopPorts();
      $topPorts->display();
      endModule("Top Ports [${dateToString[$date]}]");
    } else {
        $module_display_string="?";
	foreach (array_keys($module_display) as $module) {
	  if (!($module == $name)) {
	    $module_display_string=$module_display_string."_module_display[".$module."]=".$module_display[$module]."&";
	  }	  
	}	
	$module_display_string=$module_display_string."_module_display[".$name."]=1";
	print "<a class=\"AddButton\" href=\"$module_display_string\">Display Top Ports</a>";
    }
?>
</td></tr>
<tr><td>
<br>
<?php
    $name="TopDomains";
    if ($module_display[$name]) {
      if ($domain_len <= 1) { $plus = 2; $minus = 1; } else { $plus = $domain_len + 1; $minus = $domain_len - 1; }
      $plus_minus = "<a href='?dom_len=$plus'>+</a> <a href='?dom_len=$minus'>-</a>";
      beginModule("Top Domains [$plus_minus] [$chain] [${dateToString[$date]}]",$name);
      $topDomains = new TopDomains();
      $topDomains->display();
      endModule("Top Domains [$chain] [${dateToString[$date]}]");
    } else {
        $module_display_string="?";
	foreach (array_keys($module_display) as $module) {
	  if (!($module == $name)) {
	    $module_display_string=$module_display_string."_module_display[".$module."]=".$module_display[$module]."&";
	  }	  
	}	
	$module_display_string=$module_display_string."_module_display[".$name."]=1";
	print "<a class=\"AddButton\" href=\"$module_display_string\">Display Top Domains</a>";
    }
?>
</td></tr>
</table>


</td>
</tr></table>

<form action="" method="post">
  Style : <select name="_css_style" onchange="this.form.submit()">
<?php
    foreach (array_keys($css_styles) as $style) {
      if ($style==$css_style) {	
	print "<option value=\"$style\" selected>$style</option>\n";
      } else {
	print "<option value=\"$style\">$style</option>\n";
      }
    }
?>
  </select>
</form>

<a href="javascript:add_sidebar();">Add the sidebar</a>

<?php if ($debug) { ?>
  <form action="" method="post">
    <input type="hidden" name="_close_session" value="1"/>
    <input type="submit" value="Destroy session">
  </form>


 
<?php 
     $time_end = getmicrotime();
  $time = $time_end - $time_start;
  
  echo "<!-- Processing time : $time -->\n";

  echo "<!--\n";
  foreach (array_keys ($timings) as $location) {
    echo "$location : ",$timings[$location]," s\n";
  }
  echo "-->\n";

     } 
?>

</body>
</html>
<?php


  db_disconnect();
}

function beginModule($title,$name) {
  global $debug;
  global $timings;
  global $module_display;
  $timings[$title]=getmicrotime();

  $module_display_string="?";
  foreach (array_keys($module_display) as $module) {
    if (!($name == $module)) {
      $module_display_string=$module_display_string."_module_display[".$module."]=".$module_display[$module]."&";
    }
  }

  ?> 
  <table border='0' cellpadding='1' cellspacing='0' width='100%'>
    <tr class='ModuleTitle'><td>
        <table width='100%' cellpadding='0' cellspacing='0'>
          <tr bgcolor='#ffffff'><td>
             <table width='100%' cellpadding='2' cellspacing='0'>
               <tr class='ModuleTitle'><td><?php print $title; ?>&nbsp;<a href="<?php print $module_display_string."_module_display[".$name."]=0"; ?>" class="DelButton">[X]</a></td></tr>
               <tr><td class="ModuleBody">
<?php
}

function endModule($title) {
  global $debug;
  global $timings;
  $timings[$title]=getmicrotime()-$timings[$title];
?>
               </td></tr>
             </table>
          </td></tr>
       </table>
    </td></tr>
  </table>
  <?php
}

Return current item: IPTables log analyzer