Subversion Repositories ALCASAR

Rev

Go to most recent revision | Details | Last modification | View Log

Rev Author Line No. Line
318 richard 1
<?php 
2
/*
3
 * firewall Eyes
4
 * Copyright (C) 2004 Creabilis
5
 * 
6
 * This program is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or (at
9
 * your option) any later version.
10
 * 
11
 * This program is distributed in the hope that it will be useful, but
12
 * WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
 * 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
 */
21
include("configuration.php");
22
include("include.php");
23
 
24
// authentification check
25
authenticationCheck();
26
 
27
// Date in the past
28
header("Expires: Mon, 26 Jul 2004 00:00:00 GMT");
29
 
30
// always modified
31
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
32
 
33
// HTTP/1.1
34
header("Cache-Control: no-store, no-cache, must-revalidate");
35
header("Cache-Control: post-check=0, pre-check=0", false);
36
 
37
// HTTP/1.0
38
header("Pragma: no-cache");
39
 
40
set_time_limit (300);
41
 
42
// GET INPUT
43
// log file, get input or first logfile
44
$logfile=($_GET["logfile2display"] ? $logfiles[$_GET["logfile2display"]] : $logfiles[0]);
45
 
46
$displayedLines=($_GET["displayedLines"] ? $_GET["displayedLines"] : $configuration["displayedLines"]);
47
 
48
$configurationVars=Array("resolvIp","resolvService","readFromTheEnd","exactSearch","automaticRefresh");
49
foreach($configurationVars as $confVarName) {
50
	${$confVarName}=($_GET["searchAction"] ? $_GET[$confVarName] : $configuration[$confVarName]);
51
 
52
}
53
 
54
// init
55
$lineCount=0;
56
$indexForAction=getIndexForColumn("action",$logFields);
57
$indexForProtocol=getIndexForColumn("protocol",$logFields);
58
// get inputs
59
$criteria=$_GET["criteria"];
60
 
61
$maxWidth=0;
62
for($i=0; $i<count($logFields); $i++) {
63
	$maxWidth+=$logFields[$i][2];
64
}
65
?>
66
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
67
<html>
68
	<head>
69
		<title>Creabilis fw-Eyes</title>
70
		<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
71
		<link href="log.css" rel="stylesheet" type="text/css"/>
72
		<?php if ($automaticRefresh) {?>
73
		<meta http-equiv="refresh" content="<?=$automaticRefreshInterval?>"> 
74
		<?php } ?>
75
	</head>
76
 
77
	<body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0" bgcolor="#FFFFFF">
78
		<div align="left" style="padding-left:18px">
79
		<?php
80
		if(!file_exists ($logfile)) {
81
			die("Le fichier n'existe pas : $logfile");
82
		}
83
		if(!is_readable ($logfile)) {
84
			die("Ne peut pas lire le fichier : $logfile");
85
		}
86
 
87
		$fd = fopen ($logfile, "r");
88
 
89
		if ($readFromTheEnd){
90
			// to the end
91
			fseek($fd,0,SEEK_END);
92
		} 
93
		while (($readFromTheEnd ? ftell($fd)>0 : !feof ($fd))) {
94
			$line = ($readFromTheEnd ? fgetrs($fd) : fgets($fd, 1024));
95
			if(preg_match($detectLine, $line)) { // it's a firewall line
96
				if(preg_match($LineRegExp, $line, $infoTab)) {
97
					// resolv dns/services
98
					$infoTabOriginal=null;
99
					resolvAll();
100
					// Apply search array
101
					if(criteriaMatches($criteria,$logFields,$infoTab,$exactSearch)) {
102
						$lineCount++;
103
						$nb=($nb==1 ? 2 : 1); // for alternate display
104
						// line display
105
						?>
106
						<table class="<?=$infoTab[$indexForAction]?>" border="0" cellpadding="0" cellspacing="0" width="<?=$maxWidth?>">
107
						  <tr class="line<?=$nb?>">
108
							<?php
109
						for($i=0; $i<count($logFields); $i++) 
110
						{ 
111
							?>
112
							  <td title="<?=($infoTabOriginal[$logFields[$i][1]] ? $infoTabOriginal[$logFields[$i][1]]." - " : "")?><?=$infoTab[$logFields[$i][1]]?>">
113
								<span class="tabCell" style="width: <?=$logFields[$i][2]?>px" >
114
									<?php
115
									if($logFields[$i][4]) {
116
										?>
117
										<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>
118
										<?php
119
									}
120
 
121
									?>
122
								  &nbsp;<?=$infoTab[$logFields[$i][1]]?>
123
								</span>
124
							  </td>
125
						<?php 
126
						}?></tr>
127
						</table>
128
						<?php
129
						flush();
130
					}
131
 
132
				}
133
			}
134
			if($lineCount>=$displayedLines) break;
135
		}
136
		// close file
137
		fclose ($fd);
138
		?>
139
		<table border="0" cellpadding="0" cellspacing="0" width="<?=$maxWidth+2?>" class="footer">
140
		  <tr>
141
			<td align="center">
142
			<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>
143
			</td>
144
		  </tr>
145
		</table>
146
		</div>
147
	</body>
148
</html>