diff --git a/application/Radius/RadiusController.php b/application/Radius/RadiusController.php index cd4a893d2..782d60660 100644 --- a/application/Radius/RadiusController.php +++ b/application/Radius/RadiusController.php @@ -19,4 +19,21 @@ class RadiusController extends mfBaseController { } + protected function proxyUnsecureHTTPRequestToRadiusAction() { + $url = "http://radius.xinon.at/api.php?" . http_build_query($_GET); + $url = str_replace("proxyUnsecureHTTPRequestToRadius", "", $url); + $opts = [ + "http" => [ + "method" => "GET", + "header" => "Authorization: Basic " . base64_encode("admin:saveman"), + ] + ]; + + header("Content-Type: application/json"); + $context = stream_context_create($opts); + $response = file_get_contents($url, false, $context); + echo $response; + die(); + } + } \ No newline at end of file diff --git a/public/js/pages/Radius/Radius.js b/public/js/pages/Radius/Radius.js index c030bf534..ead449dd9 100644 --- a/public/js/pages/Radius/Radius.js +++ b/public/js/pages/Radius/Radius.js @@ -170,11 +170,7 @@ Vue.component('radius', { info: this.info, custnum: custnum, }); - const response = await fetch(`http://radius.xinon.at/api.php?${params.toString()}`, { - headers: { - 'Authorization': 'Basic ' + btoa('admin:saveman') - } - }); + const response = await fetch(`${window.TT_CONFIG['BASE_PATH']}/Radius/proxyUnsecureHTTPRequestToRadius?${params.toString()}`); if (response.ok) { this.radiusUsers = await response.json(); } else { @@ -183,14 +179,10 @@ Vue.component('radius', { }, async fetchRadacctData(username) { const params = new URLSearchParams({ - action: 'fetchRadacct', + action2: 'fetchRadacct', username: username, }); - const response = await fetch(`http://radius.xinon.at/api.php?${params.toString()}`, { - headers: { - 'Authorization': 'Basic ' + btoa('admin:saveman') - } - }); + const response = await fetch(`${window.TT_CONFIG['BASE_PATH']}/Radius/proxyUnsecureHTTPRequestToRadius?${params.toString()}`); if (response.ok) { this.radacctData = await response.json(); this.showRadacctModal = true; @@ -200,16 +192,8 @@ Vue.component('radius', { }, async loadFreeUsers() { try { - const natResponse = await fetch('http://radius.xinon.at/api.php?action=free_user&filter=nat', { - headers: { - 'Authorization': 'Basic ' + btoa('admin:saveman') - } - }); - const stfResponse = await fetch('http://radius.xinon.at/api.php?action=free_user&filter=stf', { - headers: { - 'Authorization': 'Basic ' + btoa('admin:saveman') - } - }); + const natResponse = await fetch(window.TT_CONFIG['BASE_PATH'] + '/Radius/proxyUnsecureHTTPRequestToRadius?action2=free_user&filter=nat'); + const stfResponse = await fetch(window.TT_CONFIG['BASE_PATH'] + '/Radius/proxyUnsecureHTTPRequestToRadius?action2=free_user&filter=stf'); if (natResponse.ok && stfResponse.ok) { const natData = await natResponse.json();