function showCompetitionInfos () { #---------------------------------------------------------------------- global $chosenCompetitionId; #--- Get the competition infos from the database. $competition = getFullCompetitionInfos( $chosenCompetitionId ); extract( $competition ); $delegates = getCompetitionDelegates( $chosenCompetitionId ); $wcaDelegate = joinUsers( $delegates, true ); $organizers = getCompetitionOrganizers( $chosenCompetitionId ); // Only show organizer emails if there is no contact info given. $organizer = joinUsers( $organizers, !$contact ); #--- Show the infos. echo "<h1>$name</h1>\n"; #--- Start the table. echo "<div class='table-responsive'>\n"; echo "<table width='100%' id='competitionDetails'><tr valign='top'>\n"; #--- Left part. echo "<td style='width:70%'><table>"; $country = getCountry($countryId); showItem( 'key', "Date", array( competitionDate( $competition ), $year )); showItem( 'key', "City", array( $cityName, $country['name'] )); showItem( 'key', "Venue", array( $venue )); showItem( 'sub', "Address", array( $venueAddress )); showItem( 'sub', "Details", array( $venueDetails )); showItem( 'key', "Website", array( $website )); showItem( 'key', "Organizer", array( $organizer )); showItem( 'key', "WCA Delegate", array( $wcaDelegate )); showItem( 'key', "Contact", array( $contact )); echo "</table></td>"; #--- Right part. echo "<td style='width:30%'><table>"; showItem( 'key', "Information", array( $information )); showListItemNew( 'View results for', computeCompetitionEvents( $eventSpecs )); showListItemNew( 'Reports', computeMedia( 'report' )); showListItemNew( 'Articles', computeMedia( 'article' )); showListItemNew( 'Multimedia', computeMedia( 'multimedia' )); echo "</table></td>"; #--- End table. echo "</tr></table></div>"; }
function savePreregForm() { #---------------------------------------------------------------------- global $chosenCompetitionId, $competition, $config; $personId = getMysqlParam('personId'); $name = getMysqlParam('name'); $countryId = getMysqlParam('countryId'); $gender = getMysqlParam('gender'); $birthYear = getMysqlParam('birthYear'); $birthMonth = getMysqlParam('birthMonth'); $birthDay = getMysqlParam('birthDay'); $email = getMysqlParam('email'); $guests = getMysqlParam('guests'); $comments = getMysqlParam('comments'); $ip = getMysqlParam('ip'); if (!$name or !$email or !$gender) { noticeBox(false, "Fields 'name', 'gender' and 'email' are required."); return false; } if (!preg_match("/^[_0-9a-zA-Z-]+(\\.[_0-9a-zA-Z-]+)*@[0-9a-zA-Z-]+(\\.[0-9a-zA-Z-]+)*(\\.[a-zA-Z]{2,3})\$/", $email)) { noticeBox(false, "Incorrect email address."); return false; } if ($birthYear == date('Y')) { noticeBox(false, "Please enter your date of birth."); return false; } if (!$birthYear) { $chosenPerson = dbQuery("SELECT * FROM Persons WHERE id='{$personId}'"); $chosenPerson = $chosenPerson[0]; $birthYear = $chosenPerson['year']; $birthMonth = $chosenPerson['month']; $birthDay = $chosenPerson['day']; } $guests = str_replace(array("\r\n", "\n", "\r", ","), ";", $guests); #--- Building query $eventIds = ''; foreach (getAllEventIds() as $eventId) { if (getBooleanParam("E{$eventId}")) { $eventIds .= "{$eventId} "; } } rtrim($eventIds); # Remove last space $into = "competitionId, name, personId, countryId, gender, birthYear, birthMonth, birthDay, email, guests, comments, ip, status, eventIds"; $values = "'{$chosenCompetitionId}', '{$name}', '{$personId}', '{$countryId}', '{$gender}', '{$birthYear}', '{$birthMonth}', '{$birthDay}', '{$email}', '{$guests}', '{$comments}', '{$ip}', 'p', '{$eventIds}'"; dbCommand("INSERT INTO Preregs ({$into}) VALUES ({$values})"); $organizers = getCompetitionOrganizers($competition['id']); foreach ($organizers as $organizer) { $mailEmail = $organizer['email']; // load more competition data for a nicer email $result = dbQuery("SELECT * FROM Competitions WHERE id='{$chosenCompetitionId}'"); $competition_data = $result[0]; $mailBody = "A new competitor has registered for your competition - " . $competition['cellName'] . "! "; $mailBody .= "Their information is below.\n-------------------\n"; if ($personId) { $mailBody .= "Name : {$name}"; $mailBody .= " {$personId} - https://www.worldcubeassociation.org/results/p.php?i={$personId}\n"; } else { $mailBody .= "Name : {$name}\n"; } $mailBody .= "Country : {$countryId}\n"; $mailBody .= "Gender : {$gender}\n"; $mailBody .= "Date of birth : {$birthYear}/{$birthMonth}/{$birthDay}\n"; $mailBody .= "Email : {$email}\n"; $mailBody .= "Events : {$eventIds}\n"; $mailBody .= "Guests : {$guests}\n"; $mailBody .= "Comments : {$comments}\n"; $mailBody .= "Ip : {$ip}\n"; $mailBody .= "-------------------\n"; $mailBody .= "You may edit this registration (and others) at:\n"; $mailBody .= "https://www.worldcubeassociation.org/competitions/{$chosenCompetitionId}/registrations"; $mailSubject = $competition['cellName'] . " - New registration"; $mail_config = $config->get('mail'); // only send mails on the real website if (preg_match('/^www.worldcubeassociation.org$/', $_SERVER["SERVER_NAME"])) { if ($mail_config['pear']) { // send smtp mail $headers = array('From' => $mail_config['from'], 'To' => $mailEmail, 'Subject' => $mailSubject); $smtp = Mail::factory('smtp', array('host' => $mail_config['host'], 'port' => $mail_config['port'], 'auth' => true, 'username' => $mail_config['user'], 'password' => $mail_config['pass'])); $mail = $smtp->send($mailEmail, $headers, $mailBody); } else { // normal php mail $mailHeaders = "From: \"WCA\" <" . $mail_config['from'] . ">\r\n"; $mailHeaders .= "Reply-To: board@worldcubeassociation.org\r\n"; $mailHeaders .= "MIME-Version: 1.0\r\n"; $mailHeaders .= "Content-Type: text/plain; charset=UTF-8\r\n"; mail($mailEmail, $mailSubject, $mailBody, $mailHeaders, "-f" . $mail_config['from']); } } else { // just print out message when testing noticeBox3(0, "Mail not sent (test website): " . $mailBody); } } noticeBox(true, "Registration complete.<br />Please note that all registrations must be approved by the organizer.<br/>Your registration will appear here within a few days."); return true; }