Warehouse project/fix

This commit is contained in:
Luca Haid
2025-12-03 14:08:44 +00:00
parent ff070bac73
commit 594a926262
10 changed files with 1560 additions and 735 deletions

View File

@@ -16,7 +16,16 @@ class RadiusController extends mfBaseController {
protected function indexAction() {
$this->layout()->set('additionalJS', ["plugins/chart.js/chart.4.4.6.js", "plugins/chart.js/chartjs-adapter-moment.min.js"]);
Helper::renderVue($this, $this->mod, "Radius", ['CAN_BILLING' => $this->me->can("Billing"), 'HIDE_PAGE_TITLE' => true]);
$allowedAcsUserIds = [9, 13, 25, 65, 135, 145, 178];
$acsEnabled = in_array($this->me->id, $allowedAcsUserIds);
Helper::renderVue($this, $this->mod, "Radius", [
'CAN_BILLING' => $this->me->can("Billing"),
'HIDE_PAGE_TITLE' => true,
'USER_ID' => $this->me->id,
'ACS_ENABLED' => $acsEnabled
]);
}
protected function proxyUnsecureHTTPRequestToRadiusAction() {
@@ -35,6 +44,49 @@ class RadiusController extends mfBaseController {
die();
}
/**
* Run speedtest via ACS proxy
*/
protected function genieacsRunSpeedtestAction() {
try {
$input = json_decode(file_get_contents('php://input'), true);
$ip = $input['ip'] ?? null;
if (!$ip) {
self::sendError("IP address is required");
}
$url = "http://acs.xinon.at:5000/run-speedtest";
$apiKey = "2H9zWrgxPEJL9MZ1yTGtWh16cPCu0AsQ";
$data = json_encode(['ip' => $ip]);
$opts = [
"http" => [
"method" => "POST",
"header" => "Content-Type: application/json\r\n" .
"X-API-Key: " . $apiKey . "\r\n" .
"Content-Length: " . strlen($data) . "\r\n",
"content" => $data
]
];
$context = stream_context_create($opts);
$response = file_get_contents($url, false, $context);
if ($response === false) {
self::sendError("Failed to connect to speedtest server");
}
header("Content-Type: application/json");
echo $response;
die();
} catch (Exception $e) {
error_log("GenieACS runSpeedtest error: " . $e->getMessage());
self::sendError("Error running speedtest: " . $e->getMessage());
}
}
protected function sendCustomerEmailAction() {
$input = json_decode(file_get_contents('php://input'), true);
if (!$input || !isset($input['username'], $input['year'], $input['month'], $input['monthlySummary'], $input['monthlyDetails'], $input['recipient']))