diag_logs_vpn.inc 4.26 KB
Newer Older
Ad Schellevis's avatar
Ad Schellevis committed
1
<?php
2

Ad Schellevis's avatar
Ad Schellevis committed
3
/*
4
	Copyright (C) 2014 Deciso B.V.
5
	Copyright (C) 2003-2006 Manuel Kasper <mk@neon1.net>
Ad Schellevis's avatar
Ad Schellevis committed
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
	All rights reserved.

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

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

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

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

30
require_once("guiconfig.inc");
Ad Schellevis's avatar
Ad Schellevis committed
31
require_once("vpn.inc");
32
require_once("system.inc");
33
require_once("interfaces.inc");
Ad Schellevis's avatar
Ad Schellevis committed
34

35 36 37 38 39
if (empty($config['syslog']['nentries'])) {
        $nentries = 50;
} else {
        $nentries = $config['syslog']['nentries'];
}
Ad Schellevis's avatar
Ad Schellevis committed
40 41

if ($_POST['clear']) {
42
	clear_clog($logfile);
Ad Schellevis's avatar
Ad Schellevis committed
43 44
}

45 46 47
function dump_clog_vpn($logfile, $tail, $logtype)
{
	global $config;
Ad Schellevis's avatar
Ad Schellevis committed
48 49 50 51

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

	$logarr = "";
52

53
	exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . " | tail {$sor} -n " . $tail, $logarr);
Ad Schellevis's avatar
Ad Schellevis committed
54

55
	foreach ($logarr as $logent) {
Ad Schellevis's avatar
Ad Schellevis committed
56 57 58
		$logent = preg_split("/\s+/", $logent, 6);
		$llent = explode(",", $logent[5]);
		$iftype = substr($llent[1], 0, 4);
59
		if ($iftype != $logtype) {
Ad Schellevis's avatar
Ad Schellevis committed
60
			continue;
61
		}
Ad Schellevis's avatar
Ad Schellevis committed
62 63 64 65
		echo "<tr>\n";
		echo "<td class=\"listlr nowrap\">" . htmlspecialchars(join(" ", array_slice($logent, 0, 3))) . "</td>\n";

		if ($llent[0] == "login")
66
			echo "<td class=\"listr\"><span class=\"glyphicon glyphicon-arrow-right\" aria-hidden=\"true\" alt=\"in\"></span></td>\n";
Ad Schellevis's avatar
Ad Schellevis committed
67
		else
68
			echo "<td class=\"listr\"><span class=\"glyphicon glyphicon-arrow-left\" aria-hidden=\"true\" alt=\"out\"></span></td>\n";
Ad Schellevis's avatar
Ad Schellevis committed
69 70 71 72 73 74 75 76 77 78

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

include("head.inc");

?>
79 80 81 82


<body>

Ad Schellevis's avatar
Ad Schellevis committed
83
<?php include("fbegin.inc"); ?>
84 85

	<section class="page-content-main">
86
		<div class="container-fluid">
87
			<div class="row">
88

89
				<?php if (isset($input_errors) && count($input_errors) > 0) print_input_errors($input_errors); ?>
90

91
			    <section class="col-xs-12">
92 93 94 95

					<div class="tab-content content-box col-xs-12">


96
							 <div class="table-responsive">
97
								<table class="table table-striped table-sort">
98 99 100 101 102 103 104
									<tr><td colspan="4">
										<ul class="nav nav-pills" role="tablist">
										<?php foreach ($tab_array as $tab): ?>
											<li role="presentation" <?php if (str_replace('amp;','', $tab[2]) == $_SERVER['REQUEST_URI']):?>class="active"<?php endif; ?>><a href="<?=$tab[2];?>"><?=$tab[0];?></a></li>
										<?php endforeach; ?>
										</ul>
									</td></tr>
105
									 <?php if ($mode != "raw"): ?>
106 107 108 109 110 111
										<tr>
											<td class="listhdrr"><?=gettext("Time");?></td>
											<td class="listhdrr"><?=gettext("Action");?></td>
											<td class="listhdrr"><?=gettext("User");?></td>
											<td class="listhdrr"><?=gettext("IP address");?></td>
										</tr>
112
										<?php dump_clog_vpn($logfile, $nentries, $logname); ?>
113
										<?php else:
114
											dump_clog($logfile, $nentries);
115
									  endif; ?>
Franco Fichtner's avatar
Franco Fichtner committed
116
							<tr><td colspan="4">
117
							<form action="<? $_SERVER['REQUEST_URI'] ?>" method="post">
118 119 120
								<input type="hidden" name="mode" id="mode" value="<?=$mode;?>" />
								<input name="clear" type="submit" class="btn" value="<?= gettext("Clear log");?>" />
							</form>
Franco Fichtner's avatar
Franco Fichtner committed
121 122 123
							</td></tr>
								</table>
							 </div>
124 125


126
				    </div>
127
			</section>
128 129 130
			</div>
		</div>
	</section>
131 132

<?php include("foot.inc"); ?>