forked from qian-jiahong/uvncrep017-ws
-
Notifications
You must be signed in to change notification settings - Fork 3
/
webPage.php
131 lines (128 loc) · 3.39 KB
/
webPage.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
<?php
require("lib.php");
$time_start = microtime(true);
$currentDate = strtotime('-15 minutes');
$filePathVNC="/var/log/uvncrepeater.log";
$filePathVNC_INI="/etc/uvnc/uvncrepeater.ini";
$vncFile=file($filePathVNC);
$vncIniFile=file($filePathVNC_INI);
$vpnFile=file("/etc/openvpn/openvpn-status.log");
$string1="Virtual Address,Common Name,Real Address,Last Ref";
$string2="GLOBAL STATS";
$connected="vncWebInterface";
$users=array();
$usersFound=array();
$startList=0;
for($i=0; $i<count($vncIniFile); $i++){ //example: idlist0=9734734;Username
if( strpos($vncIniFile[$i],"idlist") !== false &&
explode("idlist",$vncIniFile[$i])[0] == "" && // nothing before the string
($string=explode("=",$vncIniFile[$i])[1]) != "" && // 9734734;Username
($idListStr=explode("=",$vncIniFile[$i])[0])!= "" && // idlist0
($usrID=explode(";",$string)[0]) != "" && // 9734734
(
($usrName=trim(explode(";",$string)[1])) != "" || // 9734734
($usrName=trim(explode("=",$vncIniFile[$i])[0]))!= "" // if there is no username use the idlistString
) &&
$usrID!="0"
){
$info=array("name" => $usrName,
"date" => "",
"ip" => "-"
);
$users[$usrID] =$info;
$usersFound[$usrID] =false;
}
}
$counter=0;
$goalCounter=count($users);
for($i=count($vncFile); $i>0 && $counter<$goalCounter; $i--){
foreach ($usersFound as $usrID => $value){
if( strpos($vncFile[$i],strval($usrID)) !== false &&
strpos($vncFile[$i],$connected) !== false
){
$line=$vncFile[$i];
$p1=explode("Vnc", $line)[1];
$data=explode(">",$p1)[0];
$ip=explode($usrID."<", $line)[1];
$users[$usrID]["date"]=$data;
$users[$usrID]["ip"]=$ip;
unset($usersFound[$usrID]);
$counter++;
break;
}
}
}
?>
<html>
<head>
<title>
Online VNC Viewer
</title>
<style>
table, td, th {
border: 1px solid #ddd;
text-align: center;
}
table {
border-collapse: collapse;
width: 40%;
}
th, td {
padding: 15px;
}
</style>
</head>
<body>
<h3>VNC ONLINE TABLE</h3>
<textarea id="w3mission" rows="4" cols="50" style="width:900px;height:300px;float:right"><?php
echo tailCustom($filePathVNC, $lines = 17, $adaptive = true);
?></textarea>
<table>
<tr>
<th>
Name
</th>
<th>
ID
</th>
<th>
Date
</th>
<th>
IP
</th>
</tr>
<?php foreach ($users as $key => $value){ ?>
<tr>
<td>
<?= $users[$key]["name"] ?>
</td>
<td>
<?= $key ?>
</td>
<?php
if($users[$key]["date"]!=""){
$localDate=strtotime($users[$key]["date"]);
if($localDate>$currentDate){
echo "<td style='color:#39c35c'>".$users[$key]["date"]."</td>";
}else{
echo "<td style='color:red'>".$users[$key]["date"]."</td>";
}
}else{
echo "<td>Never seen</td>";
}
?>
<td>
<?= $users[$key]["ip"]?>
</td>
</tr>
<?php } ?>
</table>
<br><br>
<?php
echo "Last Check: ".date("d/m/Y - h:i:s a");
echo '<br>Total execution time in seconds: ' . (microtime(true) - $time_start);
?>
<script>setTimeout(function(){ location.reload(); }, 10000);</script>
</body>
</html>