/
404.php
113 lines (94 loc) · 3.54 KB
/
404.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
<?php
$no_mac_register = 1;
require_once('functions.php');
$appleMagicNames = [
'/library/test/success.html',
'/hotspot-detect.html'
];
$msMagicNames = [
'/ncsi.txt'
];
$androidMagicNames = [
'/generate_204'
];
// 192.168.1.207 captive.apple.com - [07/May/2016:01:11:00 -0400] "GET /hotspot-detect.html HTTP/1.0" 200 1028 "-" "CaptiveNetworkSupport-325.10.1 wispr"
$magicNames = array_merge($appleMagicNames, $msMagicNames, $androidMagicNames);
$uri = $_SERVER['REQUEST_URI'];
$agent = $_SERVER['HTTP_USER_AGENT'];
// 192.168.1.207 captive.apple.com - [07/May/2016:01:13:24 -0400] "GET /hotspot-detect.html HTTP/1.0" 200 1350 "-" "CaptiveNetworkSupport-325.10.1 wispr"
// 192.168.1.207 captive.apple.com - [07/May/2016:01:13:25 -0400] "GET /hotspot-detect.html HTTP/1.1" 404 742 "-" "Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13E238"
// 192.168.1.207 captive.apple.com - [07/May/2016:01:13:25 -0400] "GET /style.css HTTP/1.1" 200 1031 "http://captive.apple.com/hotspot-detect.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13E238"
// 192.168.1.207 captive.apple.com - [07/May/2016:01:13:26 -0400] "GET /logo.png HTTP/1.1" 200 3551 "http://captive.apple.com/hotspot-detect.html" "Mozilla/5.0 (iPhone; CPU iPhone OS 9_3_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Mobile/13E238"
//
if(in_array($uri, $magicNames)) {
// This request is for one of the portal detectors
$mac = getClientMac();
if(isMacSet($mac)) {
// We've been here, so give them the real thing.
if(in_array($uri, $appleMagicNames)) {
printAppleSuccess();
exit;
} else if(in_array($uri, $msMagicNames)) {
printMsSuccess();
exit;
} else {
// Hmmm....
printAppleSuccess();
exit;
}
} else {
// First time. Show them the portal page or 404?
printWelcome();
exit;
}
} else {
// Not one of the magic names, so legit 404...
httperr(404, 'Not Found', true);
printWelcome();
exit;
}
function printAppleSuccess() {
header('Content-type: text/html');
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<TITLE>Success</TITLE>
</HEAD>
<BODY>
Success
</BODY>
</HTML>
<?php }
function printMsSuccess() {
header('Content-type: text/plain');
echo "Microsoft NCSI\n";
}
function printWelcome() {
global $domainName;
printHeader(-1);
?>
<div class="box">
<h1>What's This?!?</h1>
<p>You've discovered a Sunny+Share box placed near-by by someone who
values sharing and collaboration in the local area.
</p>
<p class="readme">This WiFi access point does <b>NOT</b> provide access to the internet.
If you need to get online, you should disconnect now & try a different
access point.
</p>
<p>This service provides a free, anonymous sharing platform for the local
area. If you continue, you can access files left by others as well as
share anything you think others near-by might enjoy. For more info
about this system, see <a href="http://<?= $domainName ?>/about.php">About Sunny+Share</a>.
</p>
<p style="text-align:center;">If you'd like to connect and access this service, just press the button:<br/>
<br/>
<a style="margin-left: auto; margin-right:auto;" class="okbtn" href="http://<?= $domainName ?>/">Continue</a>
</p>
<h2>You can come back here later by connecting to this WiFi and going to
<a href="http://<?= $domainName ?>/">http://<?= $domainName ?>/</a>.</h2>
</div>
<?php
printFooter();
}
?>