Packet-Fence/admin/network/interfaces_function.php
2025-06-28 06:23:17 +05:30

47 lines
1.4 KiB
PHP

<?php
session_start();
$activePage = 'network';
$activeSubPage = 'interfaces';
include("../elements/master.php");
include("../elements/functions.php");
// ----------------------------API CALL--------------------//
$jsonFilePath = __DIR__ . '/../urls/api_endpoints.json';
$jsonData = file_get_contents($jsonFilePath);
$endpoints = json_decode($jsonData, true);
$url = $endpoints['interfaces'];
// ----------------------- ENDS HERE-------------------------//
if (!isset($_SESSION['token'])) {
include('token_exp.php');
}
$token = $_SESSION['token'];
$result = make_get_request($url, ["Authorization: $token"]);
$response = json_decode($result, true);
$_SESSION["response"] = $response;
if (isset($response['items']) && is_array($response['items'])) {
$user_list = array_map(function($user) {
return [
'is_running' => $user['is_running'] ?? '-',
'name' => $user['name'] ?? '-',
'ipaddress' => $user['ipaddress'] ?? '-',
'netmask' => $user['netmask'] ?? '-',
'network' => $user['network'] ?? '-', // Example, adjust as needed
'type' => $user['type'] ?? '-', // Example, adjust as needed
'address' => $user['address'] ?? '-'
];
}, $response['items']);
$_SESSION['userlist'] = $user_list;
} else {
$user_list = "No users found or invalid response format.";
}
?>