Subversion Repositories ALCASAR

Rev

Blame | Last modification | View Log

<?php 
/*
 * firewall Eyes
 * Copyright (C) 2004 Creabilis
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
include("configuration.php");
include("include.php");

// authentification check
authenticationCheck();

// Date in the past
header("Expires: Mon, 26 Jul 2004 00:00:00 GMT");

// always modified
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
 
// HTTP/1.1
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);

// HTTP/1.0
header("Pragma: no-cache");

set_time_limit (300);

// GET INPUT
// log file, get input or first logfile
$logfile=($_GET["logfile2display"] ? $logfiles[$_GET["logfile2display"]] : $logfiles[0]);

$displayedLines=($_GET["displayedLines"] ? $_GET["displayedLines"] : $configuration["displayedLines"]);

$configurationVars=Array("resolvIp","resolvService","readFromTheEnd","exactSearch","automaticRefresh");
foreach($configurationVars as $confVarName) {
        ${$confVarName}=($_GET["searchAction"] ? $_GET[$confVarName] : $configuration[$confVarName]);

}

// init
$lineCount=0;
$indexForAction=getIndexForColumn("action",$logFields);
$indexForProtocol=getIndexForColumn("protocol",$logFields);
// get inputs
$criteria=$_GET["criteria"];

$maxWidth=0;
for($i=0; $i<count($logFields); $i++) {
        $maxWidth+=$logFields[$i][2];
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
        <head>
                <title>Creabilis fw-Eyes</title>
                <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
                <link href="log.css" rel="stylesheet" type="text/css"/>
                <?php if ($automaticRefresh) {?>
                <meta http-equiv="refresh" content="<?=$automaticRefreshInterval?>"> 
                <?php } ?>
        </head>

        <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#FFFFFF">
                <div align="left" style="padding-left:18px">
                <?php
                if(!file_exists ($logfile)) {
                        die("Le fichier n'existe pas : $logfile");
                }
                if(!is_readable ($logfile)) {
                        die("Ne peut pas lire le fichier : $logfile");
                }

                $fd = fopen ($logfile, "r");

                if ($readFromTheEnd){
                        // to the end
                        fseek($fd,0,SEEK_END);
                } 
                while (($readFromTheEnd ? ftell($fd)>0 : !feof ($fd))) {
                        $line = ($readFromTheEnd ? fgetrs($fd) : fgets($fd, 1024));
                        if(preg_match($detectLine, $line)) { // it's a firewall line
                                if(preg_match($LineRegExp, $line, $infoTab)) {
                                        // resolv dns/services
                                        $infoTabOriginal=null;
                                        resolvAll();
                                        // Apply search array
                                        if(criteriaMatches($criteria,$logFields,$infoTab,$exactSearch)) {
                                                $lineCount++;
                                                $nb=($nb==1 ? 2 : 1); // for alternate display
                                                // line display
                                                ?>
                                                <table class="<?=$infoTab[$indexForAction]?>" border="0" cellpadding="0" cellspacing="0" width="<?=$maxWidth?>">
                                                  <tr class="line<?=$nb?>">
                                                        <?php
                                                for($i=0; $i<count($logFields); $i++) 
                                                { 
                                                        ?>
                                                          <td title="<?=($infoTabOriginal[$logFields[$i][1]] ? $infoTabOriginal[$logFields[$i][1]]." - " : "")?><?=$infoTab[$logFields[$i][1]]?>">
                                                                <span class="tabCell" style="width: <?=$logFields[$i][2]?>px" >
                                                                        <?php
                                                                        if($logFields[$i][4]) {
                                                                                ?>
                                                                                <a href="info.php?type=<?=urlencode($logFields[$i][4])?>&p1=<?=urlencode($infoTab[$logFields[$i][1]])?>" title="informations"><img src="images/<?=str_replace(" ","-",($logFields[$i][0]))?>.gif" width="15" height="15" border="0" align="absmiddle"></a>
                                                                                <?php
                                                                        }
                                                                        
                                                                        ?>
                                                                  &nbsp;<?=$infoTab[$logFields[$i][1]]?>
                                                                </span>
                                                          </td>
                                                <?php 
                                                }?></tr>
                                                </table>
                                                <?php
                                                flush();
                                        }

                                }
                        }
                        if($lineCount>=$displayedLines) break;
                }
                // close file
                fclose ($fd);
                ?>
                <table border="0" cellpadding="0" cellspacing="0" width="<?=$maxWidth+2?>" class="footer">
                  <tr>
                        <td align="center">
                        <A HREF="http://www.creabilis.com" target="creabilis">Firewall Eyes</A> - <A HREF="http://www.gnu.org/licenses/gpl.html">GPL</A> - Creabilis © 2004 - Web site : <A HREF="http://firewalleyes.creabilis.com">http://firewalleyes.creabilis.com</A>
                        </td>
                  </tr>
                </table>
                </div>
        </body>
</html>