diff --git a/includes/defaults.php b/includes/defaults.php index 3fc6e914..dd5c588f 100755 --- a/includes/defaults.php +++ b/includes/defaults.php @@ -8,6 +8,7 @@ $defaults = [ 'RASPI_BRAND_TEXT' => 'RaspAP', 'RASPI_VERSION' => '2.9.6', 'RASPI_CONFIG_NETWORK' => RASPI_CONFIG.'/networking/defaults.json', + 'RASPI_CONFIG_PROVIDERS' => 'config/vpn-providers.json', 'RASPI_ADMIN_DETAILS' => RASPI_CONFIG.'/raspap.auth', 'RASPI_WIFI_AP_INTERFACE' => 'wlan0', 'RASPI_CACHE_PATH' => sys_get_temp_dir() . '/raspap', @@ -45,6 +46,7 @@ $defaults = [ 'RASPI_DHCP_ENABLED' => true, 'RASPI_ADBLOCK_ENABLED' => false, 'RASPI_OPENVPN_ENABLED' => false, + 'RASPI_VPN_PROVIDER_ENABLED' => false, 'RASPI_WIREGUARD_ENABLED' => false, 'RASPI_TORPROXY_ENABLED' => false, 'RASPI_CONFAUTH_ENABLED' => true, diff --git a/includes/functions.php b/includes/functions.php index 24a42f15..e5797507 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -169,6 +169,24 @@ function getDefaultNetOpts($svc,$key) } } +/** + * Returns a value for the specified VPN provider + * + * @param numeric $id + * @param string $key + * @return object $json + */ +function getProviderValue($id,$key) +{ + $obj = json_decode(file_get_contents(RASPI_CONFIG_PROVIDERS), true); + if ($obj === null) { + return false; + } else { + $id--; + return $obj['providers'][$id][$key]; + } +} + /* Functions to write ini files */ /** @@ -669,6 +687,7 @@ function initializeApp() $_SESSION["theme_url"] = getThemeOpt(); $_SESSION["toggleState"] = getSidebarState(); $_SESSION["bridgedEnabled"] = getBridgedState(); + $_SESSION["providerID"] = getProviderID(); } function getThemeOpt() @@ -709,6 +728,17 @@ function getBridgedState() return $arrHostapdConf['BridgedEnable']; } +// Returns VPN provider ID, if defined +function getProviderID() +{ + if (RASPI_VPN_PROVIDER_ENABLED) { + $arrProvider = parse_ini_file(RASPI_CONFIG.'/provider.ini'); + if (isset($arrProvider['providerID'])) { + return $arrProvider['providerID']; + } + } +} + /** * Validates the format of a CIDR notation string * diff --git a/includes/page_actions.php b/includes/page_actions.php index b460dd43..ed64a33e 100755 --- a/includes/page_actions.php +++ b/includes/page_actions.php @@ -27,6 +27,9 @@ case "/wg_conf": DisplayWireGuardConfig(); break; + case "/provider_conf": + DisplayProviderConfig(); + break; case "/torproxy_conf": DisplayTorProxyConfig(); break; diff --git a/includes/sidebar.php b/includes/sidebar.php index ada2a0b0..13558354 100755 --- a/includes/sidebar.php +++ b/includes/sidebar.php @@ -60,6 +60,11 @@ + + +