// simple validation first... if (!preg_match('/\\d{4}\\w{4}\\d{2}/', $chosenPersonId)) { showErrorMessage('Invalid WCA id Format <strong>[</strong>' . o($chosenPersonId) . '<strong>]</strong>'); print '<p><a href="persons.php">Click here to search for people.</a></p>'; require 'includes/_footer.php'; die; } #--- Get all incarnations of the person. $persons = dbQuery("\n SELECT person.name personName, country.name countryName, day, month, year, gender\n FROM Persons person, Countries country\n WHERE person.id = '{$chosenPersonId}' AND country.id = person.countryId\n ORDER BY person.subId\n"); #--- If there are none, show an error and do no more. if (!count($persons)) { showErrorMessage('Unknown person id <strong>[</strong>' . o($chosenPersonId) . '<strong>]</strong>'); $namepart = substr($chosenPersonId, 4, 4); print '<p><a href="persons.php?pattern=' . urlEncode($namepart) . '">Click to search for people with `' . o($namepart) . '` in their name.</a></p>'; require 'includes/_footer.php'; die; } #--- Get and show the current incarnation. $currentPerson = array_shift($persons); echo "<h1>" . o($currentPerson['personName']) . " - Map of Competitions</h1>"; echo "<h2><a href='p.php?i=" . urlEncode($chosenPersonId) . "'>Back to Competitor Page</a></h2>"; // create map markers $markers = array(); foreach ($chosenCompetitions as $comp) { $markers[$comp['id']] = array(); $markers[$comp['id']]['latitude'] = $comp['latitude']; $markers[$comp['id']]['longitude'] = $comp['longitude']; $markers[$comp['id']]['info'] = "<a href='/competitions/{$comp['id']}'>" . o($comp['cellName']) . "</a><br />" . date("M j, Y", mktime(0, 0, 0, $comp['month'], $comp['day'], $comp['year'])) . " - " . o($comp['cityName']); } displayMap($markers); require 'includes/_footer.php';
function listCompetitions () { #---------------------------------------------------------------------- global $chosenEventId, $chosenYears, $chosenRegionId, $chosenPatternHtml; global $chosenList, $chosenMap; global $chosenCompetitions; $chosenCompetitions = getCompetitions( $chosenList ); tableBegin( 'results', 5 ); tableCaption( false, spaced(array( eventName($chosenEventId), chosenRegionName(), $chosenYears, $chosenPatternHtml ? "\"$chosenPatternHtml\"" : '' ))); if( $chosenList ){ tableHeader( explode( '|', 'Year|Date|Name|Country, City|Venue' ), array( 4 => 'class="f"' )); foreach( $chosenCompetitions as $competition ){ extract( $competition ); if( isset( $previousYear ) && $year != $previousYear ) tableRowEmpty(); $previousYear = $year; $isPast = wcaDate( 'Ymd' ) > (10000*$year + 100*$month + $day); tableRow( array( $year, competitionDate( $competition ), $isPast ? competitionLink( $id, $cellName ) : (( $showPreregForm || $showPreregList ) ? competitionLinkClassed( 'rg', $id, $cellName ) : competitionLinkClassed( 'fc', $id, $cellName )), "<b>$countryName</b>, $cityName", processLinks( $venue ) )); } } tableEnd(); if( $chosenMap ) { // create map markers $markers = array(); foreach($chosenCompetitions as $comp) { $markers[$comp['id']] = array(); $markers[$comp['id']]['latitude'] = $comp['latitude']; $markers[$comp['id']]['longitude'] = $comp['longitude']; $markers[$comp['id']]['info'] = "<a href='c.php?i=".$comp['id']."'>" . o($comp['cellName']) . "</a><br />" . date("M j, Y", mktime(0,0,0,$comp['month'],$comp['day'],$comp['year'])) . " - " . o($comp['cityName']); } displayMap($markers); } }
<style> body { font-family: "Courier New"; } </style> </head> <body> <?php $startX = 1; $startY = 1; $currentX = $startX; $currentY = $startY; $endX = 9; $endY = 9; $map = createMap(10, 10); $dirDice = array("Forward", "Backward", "Left", "Right"); travel($endX, $endY, 100); displayMap($map); function move($move) { global $map, $currentX, $currentY, $dirDice; $invalidMove = true; $tmpDice = array_merge(array(), $dirDice); while ($invalidMove) { $tmpX = $currentX; $tmpY = $currentY; if (!empty($tmpDice)) { $index = array_rand($tmpDice, 1); $direction = $tmpDice[$index]; if ($direction == "Forward") { $tmpX--; } else { if ($direction == "Backward") {