summaryrefslogtreecommitdiff
path: root/gui/checkra.php
blob: 4354b7399ee8a3788d885ca78c631c0b3a00e120 (plain)
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
<html>
<head>
<meta http-equiv="refresh" content="1; url=checkra.php">
</head>
<body>
<?php
function get_status()
{
	exec("sudo -H /usr/sbin/rapid-tunneling-status -p", $pid, $status);
	if (count($pid) > 0)
		$pid = trim($pid[0]);
	else
		$pid = "";
	return array($pid, $status);
	// $status = 0 if connected, 1 if connecting, 2 if not connected
}

$res = get_status();
$pid = $res[0];
$status = $res[1];
if (isset($_REQUEST["action"]) && $_REQUEST["action"] == "disconnect" && $pid != "" && ($status == 0 || $status == 1)) {
	// stop it
	exec("sudo -H /usr/sbin/rapid-tunneling-status -s");
	$res = get_status();
	$pid = $res[0];
	$status = $res[1];
}

if ($status == 0)
	$netstat = "<span style='color: green'>Connected</span>";
elseif ($status == 1)
	$netstat = "<span style='color: orange'>Connecting</span>";
else
	$netstat = "<span style='color: red'>Not connected</span>";

echo "Connection status:<br>\n";
echo date("r") . "&nbsp;&nbsp;&nbsp; <b>$netstat</b><br>\n";
if ($status == 0 || $status == 1) {
	echo "<br><button onclick='location.href += \"?action=disconnect\"'>Disconnect</button>";
	echo "<noscript>(Javascript is required for disconnect to work)</p></noscript>";
}
?>
</body>
</html>