Skip to content

Commit

Permalink
Merge pull request #1154 from akrherz/250307-2
Browse files Browse the repository at this point in the history
Omnibus
  • Loading branch information
akrherz authored Mar 8, 2025
2 parents 420656e + 97a87c7 commit 4b7c436
Show file tree
Hide file tree
Showing 19 changed files with 80 additions and 65 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ ci:
autoupdate_schedule: quarterly
repos:
- repo: https://github.com/pre-commit/mirrors-eslint
rev: 'v9.21.0'
rev: 'v9.22.0'
hooks:
- id: eslint
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.9.9"
rev: "v0.9.10"
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
Expand Down
2 changes: 1 addition & 1 deletion htdocs/GIS/apps/rview/warnings.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ $query = "SELECT w.phenomena, u.name as cname, w.expire as expire,
from $wtable w, nws_ugc u
WHERE w.expire > $tsextra and w.significance != 'A'
and w.ugc = u.ugc $cuextra ORDER by {$sortcol} {$sortdir}";
pg_exec($connection, "set time zone 'GMT'");
pg_exec($connection, "set time zone 'UTC'");
$result = pg_exec($connection, $query);

$afos = array(
Expand Down
7 changes: 3 additions & 4 deletions htdocs/cow/top10.phtml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<?php
require_once "../../config/settings.inc.php";
require_once "../../include/myview.php";
$t = new MyView();

require_once "../../include/forms.php";
require_once "../../include/database.inc.php";
require_once "../../include/network.php";
require_once "../../include/imagemaps.php";
require_once "../../include/reference.php";

$t = new MyView();

$nt = new NetworkTable("WFO");
$nt->table["ALL"] = array("name" => " --- All ---- ", "id" => "ALL", "archive_begin" => null);
$vtec_phenomena = $reference["vtec_phenomena"];
Expand Down Expand Up @@ -104,8 +104,7 @@ while ($row = pg_fetch_assoc($rs)) {

$btable = "";
$rs = pg_execute($postgis, $stname_asc, array(unrectify_wfo($wfo)));
for ($i = 0; $row = pg_fetch_array($rs); $i++) {

while ($row = pg_fetch_assoc($rs)) {
$url = sprintf(
"/vtec/event/%s-O-%s-%s-%s-%s-%04d",
substr($row['date'], 0, 4),
Expand Down
2 changes: 1 addition & 1 deletion htdocs/current/camrad.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

/* Who was online and where did they look? Hehe */
$cdrct = array();
for ($i = 0; $row = pg_fetch_array($rs); $i++) {
while ($row = pg_fetch_assoc($rs)) {
$cdrct[$row["cam"]] = $row["drct"];
}

Expand Down
3 changes: 1 addition & 2 deletions htdocs/current/mcview.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ if ($mode == "realtime") {

$rs = pg_execute($postgis, "SELECT", array(date("Y-m-d H:i", $ts)));
$watches = "<div style=\"border: 1px solid #000; padding-left: 10px; background: #eee; width: 100%;\"><strong>Valid Watches:</strong> ";
for ($i = 0; $row = pg_fetch_array($rs); $i++) {
while ($row = pg_fetch_assoc($rs)) {
$issued = strtotime($row["issued"]);
$watches .= sprintf(
"<a href=\"mcview.phtml?prod=%srad&java=none&mode=%s&frames=1&interval=5&year=%s&month=%s&day=%s&hour=%s&minute=%s\">%s (%s %s)</a> &nbsp; ",
Expand Down Expand Up @@ -302,7 +302,6 @@ foreach ($radtimes as $value) {
"<a href=\"/cgi-bin/request/raster2netcdf.py?dstr=" . gmdate('YmdHi', $value) . "&prod=composite_{$gissource}\">netCDF</a>)</li>\n";
}


/* We finally start output */

$headextra .= <<<EOM
Expand Down
2 changes: 1 addition & 1 deletion htdocs/current/sel.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ with data as (
select * from data where rank = 1
EOM
);
for ($i = 0; $row = pg_fetch_array($rs); $i++) {
while ($row = pg_fetch_assoc($rs)) {
$metadata[$row["sel"]] = $row;
$metadata[$row["sel"]]["sts"] = strtotime(substr($row["issued"], 0, 16));
$metadata[$row["sel"]]["ets"] = strtotime(substr($row["expired"], 0, 16));
Expand Down
7 changes: 4 additions & 3 deletions htdocs/kml/sbw_exact_time.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,17 @@
$phenomena = isset($_GET["phenomena"]) ? substr($_GET["phenomena"],0,2) : "SV";
$significance = isset($_GET["significance"]) ? substr($_GET["significance"],0,1) : "W";

$rs = pg_prepare($connect, "SELECT", "SELECT issue, expire, status,
$stname = uniqid();
pg_prepare($connect, $stname, "SELECT issue, expire, status,
ST_askml(geom) as kml,
round(ST_area(ST_transform(geom,9311)) / 1000000.0) as psize
from sbw_$year
WHERE wfo = $1 and phenomena = $2 and
eventid = $3 and significance = $4 and status = 'NEW'");

$result = pg_execute($connect, "SELECT",
$result = pg_execute($connect, $stname,
Array($wfo, $phenomena, $eventid, $significance) );
$row = pg_fetch_array($result, 0);
$row = pg_fetch_assoc($result, 0);
$radarts = strtotime( $row["issue"] );
if (strtotime( $row["expire"] ) > time()){
$radarts = time();
Expand Down
4 changes: 2 additions & 2 deletions htdocs/kml/sbw_interval.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function nice_date($val){
<LineStyle><width>1</width><color>ff000000</color></LineStyle>
<PolyStyle><color>7d00ff00</color></PolyStyle>
</Style>";
for ($i=0;$row=pg_fetch_array($result);$i++){
while ($row = pg_fetch_assoc($result)){
$uri = sprintf(
"<a href=\"%s/vtec/event/%s-O-NEW-%s-%s-%s-%04d\">%s</a>",
$EXTERNAL_BASEURL, date('Y', strtotime($row["polygon_begin"])),
Expand Down Expand Up @@ -153,7 +153,7 @@ function pull_wfos_in_states($state_abbreviations){
if($valid_state_count > 0 ){
$sql .= ')';
$result = pg_query($db, $sql);
for ($i=0;$row=pg_fetch_array($result);$i++){
while ($row = pg_fetch_array($result)){
if($row['wfo'] !== null){
$wfos[$wfo_count] = $row['wfo'];
++$wfo_count;
Expand Down
2 changes: 1 addition & 1 deletion htdocs/kml/sbw_lsrs.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
and w.status = 'NEW'";

$result = pg_exec($connect, $query2);
$row = pg_fetch_array($result);
$row = pg_fetch_assoc($result);

header('Content-disposition: attachment; filename=sbw_lsrs.kml');
header("Content-Type: application/vnd.google-earth.kml+xml");
Expand Down
12 changes: 7 additions & 5 deletions htdocs/kml/vtec.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
$phenomena = isset($_GET["phenomena"]) ? substr(xssafe($_GET["phenomena"]), 0, 2) : "SV";
$significance = isset($_GET["significance"]) ? substr(xssafe($_GET["significance"]), 0, 1) : "W";

$rs = pg_prepare($connect, "SELECT", "SELECT
$stname = uniqid();
pg_prepare($connect, $stname, "SELECT
ST_askml(geom) as kml, issue, expire, status,
round(ST_area(ST_transform(geom,9311)) / 1000000.0) as psize
from sbw_$year
Expand All @@ -28,12 +29,13 @@

$result = pg_execute(
$connect,
"SELECT",
$stname,
array($wfo, $phenomena, $eventid, $significance)
);

if (pg_num_rows($result) <= 0) {
$rs = pg_prepare($connect, "SELECT2", "SELECT
$stname = uniqid();
pg_prepare($connect, $stname, "SELECT
issue, expire, status,
ST_askml(u.geom) as kml,
round(ST_area(ST_transform(u.geom,9311)) / 1000000.0) as psize
Expand All @@ -43,14 +45,14 @@

$result = pg_execute(
$connect,
"SELECT2",
$stname,
array($wfo, $phenomena, $eventid, $significance)
);
}

$label = "";
if (pg_num_rows($result) > 0) {
$row = pg_fetch_array($result, 0);
$row = pg_fetch_assoc($result, 0);
$radarts = strtotime($row["issue"]);
if (strtotime($row["expire"]) > time()) {
$radarts = time();
Expand Down
4 changes: 2 additions & 2 deletions htdocs/mos/csv.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
putenv("TZ=GMT");
putenv("TZ=UTC");
require_once "../../config/settings.inc.php";
require_once "../../include/database.inc.php";
require_once "../../include/forms.php";
Expand Down Expand Up @@ -46,7 +46,7 @@
);

echo implode(",", $ar) . "\n";
for ($i = 0; $row = pg_fetch_assoc($rs); $i++) {
while ($row = pg_fetch_assoc($rs)) {
foreach ($ar as $k => $v) {
echo sprintf("%s,", $row[$v]);
}
Expand Down
13 changes: 9 additions & 4 deletions htdocs/mos/table.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ for ($now = $sts; $now <= $ets; $now += (3600 * $runsper[$model])) {
$s = date("Y-m-d H:i", $now);
$runtimes[] = $s;
}
$table .= sprintf("<table class=\"table table-condensed table-bordered table-striped\"><thead><tr><td></td><th colspan=\"%s\">Model Run Initialized at:</th></tr><tr><th width=\"75\">Valid:</th>", sizeof($runtimes));
$table .= sprintf(
"<table class=\"table table-condensed table-bordered table-striped\">".
"<thead class=\"sticky\"><tr><td></td><th colspan=\"%s\">".
"Model Run Initialized at:</th></tr><tr><th width=\"75\">Valid:</th>",
sizeof($runtimes));
for ($now = $sts; $now <= $ets; $now += (3600 * $runsper[$model])) {
$s = date("Y-m-d H:i", $now);
$sqlSelector .= sprintf("'%s',", $s);
Expand All @@ -66,12 +70,13 @@ for ($now = $sts; $now <= $ets; $now += (3600 * $runsper[$model])) {
$table .= "</tr></thead><tbody>\n";
$sqlSelector = substr($sqlSelector, 0, -1) . ")";

$rs = pg_prepare($mosdb, "SELECT", "SELECT *, t06_1 ||'/'||t06_2 as t06, " .
$stname = uniqid();
pg_prepare($mosdb, $stname, "SELECT *, t06_1 ||'/'||t06_2 as t06, " .
"t12_1 ||'/'|| t12_2 as t12 from alldata WHERE " .
"runtime IN $sqlSelector " .
"and station = $1 and model = $2");
$rs = pg_execute($mosdb, "SELECT", array($station, $model));
for ($i = 0; $row = pg_fetch_array($rs); $i++) {
$rs = pg_execute($mosdb, $stname, array($station, $model));
while ($row = pg_fetch_assoc($rs)) {
$data[substr($row["runtime"], 0, 16)][substr($row["ftime"], 0, 16)] = $row[$vname];
}

Expand Down
2 changes: 1 addition & 1 deletion htdocs/nstl_flux/plots.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $sql = "SELECT * from flux_vars ORDER by details ASC";
$rows = pg_exec($other, $sql);
$var_names = array();
$var_details = array();
for ($i = 0; $row = pg_fetch_array($rows); $i++) {
while ($row = pg_fetch_assoc($rows)) {
$var_names[] = $row["name"];
$var_details[] = $row["details"];
}
Expand Down
4 changes: 2 additions & 2 deletions htdocs/nws/cf6map.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var vectorStyleFunction = function (feature) {
const value = feature.get(renderattr);
let color = "#FFFFFF";
const outlinecolor = "#000000";
if (value != "M") {
if (value !== "M") {
if (renderattr.indexOf("depart") > -1) {
if (renderattr.indexOf("high") > -1 || renderattr.indexOf("low") > -1) {
if (value > 0) {
Expand Down Expand Up @@ -185,7 +185,7 @@ $(document).ready(() => {
});

// Figure out if we have anything specified from the window.location
var tokens = window.location.href.split("#");
let tokens = window.location.href.split("#");
if (tokens.length === 2) {
// #YYYYmmdd/variable
tokens = tokens[1].split("/");
Expand Down
4 changes: 2 additions & 2 deletions htdocs/rainfall/obhour-json.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
$res = pg_prepare($mesosite, $stname,
"SELECT id, name from stations WHERE network = $1");
$rs = pg_execute($mesosite, $stname, array($network));
for ($i = 0; $z = pg_fetch_array($rs); $i++) {
while ($z = pg_fetch_assoc($rs)) {
$data[$z["id"]] = array(
"name" => $z["name"],
"id" => $z["id"],
Expand Down Expand Up @@ -84,7 +84,7 @@
$ts->format("Y-m-d H:i") ."+00",
$network)
);
for ($i = 0; $z = pg_fetch_array($rs); $i++) {
while ($z = pg_fetch_assoc($rs)) {
foreach ($intervals as $key => $interval) {
// hackery to account for trace values
$val = floatval($z["p$interval"]);
Expand Down
58 changes: 31 additions & 27 deletions htdocs/sites/cal.phtml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?php
<?php
require_once "../../config/settings.inc.php";
require_once "../../include/database.inc.php";
require_once "../../include/sites.php";
Expand All @@ -10,56 +10,60 @@ $network = $ctx->network;
$metadata = $ctx->metadata;
$t = new MyView();
$t->title = "Site Calibration";
$t->sites_current = "cal";
$t->sites_current = "cal";

$xref = Array("IA_ASOS" => "iaawos",
"IA_RWIS" => "iarwis",
"ISUAG" => "isuag",
"ISUSM" => "isusm");
$xref = array(
"IA_ASOS" => "iaawos",
"IA_RWIS" => "iarwis",
"ISUAG" => "isuag",
"ISUSM" => "isusm"
);

$portfolio = array_key_exists($network, $xref) ? $xref[$network]: null;
$portfolio = array_key_exists($network, $xref) ? $xref[$network] : null;

$varDict = Array("tmpf" => "Air Temperature [F]",
"dwpf" => "Dew Point [F]");
$varDict = array(
"tmpf" => "Air Temperature [F]",
"dwpf" => "Dew Point [F]"
);
$table = "";
if ($portfolio != null)
{
if ($portfolio != null) {
$conn = iemdb("portfolio");
$rs = pg_prepare(
$stname = uniqid();
pg_prepare(
$conn,
"SELECT",
"SELECT * from iem_calibration WHERE portfolio = $1 and ".
"station = $2 ORDER by valid DESC"
$stname,
"SELECT * from iem_calibration WHERE portfolio = $1 and " .
"station = $2 ORDER by valid DESC"
);
$rs = pg_execute($conn, "SELECT", array($portfolio, $station));
$rs = pg_execute($conn, $stname, array($portfolio, $station));

if (pg_num_rows($rs) == 0){
if (pg_num_rows($rs) == 0) {
$table .= "<tr><th colspan=6>No events found in database.</th></tr>";
}

$rowDict = Array("tmpf"=>"", "dwpf"=>"");
for( $i=0; $row = pg_fetch_array($rs); $i++)
{
$rowDict = array("tmpf" => "", "dwpf" => "");
while ($row = pg_fetch_assoc($rs)) {
$param = $row["parameter"];
$color = "#00f";
$ts = strtotime(substr($row["valid"], 0, 16));
$ds = date("d M Y, h:i A", $ts);
if (floatval($row["adjustment"]) > 0){ $color = "#f00"; }
if (floatval($row["adjustment"]) > 0) {
$color = "#f00";
}
$rowDict[$param] .= sprintf("<tr style=\"color: $color;\"><th>%s</th><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>", $row["id"], $row["station"], $ds, $row["parameter"], $row["final"], $row["adjustment"]);
if (strlen($row["comments"]) > 0){ $rowDict[$param] .= "<tr><td></td><td colspan=5>Comments: ". $row["comments"] ."</td></tr>"; }
if (strlen($row["comments"]) > 0) {
$rowDict[$param] .= "<tr><td></td><td colspan=5>Comments: " . $row["comments"] . "</td></tr>";
}
}


foreach($rowDict as $param => $tbl){
$table .= "<tr><th colspan=\"6\" align=\"left\" style=\"background: #eee; border-bottom: 1px solid #000\">". $varDict[$param] ."</th></tr>";
foreach ($rowDict as $param => $tbl) {
$table .= "<tr><th colspan=\"6\" align=\"left\" style=\"background: #eee; border-bottom: 1px solid #000\">" . $varDict[$param] . "</th></tr>";
$table .= $tbl;
}

} else {
$table .= "<tr><td colspan=\"6\">Sorry no calibration information is collected for $network network</td></tr>";
}


$t->content = <<<EOM
<table class="table table-striped">
<thead><tr>
Expand Down
6 changes: 3 additions & 3 deletions htdocs/sites/networks.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ function pretty_date($val, $fmt = "M d, Y")
"network !~* '_COCORAHS' ORDER by name"
);
$cities = array();
for ($i = 0; $row = pg_fetch_array($rs); $i++) {
while ($row = pg_fetch_assoc($rs)) {
$cities[$row["id"]] = $row;
}
} else if (isset($_GET["special"]) && $_GET["special"] == 'allasos') {
Expand All @@ -61,7 +61,7 @@ function pretty_date($val, $fmt = "M d, Y")
"network ~* 'ASOS' ORDER by name"
);
$cities = array();
for ($i = 0; $row = pg_fetch_array($rs); $i++) {
while ($row = pg_fetch_assoc($rs)) {
$cities[$row["id"]] = $row;
}
} else if (isset($_GET["special"]) && $_GET["special"] == 'alldcp') {
Expand All @@ -73,7 +73,7 @@ function pretty_date($val, $fmt = "M d, Y")
"network ~* 'DCP' ORDER by name"
);
$cities = array();
for ($i = 0; $row = pg_fetch_array($rs); $i++) {
while ($row = pg_fetch_assoc($rs)) {
$cities[$row["id"]] = $row;
}
} else {
Expand Down
2 changes: 1 addition & 1 deletion htdocs/sites/new-rss.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
$s .= "<id>{$EXTERNAL_BASEURL}/sites/locate.php</id>\n";
$s .= "<author><name>daryl herzmann</name><email>[email protected]</email></author>\n";

for ($i = 0; $row = pg_fetch_array($rs); $i++) {
while ($row = pg_fetch_assoc($rs)) {
$cbody = "<pre>\n";
$cbody .= "ID : " . $row["id"] . "\n";
$cbody .= "Name : " . $row["name"] . "\n";
Expand Down
Loading

0 comments on commit 4b7c436

Please sign in to comment.