blob: 906cb0ae520bf518ff9040b69fbf4857bd8bb26e [file] [log] [blame]
Brian Waters13d96012017-12-08 16:53:31 -06001<?php
2
3# This file is an example wrapper around display_results.php.
4
5# It relies on clients authentication based on certificate usage
6# (it must be the same certificate as used during AAA access, so that the User-Name matches).
7# See your web server documentation for details.
8# Example for apache2:
9# (+ detail in http://httpd.apache.org/docs/2.0/ssl/ssl_howto.html#allclients )
10# - in vhost definition file, refence the CA chain of your users certificates:
11# SSLCACertificateFile /var/www/conf/ssl.crt/ca.crt
12# - in vhost file or .htaccess file (adjust Depth to your setup):
13# <IfModule mod_ssl.c>
14# SSLVerifyClient require
15# SSLVerifyDepth 2
16# </IfModule>
17
18/* Check the client is correctly SSL authenticated with his server */
19if (!isset($_SERVER["SSL_CLIENT_VERIFY"]) || $_SERVER["SSL_CLIENT_VERIFY"] != "SUCCESS")
20 die("SSL authentication failed, the webserver is probably not configured correctly.\n");
21
22/* Force some parameters to integer values */
23if ($_GET["t_limit"])
24 $_GET["t_limit"] = (int) $_GET["t_limit"];
25if ($_GET["t_offset"])
26 $_GET["t_offset"] = (int) $_GET["t_offset"];
27
28/* Default form values */
29if (!isset($_GET["Submit"])) {
30 $_GET["t_limit"] = 50;
31 $_GET["c_limit"] = 1;
32 $_GET["t_offset"] = 0;
33}
34
35/* Output the form */
36?>
37<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
38<html lang="en-US">
39<head>
40 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
41
42 <title>Accounting Data</title>
43 <meta name="description" content="This page gives you access to your personal accounting data.">
44 <meta name="keywords" content="accounting">
45
46 <style type="text/css">
47 body { text-align:center; }
48 table { border-collapse:collapse; margin-left:auto; margin-right:auto; }
49 table, td, th { border:1px solid green; padding-left:.5em; padding-right:.5em;}
50 th { background-color:green; color:white; }
51 </style>
52</head>
53
54<body >
55 <h1>Accounting data</h1>
56 <p>Note well: this page displays only data about <em>terminated</em> sessions.</p>
57 <form method="GET">
58 <table>
59 <tr>
60 <th colspan="3">
61 Filtering parameters
62 </th>
63 </tr>
64 <tr>
65 <td><input type="checkbox" name="c_starttime"<?php if (isset($_GET["c_starttime"])) echo " checked"; ?>></td>
66 <td>Show only sessions starting from (<a href="http://www.postgresql.org/docs/8.4/static/datatype-datetime.html">YYYY-MM-DD HH:MM:SS</a>):</td>
67 <td><input type="text" name="t_starttime"<?php if (isset($_GET["t_starttime"])) echo 'value="'.$_GET["t_starttime"].'"'; ?>></td>
68 </tr>
69 <tr>
70 <td><input type="checkbox" name="c_endtime"<?php if (isset($_GET["c_endtime"])) echo " checked"; ?>></td>
71 <td>Show only sessions starting until (<a href="http://www.postgresql.org/docs/8.4/static/datatype-datetime.html">YYYY-MM-DD HH:MM:SS</a>):</td>
72 <td><input type="text" name="t_endtime"<?php if (isset($_GET["t_endtime"])) echo 'value="'.$_GET["t_endtime"].'"'; ?>></td>
73 </tr>
74 <tr>
75 <td><input type="checkbox" name="c_limit"<?php if (isset($_GET["c_limit"])) echo " checked"; ?>></td>
76 <td>Show only this number of records:</td>
77 <td><input type="text" name="t_limit"<?php if (isset($_GET["t_limit"])) echo 'value="'.$_GET["t_limit"].'"'; ?>></td>
78 </tr>
79 <tr>
80 <td><input type="checkbox" name="c_offset"<?php if (isset($_GET["c_offset"])) echo " checked"; ?>></td>
81 <td>Starting from record:</td>
82 <td><input type="text" name="t_offset"<?php if (isset($_GET["t_offset"])) echo 'value="'.$_GET["t_offset"].'"'; ?>></td>
83 </tr>
84 <tr>
85 <th colspan="3">
86 Apply this filter: <input type="submit" name="Submit">
87 </th>
88 </tr>
89 </table>
90 </form>
91
92<p>
93 Currently displaying user <em><?php echo htmlentities($_SERVER["SSL_CLIENT_S_DN_CN"]); ?></em><?php
94
95/* Search user by CN or Email since some OS use the later during EAP-TLS authentication */
96$USERS = array($_SERVER["SSL_CLIENT_S_DN_CN"], $_SERVER["SSL_CLIENT_S_DN_Email"]);
97
98/* If the start time boundary was specified... */
99if ($_GET["c_starttime"] && $_GET["t_starttime"]) {
100 $START_TIME=$_GET["t_starttime"];
101}
102if ($_GET["c_endtime"] && $_GET["t_endtime"]) {
103 $END_TIME=$_GET["t_endtime"];
104}
105
106/* idem with end time */
107if ($START_TIME && $END_TIME) {
108 echo ", sessions starting between $START_TIME and $END_TIME";
109} elseif ($START_TIME) {
110 echo ", sessions starting after $START_TIME";
111} elseif ($END_TIME) {
112 echo ", sessions starting before $END_TIME";
113}
114
115/* Pagination */
116if ($_GET["c_limit"] && $_GET["t_limit"]) {
117 $LIMIT=$_GET["t_limit"];
118}
119if ($_GET["c_offset"] && $_GET["t_offset"]) {
120 $LIMIT_OFFSET=$_GET["t_offset"];
121}
122if ($LIMIT) {
123 echo ", limited to ".$LIMIT." records";
124 if ($LIMIT_OFFSET)
125 echo " starting at ".$LIMIT_OFFSET;
126} else if ($LIMIT_OFFSET) {
127 echo " starting at record ".$LIMIT_OFFSET;
128}
129echo ".\n";
130?>
131</p>
132
133<?php
134/* This file will generate the array of data matching the selection */
135require("display_results.php");
136
137?>
138</body>
139</html>