-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconsole.php
More file actions
28 lines (21 loc) · 740 Bytes
/
console.php
File metadata and controls
28 lines (21 loc) · 740 Bytes
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
<?php
// START SESSION
session_start();
// ASSIGN HOST VARIABLE
$host = $_SERVER['HTTP_HOST'];
// LOGOUT REQUEST
if (isset($_POST["logout"])) { unset($_SESSION["user"]); }
// REDIRECT TO LOGIN PAGE IF NOT LOGGED IN
if (!isset($_SESSION["user"])) {
header("Location: login.php");
exit();
}
// PULL VM VNC PORT
$vncport = $_GET['vncport'];
// KILL ANY RUNNING WEBSOCKIFY SESSIONS TO PREVENT CONFLICTS
$killstr = shell_exec('killall websockify > /dev/null 2>/dev/null &');
// CREATE NEW WEBSOCKIFY SESSION
$vncstr = shell_exec('/var/www/html/noVNC/utils/novnc_proxy --vnc localhost:' . $vncport . ' --idle-timeout 10 > /dev/null 2>/dev/null &');
// OPEN NOVNC DISPLAY PAGE
header('location: http://' . $host . ':6080/vnc.html');
?>