function analyzeChoices()
{
    #----------------------------------------------------------------------
    global $chosenEventId, $chosenCompetitionId, $chosenShow, $chosenAnything;
    $chosenEventId = getNormalParam('eventId');
    $chosenCompetitionId = getNormalParam('competitionId');
    $chosenShow = getBooleanParam('show');
    $chosenAnything = $chosenEventId || $chosenCompetitionId;
}
function analyzeChoices()
{
    #----------------------------------------------------------------------
    global $chosenCompetitionId, $chosenShow, $competitionCondition, $competitionDescription;
    $chosenCompetitionId = getNormalParam('competitionId');
    $chosenShow = getBooleanParam('show');
    $competitionCondition = competitionCondition();
    $competitionDescription = $chosenCompetitionId ? $chosenCompetitionId : "all competitions";
}
function analyzeChoices () {
#----------------------------------------------------------------------
  global $chosenUpload, $chosenConfirm, $chosenNamesFile, $chosenFilename;

  $chosenUpload      = getBooleanParam( 'upload' );
  $chosenConfirm     = getBooleanParam( 'confirm' );
  $chosenNamesFile   = getNormalParam( 'namesFile' );
  $chosenFilename    = getNormalParam( 'filename' );

}
function analyzeChoices()
{
    #----------------------------------------------------------------------
    global $chosenRegionId;
    global $chosenSingle, $chosenAverage;
    $chosenRegionId = getNormalParam('regionId');
    $chosenSingle = getBooleanParam('single');
    $chosenAverage = getBooleanParam('average');
    if (!$chosenAverage) {
        $chosenSingle = true;
    }
}
function analyzeChoices()
{
    #----------------------------------------------------------------------
    global $chosenEventId, $chosenCompetitionId, $chosenWhat, $chosenShow, $chosenWhich, $competitionCondition;
    $chosenEventId = getNormalParam('eventId');
    $chosenCompetitionId = getNormalParam('competitionId');
    $chosenWhat = getNormalParam('what');
    $chosenShow = getBooleanParam('show');
    $chosenWhich = "";
    $chosenWhich .= $chosenEventId ? $chosenEventId : "all events";
    $chosenWhich .= " in " . ($chosenCompetitionId ? $chosenCompetitionId : "all competitions");
    $competitionCondition = eventCondition() . competitionCondition();
}
function analyzeChoices()
{
    #----------------------------------------------------------------------
    global $chosenEventId, $chosenRegionId, $chosenYears, $chosenShow;
    global $chosenSingle, $chosenAverage;
    $chosenEventId = getNormalParamDefault('eventId', '333');
    $chosenRegionId = getNormalParam('regionId');
    $chosenYears = getNormalParam('years');
    $chosenShow = getNormalParamDefault('show', '100 Persons');
    $chosenSingle = getBooleanParam('single');
    $chosenAverage = getBooleanParam('average');
    if (!$chosenAverage) {
        $chosenSingle = true;
    }
}
function analyzeChoices()
{
    #----------------------------------------------------------------------
    global $chosenRegionId, $chosenEventId, $chosenYears;
    global $chosenMixed, $chosenSlim, $chosenSeparate, $chosenHistory, $chosenMixHist;
    $chosenRegionId = getNormalParam('regionId');
    $chosenEventId = getNormalParam('eventId');
    $chosenYears = getNormalParam('years');
    $chosenMixed = getBooleanParam('mixed');
    $chosenSlim = getBooleanParam('slim');
    $chosenSeparate = getBooleanParam('separate');
    $chosenHistory = getBooleanParam('history');
    $chosenMixHist = getBooleanParam('mixHist');
    if (!$chosenSlim && !$chosenSeparate && !$chosenHistory && !$chosenMixHist) {
        $chosenMixed = true;
    }
}
function analyzeChoices () {
#----------------------------------------------------------------------
  global $chosenId, $chosenConfirm, $chosenName, $chosenNameHtml, $chosenCountryId, $chosenGender, $chosenDay, $chosenMonth, $chosenYear, $chosenUpdate, $chosenFix;

  $chosenConfirm     = getBooleanParam( 'confirm'   );
  $chosenUpdate      = getBooleanParam( 'update'    );
  $chosenFix         = getBooleanParam( 'fix'       );
  $chosenId          = getNormalParam ( 'id'        );
  $chosenName        = getMysqlParam  ( 'name'      );
  $chosenNameHtml    = getHtmlParam   ( 'name'      );
  $chosenCountryId   = getMysqlParam  ( 'countryId' );
  $chosenGender      = getNormalParam ( 'gender'    );
  $chosenDay         = getNormalParam ( 'day'       );
  $chosenMonth       = getNormalParam ( 'month'     );
  $chosenYear        = getNormalParam ( 'year'      );

}
function analyzeChoices()
{
    #----------------------------------------------------------------------
    global $chosenEventId, $chosenRegionId, $chosenYears, $chosenPatternHtml, $chosenPatternMysql, $chosenList, $chosenMap;
    $chosenEventId = getNormalParam('eventId');
    $chosenRegionId = getNormalParam('regionId');
    $chosenPatternHtml = getHtmlParam('pattern');
    $chosenPatternMysql = getMysqlParam('pattern');
    $chosenYears = getNormalParam('years');
    $chosenList = getBooleanParam('list');
    $chosenMap = getBooleanParam('map');
    if (!$chosenList && !$chosenMap) {
        $chosenYears = "current";
    }
    if (!$chosenMap) {
        $chosenList = true;
    }
}
function analyzeChoices () {
#----------------------------------------------------------------------
  global $chosenCompetitionId;
  global $chosenByPerson, $chosenAllResults, $chosenTop3, $chosenWinners;
  global $chosenForm, $chosenList;

  $chosenCompetitionId = getNormalParam( 'competitionId' );

  $chosenByPerson      = getBooleanParam( 'byPerson' );
  $chosenAllResults    = getBooleanParam( 'allResults' );
  $chosenTop3          = getBooleanParam( 'top3' );
  $chosenWinners       = getBooleanParam( 'winners' );
  if( !$chosenAllResults  &&  !$chosenTop3 && !$chosenByPerson )
    $chosenWinners = true;
    
  $chosenForm          = getBooleanParam( 'form' );
  $chosenList          = getBooleanParam( 'list' );
  if( !$chosenForm ) $chosenList = true;
}
function analyzeChoices()
{
    #----------------------------------------------------------------------
    global $chosenId, $chosenConfirm, $chosenName, $chosenNameHtml, $chosenCountryId, $chosenGender, $chosenDay, $chosenMonth, $chosenYear, $chosenUpdate, $chosenFix;
    $chosenConfirm = getBooleanParam('confirm');
    $chosenUpdate = getBooleanParam('update');
    $chosenFix = getBooleanParam('fix');
    $chosenId = getNormalParam('id');
    // Gah, this is awful. We can't call getNormalParam because it refuses to
    // return anything if the parameter has a quote in it. We don't want to call
    // getMysqlParam, as we're using pdo_query throughout this file, and we don't
    // want double escaping to occur.
    $chosenName = getRawParamThisShouldBeAnException('name');
    $chosenNameHtml = getHtmlParam('name');
    $chosenCountryId = getNormalParam('countryId');
    $chosenGender = getNormalParam('gender');
    $chosenDay = getNormalParam('day');
    $chosenMonth = getNormalParam('month');
    $chosenYear = getNormalParam('year');
}
function showContent()
{
    #----------------------------------------------------------------------
    #--- In debug mode, just calculate freshly and don't cache
    if (wcaDebug()) {
        showResults();
        return;
    }
    #--- If there's no cache or this is an update request, then freshly build the cache
    if (!file_exists('generated/statistics.cache') || getBooleanParam('update8392')) {
        $startTime = microtime_float();
        ob_start();
        showResults();
        file_put_contents('generated/statistics.cache', ob_get_contents());
        ob_end_clean();
        $logMessage = sprintf("%s: Updating took %.2f seconds.", wcaDate(), microtime_float() - $startTime);
        file_put_contents('generated/statistics.log', "{$logMessage}\n", FILE_APPEND);
        echo "<p>{$logMessage}</p>";
    }
    #--- Show the cache
    echo file_get_contents('generated/statistics.cache');
}
<?php
// session information needs to be created before <html> tag is output.  Thus this php code should come at the beginning of the file.
require_once '_parameters.php';
if ( wcaDebug() ) {
  // Show errors in debug mode.
  error_reporting(E_ALL);
  ini_set("display_errors", 1);
} else {
  error_reporting(0);
  ini_set("display_errors", 0);
}
require_once( '_framework.php' );
$standAlone = getBooleanParam( 'standAlone' );

