Project

General

Profile

Download (5.45 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/usr/local/bin/php
2
<?php
3
/*
4
	diag_logs_vpn.php
5
	part of m0n0wall (http://m0n0.ch/wall)
6

    
7
	Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>.
8
	All rights reserved.
9

    
10
	Redistribution and use in source and binary forms, with or without
11
	modification, are permitted provided that the following conditions are met:
12

    
13
	1. Redistributions of source code must retain the above copyright notice,
14
	   this list of conditions and the following disclaimer.
15

    
16
	2. Redistributions in binary form must reproduce the above copyright
17
	   notice, this list of conditions and the following disclaimer in the
18
	   documentation and/or other materials provided with the distribution.
19

    
20
	THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
21
	INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
22
	AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23
	AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
	OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
	SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
	INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
	CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
	ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
	POSSIBILITY OF SUCH DAMAGE.
30
*/
31

    
32
/*	
33
	pfSense_BUILDER_BINARIES:	/usr/sbin/fifolog_reader	/usr/sbin/clog
34
	pfSense_MODULE:	vpn
35
*/
36

    
37
##|+PRIV
38
##|*IDENT=page-diagnostics-logs-pptpvpn
39
##|*NAME=Diagnostics: Logs: VPN page
40
##|*DESCR=Allow access to the 'Diagnostics: Logs: VPN' page.
41
##|*MATCH=diag_logs_vpn.php*
42
##|-PRIV
43

    
44
$pgtitle = array(gettext("Status"), gettext("System logs"), gettext("VPN"));
45
require("guiconfig.inc");
46
require_once("vpn.inc");
47

    
48
$nentries = $config['syslog']['nentries'];
49
if (!$nentries)
50
	$nentries = 50;
51

    
52
if ($_GET['vpntype'])
53
	$vpntype = $_GET['vpntype'];
54
else
55
	$vpntype = "pptp";
56
if ($_POST['vpntype'])
57
	$vpntype = $_POST['vpntype'];
58

    
59
if ($_POST['clear']) 
60
	clear_log_file("/var/log/{$vpntype}.log");
61

    
62
function dump_clog_vpn($logfile, $tail) {
63
	global $g, $config;
64

    
65
	$sor = isset($config['syslog']['reverse']) ? "-r" : "";
66

    
67
	$logarr = "";
68
	
69
	if(isset($config['system']['usefifolog'])) 
70
		exec("/usr/sbin/fifolog_reader " . $logfile . " | tail {$sor} -n " . $tail, $logarr);
71
	else 
72
		exec("/usr/sbin/clog " . $logfile . " | grep -v \"CLOG\" | grep -v \"\033\" | tail {$sor} -n " . $tail, $logarr);
73

    
74
	foreach ($logarr as $logent) {
75
		$logent = preg_split("/\s+/", $logent, 6);
76
		$llent = explode(",", $logent[5]);
77

    
78
		echo "<tr>\n";
79
		echo "<td class=\"listlr\" nowrap>" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "</td>\n";
80

    
81
		if ($llent[0] == "login")
82
			echo "<td class=\"listr\"><img src=\"/themes/{$g['theme']}/images/icons/icon_in.gif\" width=\"11\" height=\"11\" title=\"login\"></td>\n";
83
		else
84
			echo "<td class=\"listr\"><img src=\"/themes/{$g['theme']}/images/icons/icon_out.gif\" width=\"11\" height=\"11\" title=\"logout\"></td>\n";
85

    
86
		echo "<td class=\"listr\">" . htmlspecialchars($llent[3]) . "</td>\n";
87
		echo "<td class=\"listr\">" . htmlspecialchars($llent[2]) . "&nbsp;</td>\n";
88
		echo "</tr>\n";
89
	}
90
}
91

    
92
include("head.inc");
93

    
94
?>
95
<body link="#0000CC" vlink="#0000CC" alink="#0000CC">
96
<?php include("fbegin.inc"); ?>
97
<table width="100%" border="0" cellpadding="0" cellspacing="0">
98
  <tr><td class="tabnavtbl">
99
<?php
100
	$tab_array = array();
101
	$tab_array[] = array(gettext("System"), false, "diag_logs.php");
102
	$tab_array[] = array(gettext("Firewall"), false, "diag_logs_filter.php");
103
	$tab_array[] = array(gettext("DHCP"), false, "diag_logs_dhcp.php");
104
	$tab_array[] = array(gettext("Portal Auth"), false, "diag_logs_auth.php");
105
	$tab_array[] = array(gettext("IPsec"), false, "diag_logs_ipsec.php");
106
	$tab_array[] = array(gettext("PPP"), false, "diag_logs_ppp.php");
107
	$tab_array[] = array(gettext("VPN"), true, "diag_logs_vpn.php");
108
	$tab_array[] = array(gettext("Load Balancer"), false, "diag_logs_relayd.php");
109
	$tab_array[] = array(gettext("OpenVPN"), false, "diag_logs_openvpn.php");
110
	$tab_array[] = array(gettext("OpenNTPD"), false, "diag_logs_ntpd.php");
111
	$tab_array[] = array(gettext("Settings"), false, "diag_logs_settings.php");
112
	display_top_tabs($tab_array);
113
?>
114
  </td></tr>
115
  <tr>
116
    <td class="tabcont">
117
<form action="diag_logs_vpn.php" method="post">
118
		<table width="100%" border="0" cellpadding="0" cellspacing="0"><tr>
119
		  <td colspan="4" class="listtopic">
120
			<?=gettext("Choose which type of VPN you want to view.");?>
121
		  </td></tr><tr>
122
		  <td colspan="4">
123
			<?php $vpns = array("pptp" => gettext("PPTP"), "pppoe" => gettext("PPPoE"), "l2tp" => gettext("L2TP"));
124
				foreach ($vpns as $kvpn => $dvpn):
125
			?>
126
				<a href="/diag_logs_vpn.php?vpntype=<?=$kvpn;?>" >
127
				<input type="button" name="<?=$dvpn;?>" value="<?=$dvpn;?>"> 
128
				</a>
129
			<?php endforeach; ?>
130
			
131
		  </td></tr>
132
		  <tr>
133
		  <td colspan="4" class="listtopic">
134
				<?php printf(gettext("Last %s %s VPN log entries"),$nentries,$vpns[$vpntype]);?></td>
135
			</tr>
136
			<tr>
137
			  <td class="listhdrr"><?=gettext("Time");?></td>
138
			  <td class="listhdrr"><?=gettext("Action");?></td>
139
			  <td class="listhdrr"><?=gettext("User");?></td>
140
			  <td class="listhdrr"><?=gettext("IP address");?></td>
141
			</tr>
142
			<?php dump_clog_vpn("/var/log/{$vpntype}.log", $nentries); ?>
143
          </table>
144
<br />
145
<input type="hidden" name="vpntype" id="vpntype" value="<?=$vpntype;?>">
146
<input name="clear" type="submit" class="formbtn" value="<?=gettext("Clear log"); ?>">
147
</form>
148
	</td>
149
  </tr>
150
</table>
151
<?php include("fend.inc"); ?>
(26-26/222)