示例#1
0
        }
        $rankings = FileReader::getRankingsAtEvent($args['event']);
        if (!count($rankings)) {
            Downloader::getRankingsAtEvent($args['event']);
            header('Refresh:0');
        }
        $dlstats = FileReader::getStatsAtEvent($args['event']);
        if (!$dlstats && !count($dlstats)) {
            Downloader::getStatsAtEvent($args['event']);
            header('Refresh:0');
        }
        $stats = array();
        for ($i = 0; $i < count((array) $dlstats->oprs); $i++) {
            $tempTeam = array_keys((array) $dlstats->oprs)[$i];
            $opr = $dlstats->oprs->{$tempTeam};
            $dpr = $dlstats->dprs->{$tempTeam};
            $ccwm = $dlstats->ccwms->{$tempTeam};
            $stats[$tempTeam] = array('number' => $tempTeam, 'opr' => $opr, 'dpr' => $dpr, 'ccwm' => $ccwm);
        }
        $this->view->render($res, 'event.html', ['title' => $event->name, 'event' => $event, 'teams' => $teams, 'stats' => $stats, 'rankings' => $rankings, 'matches' => $matches, 'user' => Auth::getLoggedInUser()]);
    });
    $this->get('/{event:\\d{4}[A-Za-z]{1,4}}/update', function ($req, $res, $args) {
        Auth::redirectIfNotLoggedIn();
        FileReader::getEvent($args['event'], true);
        FileReader::getTeamsAtEvent($args['event'], true);
        FileReader::getMatchesAtEvent($args['event'], true);
        FileReader::getStatsAtEvent($args['event'], true);
        FileReader::getRankingsAtEvent($args['event'], true);
        return $res->withStatus(302)->withHeader('Location', '/event/' . $args['event']);
    });
});