";
$opstring .= "
" . htmlspecialchars($server['name']) . "
";
$opstring .= "";
$opstring .= "
";
$opstring .= "";
$opstring .= "";
$opstring .= "" . gettext('Name/Time') . " | ";
$opstring .= "" . gettext('Real/Virtual IP') . " | ";
$opstring .= " | ";
$opstring .= "
";
$opstring .= "";
$opstring .= "";
$rowIndex = 0;
foreach ($server['conns'] as $conn):
$evenRowClass = $rowIndex % 2 ? " listMReven" : " listMRodd";
$rowIndex++;
$opstring .= "";
$opstring .= "";
$opstring .= $conn['common_name'];
$opstring .= " | ";
$opstring .= "";
$opstring .= $conn['remote_host'];
$opstring .= " | ";
$opstring .= "";
$opstring .= "";
$opstring .= "";
$opstring .= " | ";
$opstring .= "
";
$opstring .= "";
$opstring .= "";
$opstring .= $conn['connect_time'];
$opstring .= " | ";
$opstring .= "";
$opstring .= $conn['virtual_addr'];
if (!empty($conn['virtual_addr']) && !empty($conn['virtual_addr6'])) {
$opstring .= " ";
}
$opstring .= $conn['virtual_addr6'];
$opstring .= " | ";
$opstring .= " | ";
$opstring .= "
";
endforeach;
$opstring .= "";
$opstring .= "
";
$opstring .= "
";
$opstring .= "";
endforeach;
print($opstring);
$got_sk_server = false;
if (!empty($sk_servers)):
foreach ($sk_servers as $sk_server):
if (!in_array($sk_server['vpnid'], $skipovpns)) {
$got_sk_server = true;
break;
}
endforeach;
endif;
if ($got_sk_server):
$opstring = "";
$opstring .= "";
print($opstring);
endif;
$got_ovpn_client = false;
if (!empty($clients)):
foreach ($clients as $client):
if (!in_array($client['vpnid'], $skipovpns)) {
$got_ovpn_client = true;
break;
}
endforeach;
endif;
if ($got_ovpn_client):
$opstring = "";
$opstring .= "";
print($opstring);
endif;
if ((empty($clients)) && (empty($servers)) && (empty($sk_servers))) {
$none_to_display_text = gettext("No OpenVPN instances defined");
} else if (!$got_ovpn_server && !$got_sk_server && !$got_ovpn_client) {
$none_to_display_text = gettext("All OpenVPN instances are hidden");
} else {
$none_to_display_text = "";
}
if (strlen($none_to_display_text) > 0) {
print('' . $none_to_display_text . ' |
');
}
}
}
/* Handle AJAX */
if ($_GET['action']) {
if ($_GET['action'] == "kill") {
$port = $_GET['port'];
$remipp = $_GET['remipp'];
if (!empty($port) and !empty($remipp)) {
$retval = openvpn_kill_client($port, $remipp);
echo htmlentities("|{$port}|{$remipp}|{$retval}|");
} else {
echo gettext("invalid input");
}
exit;
}
}
// Compose the table contents and pass it back to the ajax caller
if ($_REQUEST && $_REQUEST['ajax']) {
printPanel($_REQUEST['widgetkey']);
exit;
} else if ($_POST['widgetkey']) {
$validNames = array();
$servers = openvpn_get_active_servers();
$sk_servers = openvpn_get_active_servers("p2p");
$clients = openvpn_get_active_clients();
foreach ($servers as $server) {
array_push($validNames, $server['vpnid']);
}
foreach ($sk_servers as $sk_server) {
array_push($validNames, $sk_server['vpnid']);
}
foreach ($clients as $client) {
array_push($validNames, $client['vpnid']);
}
if (is_array($_POST['show'])) {
$user_settings['widgets'][$_POST['widgetkey']]['filter'] = implode(',', array_diff($validNames, $_POST['show']));
} else {
$user_settings['widgets'][$_POST['widgetkey']]['filter'] = implode(',', $validNames);
}
save_widget_settings($_SESSION['Username'], $user_settings["widgets"], gettext("Saved OpenVPN Filter via Dashboard."));
header("Location: /index.php");
}
$widgetperiod = isset($config['widgets']['period']) ? $config['widgets']['period'] * 1000 : 10000;
$widgetkey_nodash = str_replace("-", "", $widgetkey);
?>