-
Notifications
You must be signed in to change notification settings - Fork 18
/
logout.php
95 lines (76 loc) · 2.79 KB
/
logout.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?PHP
//Include PFsense functions
require_once("auth.inc");
require_once("functions.inc");
require_once("captiveportal.inc");
session_start();
//Do not cache pages
header("Expires: 0");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
header("Connection: close");
//MySQL Configuration
$dbhost = '127.0.0.1';
$dbuser = 'radius';
$dbpass = 'radpass';
$dbname = 'radius';
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Telenor WIFI</title>
<link href="captiveportal-bootstrap.min.css" rel="stylesheet">
</head>
<body>
<div class="container">
<img src="captiveportal-logo.jpg" class="img-responsive" alt="Responsive image">
<script src="captiveportal-jquery.min.js"></script>
<script src="captiveportal-bootstrap.min.js"></script>
<?php
//PFSense functions to resolve mac
$clientip = $_SERVER['REMOTE_ADDR'];
if (!$clientip) {
/* not good - bail out */
log_error("Zone: {$cpzone} - Captive portal could not determine client's IP address.");
$error_message = "An error occurred. Please check the system logs for more information.";
portal_reply_page($redirurl, "error", $errormsg);
ob_flush();
return;
}
$macfilter = !isset($cpcfg['nomacfilter']);
$passthrumac = isset($cpcfg['passthrumacadd']);
/* find MAC address for client */
if ($macfilter || $passthrumac) {
$tmpres = pfSense_ip_to_mac($clientip);
if (!is_array($tmpres)) {
/* unable to find MAC address - shouldn't happen! - bail out */
captiveportal_logportalauth("unauthenticated","noclientmac",$clientip,"ERROR");
echo "An error occurred. Please check the system logs for more information.";
log_error("Zone: {$cpzone} - Captive portal could not determine client's MAC address. Disable MAC address filtering in captive portal if you do not need this functionality.");
ob_flush();
return;
}
$mac = $tmpres['macaddr'];
unset($tmpres);
}
if(!$mac) die("Error! Could not identify your device");
print "<pre>Logging out (mac: $mac)</pre>";
$con = mysql_connect($dbhost, $dbuser, $dbpass,$dbname) or die("Database error: connect failed ".mysql_error());
//Clean old MAC addresses
$clean = "DELETE FROM `radius`.`radcheck` where `username`= '$mac'";
mysql_query($clean);
mysql_close($con);
print "<h2>You have been logged out</h2>";
print "<p>Thansk for using Telenor WIFI</p><br/><br/>";
print "<p>Note! It can take up to 5 min before your connection are closed</p>";
unset($_POST);
session_unset();
session_destroy();
?>
</div>
</body>
</html>