?><!doctype html><html lang="en">
<head>
<title>World Cube Association - Official Results</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="WCA Website Team" />
<meta name="description" content="Official World Cube Association Competition Results" />
<meta name="keywords" content="rubik's cube,puzzles,competition,official results,statistics,WCA" />
<link rel="shortcut icon" href="<?php print pathToRoot(); ?>images/wca.ico" />

<?php

$jQuery = true; // For bootstrap.

/* Deal with scripts here, for now */
$scripts = new WCAClasses\WCAScripts();
if(isset($jQuery) && $jQuery) {
function showPreregList()
{
    #----------------------------------------------------------------------
    global $chosenCompetitionId;
    if (getBooleanParam('isPreregSubmit')) {
        savePreregForm();
    }
    $eventId = getNormalParam('eventId');
    if ($eventId) {
        showPsychSheet($eventId);
        return;
    }
    echo "<h1>Registered competitors</h1><br />";
    #--- Get the data.
    $preregs = dbQuery("SELECT * FROM Preregs WHERE competitionId = '{$chosenCompetitionId}' AND status='a' ORDER BY countryId, name");
    $competition = getFullCompetitionInfos($chosenCompetitionId);
    #--- Get all events of the competition.
    $eventList = getEventSpecsEventIds($competition['eventSpecs']);
    $headerEvent = "";
    $headerEventLink = "";
    foreach ($eventList as $event) {
        $headerEvent .= "|{$event}";
        $headerEventLink .= "|<a href='c.php?list=1&competitionId={$chosenCompetitionId}&eventId={$event}'>{$event}</a>";
    }
    for ($i = 3; $i < 3 + count($eventList); $i++) {
        $tableStyle[$i] = 'class="c"';
    }
    $tableStyle[3 + count($eventList)] = 'class="f"';
    tableBegin('results', 4 + count($eventList));
    $countPerson = 0;
    $countCountry = 0;
    foreach ($preregs as $prereg) {
        extract($prereg);
        if (!($countPerson % 20)) {
            if ($countPerson) {
                tableHeader(explode('|', "#|Person|Citizen of{$headerEvent}|"), $tableStyle);
            } else {
                if (isset($standAlone)) {
                    tableHeader(explode('|', "#|Person|Citizen of{$headerEvent}|"), $tableStyle);
                } else {
                    tableHeader(explode('|', "#|Person|Citizen of{$headerEventLink}|"), $tableStyle);
                }
            }
        }
        $countPerson += 1;
        #--- Compute the row.
        $row = array($countPerson);
        if ($personId) {
            if (preg_match('/competition_registration.php/', $_SERVER['PHP_SELF'])) {
                $row[] = "<a target='_blank' class='p' href='p.php?i={$personId}'>{$name}</a>";
            } else {
                $row[] = personLink($personId, $name);
            }
        } else {
            $row[] = $name;
        }
        $row[] = $countryId;
        if (!isset($listCountries[$countryId])) {
            $listCountries[$countryId] = 1;
            $countCountry += 1;
        }
        $personEvents = 0;
        $eventIdsList = array_flip(explode(' ', $eventIds));
        foreach ($eventList as $event) {
            if (isset($eventIdsList[$event])) {
                $row[] = 'X';
                $countEvents[$event] = isset($countEvents[$event]) ? $countEvents[$event] + 1 : 1;
                $personEvents += 1;
            } else {
                $row[] = '-';
            }
        }
        $row[] = $personEvents;
        tableRow($row);
    }
    $row = array('', 'Total', $countCountry);
    foreach ($eventList as $event) {
        if (isset($countEvents[$event])) {
            $row[] = $countEvents[$event];
        } else {
            $row[] = 0;
        }
    }
    $row[] = '';
    tableHeader($row, $tableStyle);
    tableEnd();
}