<commit_before><?php
 include("../../../config/settings.inc.php");

$station = isset($_GET['station']) ? $_GET['station'] : "DSM";
$year = isset($_GET['year']) ? $_GET['year']: date("Y");
$sts = mktime(0,0,0,  5, 1, $year);
$ets = mktime(0,0,0, 10, 1, $year);
$sdate = date("Y-m-d", $sts);
$edate = date("Y-m-d", $ets);
$s2date = date("2000-m-d", $sts);
$e2date = date("2000-m-d", $ets);

$today = time();

include("$rootpath/include/database.inc.php");
include("$rootpath/include/station.php");
$st = new StationData($station);
$st->load_station( $st->table[$station]['climate_site'] );
$cities = $st->table;
$coopdb = iemdb("coop");
$iem = iemdb("access");

function calcGDD($high,$low)
{
	if ($low < 50)  $low = 50.00;
    if ($high > 86) $high = 86.00;
    if ($high < 50) return 0.00;
    return (($high+$low)/2.00) - 50.00;

}

$climate_site = $cities[$station]["climate_site"];

$q = "SELECT max_tmpf, min_tmpf, day from summary_$year
		WHERE station = '$station' and day between '$sdate' and '$edate'
		ORDER by day ASC";
$rs = pg_query($iem, $q);
$obs = Array();
$aobs = Array();
$atot = 0;
for ($i=0; $row = @pg_fetch_array($rs,$i); $i++)
{
	$hi = (float)$row["max_tmpf"];
	$lo = (float)$row["min_tmpf"];
	$gdd = calcGDD($hi, $lo);
	$atot += $gdd;
	$aobs[$i] = $atot;
	$obs[$i] = $gdd;
}

/* Now we need the climate data */
$q = "SELECT gdd50, valid from climate
		WHERE station = '". strtolower($climate_site) ."' and valid between '$s2date' and
		'$e2date'
		ORDER by valid ASC";
$rs = pg_exec($coopdb, $q);
$climate = Array();
$cdiff = Array();
$aclimate = Array();
$atot = 0;
$zeros = Array();
$xlabels = Array();
for( $i=0; $row = @pg_fetch_array($rs,$i); $i++) 
{
	$gdd = (float)$row["gdd50"];
	$atot += $gdd;
	if (@$aobs[$i] > 0)
	{<commit_msg>sql injection free for now<commit_after><?php
 include("../../../config/settings.inc.php");

$station = isset($_GET['station']) ? $_GET['station'] : "DSM";
$year = isset($_GET['year']) ? $_GET['year']: date("Y");
$sts = mktime(0,0,0,  5, 1, $year);
$ets = mktime(0,0,0, 10, 1, $year);
$sdate = date("Y-m-d", $sts);
$edate = date("Y-m-d", $ets);
$s2date = date("2000-m-d", $sts);
$e2date = date("2000-m-d", $ets);

$today = time();

include("$rootpath/include/database.inc.php");
include("$rootpath/include/station.php");
$st = new StationData($station);
$st->load_station( $st->table[$station]['climate_site'] );
$cities = $st->table;
$coopdb = iemdb("coop");
$iem = iemdb("access");

function calcGDD($high,$low)
{
	if ($low < 50)  $low = 50.00;
    if ($high > 86) $high = 86.00;
    if ($high < 50) return 0.00;
    return (($high+$low)/2.00) - 50.00;

}

$climate_site = $cities[$station]["climate_site"];

$rs = pg_prepare($iem, "SELECT", "SELECT max_tmpf, min_tmpf, day from summary_$year
		WHERE station = $1 and day between $2 and $3 ORDER by day ASC");
$rs = pg_execute($iem, "SELECT", Array($station, $sdate, $edate));
$obs = Array();
$aobs = Array();
$atot = 0;
for ($i=0; $row = @pg_fetch_array($rs,$i); $i++)
{
	$hi = (float)$row["max_tmpf"];
	$lo = (float)$row["min_tmpf"];
	$gdd = calcGDD($hi, $lo);
	$atot += $gdd;
	$aobs[$i] = $atot;
	$obs[$i] = $gdd;
}

/* Now we need the climate data */
$q = "SELECT gdd50, valid from climate
		WHERE station = '". strtolower($climate_site) ."' and valid between '$s2date' and
		'$e2date'
		ORDER by valid ASC";
$rs = pg_exec($coopdb, $q);
$climate = Array();
$cdiff = Array();
$aclimate = Array();
$atot = 0;
$zeros = Array();
$xlabels = Array();
for( $i=0; $row = @pg_fetch_array($rs,$i); $i++) 
{
	$gdd = (float)$row["gdd50"];
	$atot += $gdd;
	if (@$aobs[$i] > 0)
	{
{'fraction_non_alphanumeric': 0.25676807144850683, 'fraction_numerical': 0.032096008931063354, 'mean_word_length': 4.652996845425868, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6589597', 'n_tokens_mistral': 1611, 'n_tokens_neox': 1526, 'n_words': 345}