25 lines
603 B
PHP
25 lines
603 B
PHP
<?php
|
|
require_once __DIR__ . '/common.php';
|
|
|
|
header('Content-Type: application/json');
|
|
$dbconn = getDBConnection();
|
|
|
|
try {
|
|
$query = "SELECT lat, lon, outagen FROM newpower WHERE active = true AND cwa = 'RLX'";
|
|
$result = pg_query($dbconn, $query);
|
|
|
|
if ($result === false) {
|
|
throw new Exception('Query failed: ' . pg_last_error());
|
|
}
|
|
|
|
$data = pg_fetch_all($result) ?: [];
|
|
echo json_encode($data);
|
|
|
|
pg_free_result($result);
|
|
} catch (Exception $e) {
|
|
http_response_code(500);
|
|
echo json_encode(['error' => $e->getMessage()]);
|
|
} finally {
|
|
pg_close($dbconn);
|
|
}
|
|
?>
|