-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhere-miss.php
72 lines (64 loc) · 1.51 KB
/
here-miss.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
<?php
//// Here, Miss.
// An DoNotTrack detection script that ignores settings done automatically.
// Copyright 2022 eustasy UK Ltd - MIT Licensed
//
//// Inputs
//
// $respectIE = bool(false)
// A boolean value on whether to respect later IE versions that turn on DoNotTrack by default.
// Defaults to `false`
//
//// Outputs
//
// $iev = int(11)
// The Internet Explorer version. An integer if Internet Explorer, `false` if not.
//
// $isie = bool(true)
// A boolean value to check if this is Internet Explorer.
//
// $dnt = bool(false)
// A boolean value that states whether the DoNotTrack header was set.
//
// $trackme = bool(true)
// A boolean value that states whether the user allows tracking.
$iev = false;
$isie = false;
$dnt = false;
if ( isset($_SERVER['HTTP_USER_AGENT']) ) {
$ua = htmlentities($_SERVER['HTTP_USER_AGENT']);
} else {
$ua = false;
}
if ( !isset($respectIE) ) {
$respectIE = false;
}
// 5 - 10
$msie = strrpos($ua, 'MSIE ');
if ( $msie !== false ) {
$iev = intval(substr($ua, ($msie + 5), strrpos($ua, '.', $msie)));
// >= 11 (Majority)
} elseif ( strrpos($ua, 'Trident/') !== false ) {
$rv = strrpos($ua, 'rv:');
$iev = intval(substr($ua, ($rv + 3), strrpos($ua, '.', $rv)));
}
// No detection of 0 - 4
// Rarely used.
// If is IE, mark it as so.
if ( $iev ) {
$isie = true;
}
if (
// If DNT is on
isset($_SERVER['HTTP_DNT']) &&
$_SERVER['HTTP_DNT'] &&
(
// AND you are not using IE 10 or later
$iev < 10 ||
// OR we were asked to respect it
$respectIE
)
) {
$dnt = true;
}
$trackme = !$dnt;