function checkSimilarResults()
{
    #----------------------------------------------------------------------
    global $competitionCondition, $chosenWhich;
    echo "<hr /><p>Checking <b>" . $chosenWhich . " similar results</b>... (wait for the result message box at the end)</p>\n";
    #--- Get all similar results (except old-new multiblind)
    $rows = pdo_query("\n      SELECT\n          Results.competitionId AS competitionId,\n          Results.personId AS personIdA, Results.personName AS personNameA, Results.eventId AS eventIdA, Results.roundId AS roundIdA,\n          h.personId AS personIdB, h.personName AS personNameB, h.eventId AS eventIdB, h.roundId AS roundIdB,\n          Results.value1 AS value1A, Results.value2 AS value2A, Results.value3 AS value3A, Results.value4 AS value4A, Results.value5 AS value5A,\n          h.value1 AS value1B, h.value2 AS value2B, h.value3 AS value3B, h.value4 AS value4B, h.value5 AS value5B\n      FROM Results\n      JOIN (\n          SELECT competitionId, eventId, roundId, personId, personName, value1, value2, value3, value4, value5\n          FROM Results " . ($competitionCondition ? "JOIN Competitions ON Competitions.id = competitionId " : "") . "WHERE best > 0 " . ($competitionCondition ? $competitionCondition : "") . " AND value3 <> 0\n              AND eventId <> '333mbo'\n      ) h ON Results.competitionId = h.competitionId\n          AND Results.eventId <> '333mbo'\n          AND Results.personId < h.personId\n          AND (\n              (Results.value1 = h.value1 AND h.value1 > 0) +\n              (Results.value2 = h.value2 AND h.value2 > 0) +\n              (Results.value3 = h.value3 AND h.value3 > 0) +\n              (Results.value4 = h.value4 AND h.value4 > 0) +\n              (Results.value5 = h.value5 AND h.value5 > 0) > 2\n              )\n  ");
    tableBegin('results', 4);
    foreach ($rows as $row) {
        $competition = getCompetition($row['competitionId']);
        $competitionName = $competition['cellName'];
        tableCaption(false, competitionLink($row['competitionId'], $competitionName));
        tableHeader(explode('|', "Person|Event|Round|Result Details"), array(3 => 'class="f"'));
        foreach (array('A', 'B') as $letter) {
            $otherLetter = chr(65 + 66 - ord($letter));
            $resultStr = '';
            for ($i = 1; $i <= 5; $i++) {
                $value = $row['value' . $i . $letter];
                if (!$value) {
                    break;
                }
                $resultStr .= "<span class='label label-" . ($value == $row['value' . $i . $otherLetter] ? "danger" : "success") . "'>" . formatValue($value, valueFormat($row['eventId' . $letter])) . "</span> ";
            }
            tableRow(array(personLink($row['personId' . $letter], $row['personName' . $letter]), eventCellName($row['eventId' . $letter]), roundCellName($row['roundId' . $letter]), $resultStr));
        }
    }
    tableEnd();
    #--- Tell the result.
    $date = wcaDate();
    noticeBox2(count($rows) == 0, "No similar results were found.<br />{$date}", "Similar results were found.<br />{$date}");
}
function checkRoundNames($roundInfos, $competitionId, $eventId)
{
    #----------------------------------------------------------------------
    #--- Whose rounds are combined
    $listCombined = array('h' => true, '0' => false, 'd' => true, '1' => false, '2' => false, 'e' => true, 'g' => true, '3' => false, 'c' => true, 'f' => false);
    #--- Switch between combined and not combined
    $switchCombined = array('h' => '0', '0' => 'h', 'd' => '1', '1' => 'd', '2' => 'e', 'e' => '2', 'g' => '3', '3' => 'g', 'c' => 'f', 'f' => 'c');
    $normalRoundIds = array(0 => array(), 1 => array('f'), 2 => array('1', 'f'), 3 => array('1', '2', 'f'), 4 => array('1', '2', '3', 'f'));
    $nbErrors = 0;
    $nbRounds = ($roundInfos[0][0] == '0' or $roundInfos[0][0] == 'h') ? count($roundInfos) - 1 : count($roundInfos);
    foreach ($roundInfos as $roundInfo) {
        list($roundId, $roundCellName, $formatId, $isNotCombined) = $roundInfo;
        $backRoundId = $roundId;
        #--- Check for round "combined-ness"
        if (!$isNotCombined xor $listCombined[$roundId]) {
            echo "<p style='margin-top:2em; margin-bottom:0'><a href='https://www.worldcubeassociation.org/results/c.php?i={$competitionId}&allResults=1#e{$eventId}_{$roundId}'>{$competitionId} - {$eventId} - {$roundId}</a></p>";
            echo "<p>Round {$roundCellName} should " . ($isNotCombined ? "not " : "") . "be a combined round</p>";
            $roundId = $switchCombined[$roundId];
            $nbErrors += 1;
        }
        if ($backRoundId != '0' and $backRoundId != 'h') {
            #--- Check for round name
            $normalRoundId = array_shift($normalRoundIds[$nbRounds]);
            if (($listCombined[$roundId] ? $switchCombined[$roundId] : $roundId) != $normalRoundId) {
                $roundId = $listCombined[$roundId] ? $switchCombined[$normalRoundId] : $normalRoundId;
                echo "<p style='margin-top:2em; margin-bottom:0'><a href='https://www.worldcubeassociation.org/results/c.php?i={$competitionId}&allResults=1#e{$eventId}_{$roundId}'>{$competitionId} - {$eventId} - {$backRoundId}</a></p>";
                echo "<p>Round {$roundCellName} should be " . roundCellName($roundId) . "</p>";
                $nbErrors += 1;
            }
        }
        $translateRounds[$backRoundId] = $roundId;
    }
    if ($nbErrors) {
        changeRounds($competitionId, $eventId, $translateRounds, true);
    }
    return $nbErrors;
}