<?php
require_once __DIR__ . '/common.php';

$dbconn = getDBConnection();

//no gets, current point outage info
if(empty(array_diff_key($_GET, array('service' => '')))) {
    $result = pg_query_params($dbconn,
    "SELECT json_build_object('type', 'FeatureCollection','features', json_agg(json_build_object('type','Feature', 'geometry',  ST_AsGeoJSON(geom)::json,'properties',json_build_object('incname',incname,'discovery',discovery,'modified',modified,'age',age,'dailyacres',dailyacres,'type',type,'contained',contained,'personnel',personnel))order by modified asc)) FROM fire where type = $1 and contained <> 100 and modified > now() - interval '36 hours'",
    array('WF')) or die('Query failed: ' . pg_last_error());
    $resultArray = pg_fetch_all($result);
    echo($resultArray[0]['json_build_object']);
}

// Close database connection when needed
if (isset($dbconn)) {
    pg_close($dbconn);
}
?>