/
visit.php
79 lines (64 loc) · 2.89 KB
/
visit.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
<html>
<?php
include_once 'core/functions.php';
sec_session_start();
$pid = htmlspecialchars($_GET["pid"]);
$url = getURLFromPID($mysqli, $pid);
if (isset($_COOKIE["setting"]))
$nightmode = $_COOKIE["setting"]["nightmode"];
$ssl = checkForSSL($url);
/* open session, we store the opening time to find the correct dataset later without echoing the pid as it could be used to manipulate another entry */
$openTime = openPageSession($mysqli, $pid);
$_SESSION["sNR" . ($openTime * $pid)] = array($openTime, $pid);
?>
<head>
<meta charset="UTF-8">
<title><?php echo CONST_PROJNAME ?></title>
<link rel="stylesheet" href="<?php if ($nightmode) { echo "nm"; } ?>style.css" />
<script>
window.onload = function () {
startTime(Date.now());
};
window.onunload = window.onbeforeunload = (function(){
closeSession();
})
function startTime(StartFrom) {
start = StartFrom;
countTo = new Date();
difference = (countTo - start);
days = Math.floor(difference / (60 * 60 * 1000 * 24) * 1);
hours = Math.floor((difference % (60 * 60 * 1000 * 24)) / (60 * 60 * 1000) * 1);
mins = Math.floor(((difference % (60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) / (60 * 1000) * 1);
secs = Math.floor((((difference % (60 * 60 * 1000 * 24)) % (60 * 60 * 1000)) % (60 * 1000)) / 1000 * 1);
days = days < 10 ? "0" + days : days;
hours = hours < 10 ? "0" + hours : hours;
mins = mins < 10 ? "0" + mins : mins;
secs = secs < 10 ? "0" + secs : secs;
document.getElementById('uptime').innerHTML = (days > 0 ? days + "d, " : "") + hours + ":" + mins + ":" + secs;
clearTimeout(startTime.to);
startTime.to = setTimeout(function () { startTime(StartFrom); }, 1000);
}
function closeSession() {
var xhttp = new XMLHttpRequest();
xhttp.open("POST", "api/closePage.php", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("spid=" + <?php echo $openTime * $pid; ?>);
}
</script>
</head>
<body>
<a style="font-size: 14px; float: left;" href="/">◄ Zurück zu LoginWell </a>
<div style="float: right;">Online-Zeit: <div id="uptime" style="float: right;"></div> </div>
<br/>
<div class="content">
<iframe src="<?php
if ($ssl) {
echo "https";
} else {
echo "http";
}
?>://<?php echo $url; ?>" width="100%" height="96%">
</iframe>
</div>
</body>
</html>