Skip to content

Commit 38e2053

Browse files
authored
Merge pull request #1666 from akrherz/260625-2
Address lint
2 parents 434c7e1 + 7c75270 commit 38e2053

41 files changed

Lines changed: 592 additions & 393 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

htdocs/COOP/current.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ $cols = array(
173173
"phour" => "Rainfall One Hour", "snoww" => "Snow Water Equivalent"
174174
);
175175
if (!array_key_exists($sortcol, $cols)) {
176-
xssafe("</script>");
176+
die405();
177177
}
178178
$t->current_network = "COOP";
179179

htdocs/DCP/current.phtml

Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ require_once "../../include/forms.php";
88
require_once "../../include/mlib.php";
99
$pgconn = iemdb('iem');
1010

11-
$sortcol = isset($_GET['sortcol']) ? xssafe($_GET['sortcol']) : "valid";
11+
$sortcol = get_str404("sortcol", "valid");
1212
$network = get_str404("network", 'IA_DCP', 9);
13-
$shef = isset($_REQUEST['shef']) && $_REQUEST['shef'] == 'yes';
13+
$shef = get_str404("shef", "no") === 'yes';
1414

1515
$t->title = "DCP/GOES Current Conditions";
1616
$t->refresh = 600;
1717

1818
$t->breadcrumbs = <<<EOM
19-
<ol class="breadcrumb">
20-
<li><a href="/DCP/">DCP Network</a></li>
21-
<li class="active">Sortable Currents</li>
19+
<ol class="breadcrumb mb-0">
20+
<li class="breadcrumb-item"><a href="/DCP/">DCP Network</a></li>
21+
<li class="breadcrumb-item active" aria-current="page">Sortable Currents</li>
2222
</ol>
2323
EOM;
2424
$cols = array(
@@ -33,7 +33,7 @@ $cols = array(
3333
'TWIZ' => 'Water Temperature',
3434
);
3535
if (!array_key_exists($sortcol, $cols)) {
36-
xssafe("</script>");
36+
die405();
3737
}
3838

3939
$stname = iem_pg_prepare(
@@ -67,26 +67,55 @@ while ($row = pg_fetch_assoc($rs)) {
6767
$final = aSortBySecondIndex($obs, $sortcol, "desc");
6868

6969
$nselect = selectNetworkType("DCP", $network);
70+
$nselect = str_replace('class="iemselect2"', 'class="iemselect2 form-select"', $nselect);
71+
$nselect = str_replace('<select ', '<select id="network-select" ', $nselect);
7072

7173
$ar = array("no" => "No", "yes" => "Yes");
72-
$sselect = make_select("shef", $shef, $ar);
74+
$sselect = make_select(
75+
"shef",
76+
$shef ? "yes" : "no",
77+
$ar,
78+
"",
79+
"form-select",
80+
FALSE,
81+
FALSE,
82+
TRUE,
83+
array("id" => "shef-select")
84+
);
7385

7486
$t->current_network = "DCP";
75-
$baseurl2 = "current.phtml?network=$network&sortcol=";
87+
$shefqs = $shef ? "&shef=yes" : "";
88+
$baseurl2 = "current.phtml?network=$network{$shefqs}&sortcol=";
7689

7790
$content = <<<EOM
78-
<form method="GET" action="current.phtml" name="myselector">
79-
<input type="hidden" name="sortcol" value="{$sortcol}">
80-
<strong>Select Network:</strong> {$nselect}
81-
82-
<strong>Show SHEF Codes:</strong> {$sselect}
83-
84-
<input type="submit" value="Go!">
85-
</form>
86-
87-
<p>Sorted by: {$cols[$sortcol]}
88-
<table class="table table-sm table-striped table-bordered">
89-
<thead>
91+
<div class="card shadow-sm mb-3">
92+
<div class="card-body">
93+
<form method="GET" action="current.phtml" name="myselector" class="row g-3 align-items-end">
94+
<input type="hidden" name="sortcol" value="{$sortcol}">
95+
<div class="col-12 col-lg-6">
96+
<label for="network-select" class="form-label mb-1">Select Network</label>
97+
{$nselect}
98+
</div>
99+
<div class="col-12 col-md-4 col-lg-3">
100+
<label for="shef-select" class="form-label mb-1">Show SHEF Codes</label>
101+
{$sselect}
102+
</div>
103+
<div class="col-12 col-md-4 col-lg-3">
104+
<button type="submit" class="btn btn-primary w-100">Update View</button>
105+
</div>
106+
</form>
107+
</div>
108+
</div>
109+
110+
<div class="d-flex flex-column flex-md-row justify-content-between align-items-md-center gap-2 mb-2">
111+
<p class="mb-0">Sorted by: <span class="badge text-bg-light">{$cols[$sortcol]}</span></p>
112+
<p class="text-body-secondary small mb-0">Rows with stale observations are highlighted.</p>
113+
</div>
114+
115+
<div class="table-responsive">
116+
<table class="table table-sm table-striped table-bordered table-hover align-middle mb-0">
117+
<caption class="caption-top">Latest DCP/GOES observations for selected state.</caption>
118+
<thead class="table-light">
90119
<tr>
91120
<th><a href="{$baseurl2}station">SiteID:</a></th>
92121
<th><a href="{$baseurl2}name">Station Name:</a></th>
@@ -104,15 +133,15 @@ $now = time();
104133
foreach ($final as $site => $value) {
105134
$url = sprintf("/sites/site.php?station=%s&network=%s", $site, $network);
106135
$content .= "<tr><td><a href=\"$url\">$site</a></td>
107-
<td>" . $value["name"] . "</font></td>";
108-
$content .= "<td ";
136+
<td>" . $value["name"] . "</td>";
137+
$content .= "<td class=\"text-nowrap";
109138
$tdiff = $now - $value["valid"];
110139
$dtfmt = "d M h:i A";
111140
if ($tdiff > (6 * 3600)) {
112141
$dtfmt = "d M Y h:i A";
113-
$content .= 'bgcolor="red"';
142+
$content .= ' table-danger fw-semibold';
114143
}
115-
$content .= ">" . date($dtfmt, $value["valid"]) . "</td>";
144+
$content .= "\">" . date($dtfmt, $value["valid"]) . "</td>";
116145

117146
if (array_key_exists('HGIZ', $value)) {
118147
$content .= sprintf("<td>%s</td>", $value["HGIZ"]);
@@ -153,7 +182,7 @@ foreach ($final as $site => $value) {
153182

154183
$content .= "</tr>";
155184
if ($shef) {
156-
$content .= "<tr><td colspan=\"9\">";
185+
$content .= "<tr class=\"table-secondary\"><td colspan=\"9\" class=\"small font-monospace\">";
157186
foreach ($value as $k => $v) {
158187
if ($k == 'name' || $k == 'valid') continue;
159188
$content .= sprintf("/%s %s ", $k, $v);
@@ -165,6 +194,7 @@ $content .= <<<EOM
165194
</tbody><tfoot>
166195
<tr><td colspan="9">&nbsp;</td></tr>
167196
</tfoot></table>
197+
</div>
168198
EOM;
169199
$t->content = $content;
170200
$t->render('sortables.phtml');

htdocs/DCP/index.phtml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,15 @@ about this dataset.</p>
4444
<li><a href='/request/dcp/fe.phtml'><i class="bi bi-download" aria-hidden="true"></i> Download from the archive</a>
4545
<br />Download the observations from the archive.</li>
4646
</ul>
47-
<p>
48-
4947
50-
<b>References:</b><br>
51-
<b>1</b> <a
48+
<p>
49+
<strong>References:</strong>
50+
<br />
51+
<strong>1</strong> <a
5252
href="https://hads.ncep.noaa.gov/dcp_operators.shtml">https://hads.ncep.noaa.gov/dcp_operators.shtml</a>
53-
, viewed 12 Jul 2017
54-
<br><a href="https://water.usgs.gov/pubs/circ/circ1123/">https://water.usgs.gov/pubs/circ/circ1123/</a>
55-
, viewed: 21 May 2025
53+
, viewed 26 June 2026.
54+
</p>
55+
5656
5757
EOM;
5858
$t->render('single.phtml');

htdocs/DCP/site.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@
22
width: 100%;
33
height: 400px;
44
border: 2px solid black;
5-
}
5+
}

htdocs/DCP/site.phtml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?php
2-
$OL = "10.6.1";
2+
$OL = "10.9.0";
33
require_once "../../config/settings.inc.php";
44
define("IEM_APPID", 110);
55
require_once "../../include/mlib.php";
@@ -12,8 +12,8 @@ require_once "../../include/forms.php";
1212
$day = get_int404("day", date("d"));
1313
$month = get_int404("month", date("m"));
1414
$year = get_int404("year", date("Y"));
15-
$station = isset($_GET['station']) ? xssafe($_GET['station']) : null;
16-
$shefvar = isset($_GET['shefvar']) ? xssafe($_GET['shefvar']) : null;
15+
$station = get_str404("station", null);
16+
$shefvar = get_str404("shefvar", null);
1717
$network = get_str404("network", 'IA_DCP', 9);
1818

1919
$ts = mktime(1, 0, 0, $month, $day, $year);
@@ -120,9 +120,10 @@ EOM;
120120
} else {
121121
if (!$alone) {
122122
$extra = <<<EOM
123-
<div class="warning">This site is listed within the IEM database as both a
124-
"COOP" and "DCP" site. This printout below will only include a days
125-
worth of data.</div>
123+
<div class="warning">
124+
Since this station identifier is dual listed as both a "COOP" and "DCP"
125+
type station, the page will only list one day worth of data.
126+
</div>
126127
EOM;
127128
}
128129
$extra .= "<br /><br />

htdocs/GIS/apps/coop/gsplot.php

Lines changed: 34 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,49 @@
77

88
$coopdb = iemdb("coop");
99

10-
$var = isset($_GET["var"]) ? xssafe($_GET["var"]) : "gdd50";
10+
$var = get_str404("var", "gdd50");
1111
$year = get_int404("year", date("Y"));
1212
$smonth = get_int404("smonth", 5);
1313
$sday = get_int404("sday", 1);
1414
$emonth = get_int404("emonth", date("m"));
1515
$eday = get_int404("eday", date("d"));
16-
$network = isset($_REQUEST["network"]) ? xssafe($_REQUEST["network"]) : "IACLIMATE";
17-
if (strlen($network) > 9){
18-
xssafe("<tag>");
16+
$network = get_str404("network", "IACLIMATE", 9);
17+
18+
$varDef = array(
19+
"gdd32" => "Growing Degree Days (base=32)",
20+
"gdd41" => "Growing Degree Days (base=41)",
21+
"gdd46" => "Growing Degree Days (base=46)",
22+
"gdd48" => "Growing Degree Days (base=48)",
23+
"gdd50" => "Growing Degree Days (base=50)",
24+
"gdd51" => "Growing Degree Days (base=51)",
25+
"gdd52" => "Growing Degree Days (base=52)",
26+
"cdd65" => "Cooling Degree Days (base=65)",
27+
"hdd65" => "Heating Degree Days (base=65)",
28+
"et" => "Potential Evapotranspiration",
29+
"prec" => "Precipitation",
30+
"sgdd50" => "Soil Growing Degree Days (base=50)",
31+
"sdd86" => "Stress Degree Days (base=86)",
32+
"mintemp" => "Minimum Temperature [F]",
33+
"maxtemp" => "Maximum Temperature [F]",
34+
);
35+
if (!array_key_exists($var, $varDef)) {
36+
die405();
1937
}
2038

39+
2140
$nt = new NetworkTable($network);
2241
$cities = $nt->table;
2342

2443
$sts = new DateTime("{$year}-{$smonth}-{$sday}");
2544
$ets = new DateTime("{$year}-{$emonth}-{$eday}");
2645

2746

47+
/**
48+
* Generate the page title
49+
* @param MapObj $map
50+
* @param imageObj $imgObj
51+
* @param string $titlet
52+
*/
2853
function mktitlelocal($map, $imgObj, $titlet)
2954
{
3055

@@ -36,6 +61,11 @@ function mktitlelocal($map, $imgObj, $titlet)
3661
$point->draw($map, $layer, $imgObj, 0, $titlet);
3762
}
3863

64+
/**
65+
* Generate a "No Data" message on the map
66+
* @param MapObj $map
67+
* @param imageObj $img
68+
*/
3969
function plotNoData($map, $img)
4070
{
4171
$layer = $map->getLayerByName("credits");
@@ -51,23 +81,6 @@ function plotNoData($map, $img)
5181
);
5282
}
5383

54-
$varDef = array(
55-
"gdd32" => "Growing Degree Days (base=32)",
56-
"gdd41" => "Growing Degree Days (base=41)",
57-
"gdd46" => "Growing Degree Days (base=46)",
58-
"gdd48" => "Growing Degree Days (base=48)",
59-
"gdd50" => "Growing Degree Days (base=50)",
60-
"gdd51" => "Growing Degree Days (base=51)",
61-
"gdd52" => "Growing Degree Days (base=52)",
62-
"cdd65" => "Cooling Degree Days (base=65)",
63-
"hdd65" => "Heating Degree Days (base=65)",
64-
"et" => "Potential Evapotranspiration",
65-
"prec" => "Precipitation",
66-
"sgdd50" => "Soil Growing Degree Days (base=50)",
67-
"sdd86" => "Stress Degree Days (base=86)",
68-
"mintemp" => "Minimum Temperature [F]",
69-
"maxtemp" => "Maximum Temperature [F]",
70-
);
7184

7285
$rnd = array(
7386
"gdd32" => 0,

htdocs/GIS/apps/coop/gsplot.phtml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@ $coopdb = iemdb("coop");
1010

1111
$t = new MyView();
1212

13-
$var = isset($_GET["var"]) ? xssafe($_GET["var"]) : "gdd50";
13+
$var = get_str404("var", "gdd50");
1414
$year = get_int404("year", date("Y", time() - 86400));
1515
$smonth = get_int404("smonth", 5);
1616
$sday = get_int404("sday", 1);
1717
$emonth = get_int404("emonth", date("m", time() - 86400));
1818
$eday = get_int404("eday", date("d", time() - 86400));
19-
$network = isset($_REQUEST["network"]) ? xssafe($_REQUEST["network"]) : "IACLIMATE";
20-
if (strlen($network) > 9){
21-
xssafe("<tag>");
22-
}
19+
$network = get_str404("network", "IACLIMATE", 9);
2320

2421
$nt = new NetworkTable($network);
2522
$cities = $nt->table;

htdocs/GIS/apps/coop/index.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
$nt = new NetworkTable("IACLIMATE");
1818
$cities = $nt->table;
1919

20-
$plot = isset($_GET["plot"]) ? xssafe($_GET["plot"]) : "high";
21-
$area = isset($_GET["area"]) ? xssafe($_GET["area"]) : "all";
20+
$plot = get_str404("plot", "high");
21+
$area = get_str404("area", "all");
2222
$month = get_int404("month", date("m"));
2323
$day = get_int404("day", date("d"));
2424

@@ -43,7 +43,7 @@
4343
"nw" => array($lx, $ly + ($dy / 2), $ux - ($dx / 2), $uy)
4444
);
4545
if (!array_key_exists($area, $ex)) {
46-
xssafe("<tag>");
46+
die405();
4747
}
4848

4949
$map->setextent($ex[$area][0], $ex[$area][1], $ex[$area][2], $ex[$area][3]);
@@ -100,7 +100,7 @@
100100
"high" => "Average High Temp [F]"
101101
);
102102
if (!array_key_exists($plot, $var)) {
103-
xssafe("<tag>");
103+
die405();
104104
}
105105

106106
$dbdate = new DateTime("2000-{$month}-{$day}");
@@ -199,11 +199,11 @@
199199
200200
<img src="{$url}" class="img img-fluid" />
201201
<br><i>You can right-click on the image to save it.</i>
202-
<br><li>Only one year with the record value is shown, there may have been
202+
<br><li>Only one year with the record value is shown, there may have been
203203
more.</li>
204204
205205
</div><div class="col-md-5">
206-
206+
207207
<form name="f" method="GET" action="index.php">
208208
209209
<table width="100%">
@@ -213,7 +213,7 @@
213213
214214
<tr><td colspan=2>
215215
{$aselect}
216-
<br><i>If you select a sub-region, the year of a record event will appear
216+
<br><i>If you select a sub-region, the year of a record event will appear
217217
as well.</i><br><br>
218218
219219
</td></tr>
@@ -265,7 +265,7 @@
265265
266266
<tr>
267267
<td colspan="2">
268-
The black and red dots signify the climate record for the station. Sites in
268+
The black and red dots signify the climate record for the station. Sites in
269269
black date back till 1893 and sites in red to 1951.
270270
271271
</td></tr>

0 commit comments

Comments
 (0)