Skip to content

Commit f88aefe

Browse files
committed
Refactor: Remove unused call_api function and related comments
1 parent 54db347 commit f88aefe

File tree

1 file changed

+0
-50
lines changed

1 file changed

+0
-50
lines changed

front/index.php

Lines changed: 0 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -113,52 +113,6 @@ function is_https_request(): bool {
113113
return false;
114114
}
115115

116-
function call_api(string $endpoint, array $data = []): ?array {
117-
/*
118-
Call NetAlertX API endpoint (for login page endpoints that don't require auth).
119-
120-
Returns: JSON response as array, or null on failure
121-
*/
122-
try {
123-
// Determine API host (assume localhost on same port as frontend)
124-
$api_host = $_SERVER['HTTP_HOST'] ?? 'localhost';
125-
$api_scheme = is_https_request() ? 'https' : 'http';
126-
$api_url = $api_scheme . '://' . $api_host;
127-
128-
$url = $api_url . $endpoint;
129-
130-
$ch = curl_init($url);
131-
if (!$ch) return null;
132-
133-
curl_setopt_array($ch, [
134-
CURLOPT_RETURNTRANSFER => true,
135-
CURLOPT_TIMEOUT => 5,
136-
CURLOPT_FOLLOWLOCATION => false,
137-
CURLOPT_HTTPHEADER => [
138-
'Content-Type: application/json',
139-
'Accept: application/json'
140-
]
141-
]);
142-
143-
if (!empty($data)) {
144-
curl_setopt($ch, CURLOPT_POST, true);
145-
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
146-
}
147-
148-
$response = curl_exec($ch);
149-
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
150-
curl_close($ch);
151-
152-
if ($httpcode !== 200 || !$response) {
153-
return null;
154-
}
155-
156-
return json_decode($response, true);
157-
} catch (Exception $e) {
158-
return null;
159-
}
160-
}
161-
162116

163117
function logout_user(): void {
164118
$_SESSION = [];
@@ -199,10 +153,6 @@ function logout_user(): void {
199153
}
200154
}
201155

202-
/* =====================================================
203-
Remember Me Validation
204-
===================================================== */
205-
206156
/* =====================================================
207157
Already Logged In
208158
===================================================== */

0 commit comments

Comments
 (0)