function OnLoadPageData() { # new data manager $manager = new MatchManager($this->GetSettings(), $this->GetDataConnection()); # Check for month value if (isset($_GET['month']) and is_numeric($_GET['month'])) { # Make sure it looks real $i_day = (int) date('d', $_GET['month']); $i_year = (int) date('Y', $_GET['month']); $i_month = (int) date('m', $_GET['month']); if ($i_year >= 2000 and $i_year <= 2050 and $i_month >= 1 and $i_month <= 12 and $i_day == 1) { # Read start date specified by user, which will be with DST applied because users don't think in UTC $i_start = $_GET['month']; $i_end = mktime(11, 59, 59, $i_month, date('t', $_GET['month']), $i_year); # Convert to UTC, as that's how match dates are stored $i_end = gmdate('U', $i_end); $manager->FilterByDateStart($i_start); $manager->FilterByDateEnd($i_end); } } else { # get next few matches $i_one_day = 86400; $i_start = gmdate('U') - $i_one_day * 1; # yesterday $manager->FilterByDateStart($i_start); $manager->FilterByMaximumResults(50); } # Check for match type $i_match_type = null; if (isset($_GET['type']) and is_numeric($_GET['type'])) { $i_match_type = (int) $_GET['type']; if ($i_match_type < 0 or $i_match_type > 50) { $i_match_type = null; } } $a_match_types = is_null($i_match_type) ? null : array($i_match_type); $manager->FilterByMatchType($a_match_types); # Check for player type $i_player_type = null; if (isset($_GET['player']) and is_numeric($_GET['player'])) { $i_player_type = (int) $_GET['player']; if ($i_player_type < 0 or $i_player_type > 50) { $i_player_type = null; } } $a_player_types = is_null($i_player_type) ? null : array($i_player_type); $manager->FilterByPlayerType($a_player_types); $manager->ReadMatchSummaries(); $this->a_matches = $manager->GetItems(); $this->a_months = $manager->ReadMatchMonths(); # tidy up unset($manager); }