mirror of
https://github.com/billz/raspap-webgui.git
synced 2025-03-01 10:31:47 +00:00
Processed with phpcbf
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user