1
0
mirror of https://github.com/billz/raspap-webgui.git synced 2023-10-10 13:37:24 +02:00
raspap-webgui/includes/openvpn.php

65 lines
1.4 KiB
PHP
Raw Normal View History

2019-11-12 17:03:26 +01:00
<?php
include_once('includes/status_messages.php');
/**
*
* Manage OpenVPN configuration
*
*/
function DisplayOpenVPNConfig()
{
exec('cat '. RASPI_OPENVPN_CLIENT_CONFIG, $returnClient);
exec('cat '. RASPI_OPENVPN_SERVER_CONFIG, $returnServer);
exec('pidof openvpn | wc -l', $openvpnstatus);
// parse client settings
foreach ($returnClient as $a) {
if ($a[0] != "#") {
$arrLine = explode(" ", $a) ;
$arrClientConfig[$arrLine[0]]=$arrLine[1];
}
}
// parse server settings
foreach ($returnServer as $a) {
if ($a[0] != "#") {
$arrLine = explode(" ", $a) ;
$arrServerConfig[$arrLine[0]]=$arrLine[1];
}
}
echo renderTemplate("openvpn", compact(
"status",
"openvpnStatus"
));
2019-11-12 22:05:21 +01:00
2019-11-12 17:03:26 +01:00
}
2019-11-12 22:05:21 +01:00
/**
*
*
*/
function SaveOpenVPNConfig()
{
if (isset($_POST['SaveOpenVPNSettings'])) {
// TODO
} elseif (isset($_POST['StartOpenVPN'])) {
echo "Attempting to start openvpn";
exec('sudo systemctl start openvpn.service', $return);
foreach ($return as $line) {
$status->addMessage($line, 'info');
}
} elseif (isset($_POST['StopOpenVPN'])) {
echo "Attempting to stop openvpn";
exec('sudo systemctl stop openvpn.service', $return);
foreach ($return as $line) {
$status->addMessage($line, 'info');
}
}
}
?>