Processed with phpcbf

This commit is contained in:
billz
2020-02-15 17:57:46 +00:00
parent c0af41a53b
commit 457da91008
28 changed files with 1062 additions and 969 deletions

View File

@@ -1,12 +1,10 @@
<?php
include_once('includes/status_messages.php');
require_once 'includes/status_messages.php';
require_once 'config.php';
/**
*
* Manage OpenVPN configuration
*
*/
function DisplayOpenVPNConfig()
{
@@ -48,26 +46,27 @@ function DisplayOpenVPNConfig()
$authPassword = $auth[1];
}
echo renderTemplate("openvpn", compact(
"status",
"serviceStatus",
"openvpnstatus",
"public_ip",
"authUser",
"authPassword"
));
echo renderTemplate(
"openvpn", compact(
"status",
"serviceStatus",
"openvpnstatus",
"public_ip",
"authUser",
"authPassword"
)
);
}
/**
*
* Validates uploaded .ovpn file, adds auth-user-pass and
* stores auth credentials in login.conf. Copies files from
* tmp to OpenVPN
*
* @param object $status
* @param object $file
* @param string $authUser
* @param string $authPassword
* @param object $status
* @param object $file
* @param string $authUser
* @param string $authPassword
* @return object $status
*/
function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
@@ -84,15 +83,15 @@ function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
// Parse returned errors
switch ($file['error']) {
case UPLOAD_ERR_OK:
break;
case UPLOAD_ERR_NO_FILE:
throw new RuntimeException('OpenVPN configuration file not sent');
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
throw new RuntimeException('Exceeded filesize limit');
default:
throw new RuntimeException('Unknown errors');
case UPLOAD_ERR_OK:
break;
case UPLOAD_ERR_NO_FILE:
throw new RuntimeException('OpenVPN configuration file not sent');
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
throw new RuntimeException('Exceeded filesize limit');
default:
throw new RuntimeException('Unknown errors');
}
// Validate extension
@@ -109,7 +108,8 @@ function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
'ovpn' => 'text/plain'
),
true
)) {
)
) {
throw new RuntimeException('Invalid file format');
}
@@ -127,7 +127,8 @@ function SaveOpenVPNConfig($status, $file, $authUser, $authPassword)
'ovpnclient',
$ext
)
)) {
)
) {
throw new RuntimeException('Unable to move uploaded file');
}
// Good file upload, update auth credentials if present