Example #1
0
$overrideTitle = "Modify Signup";
get_header();
get_sidebar();
$tournamentKey = $_GET['tournament'];
if (!$tournamentKey) {
    die("Which tournament?");
}
$signupKey = $_GET['signup'];
if (!$signupKey) {
    die("Which signup?");
}
$connection = new mysqli($db_hostname, $db_username, $db_password, $db_database);
if ($connection->connect_error) {
    die($connection->connect_error);
}
$signup = GetSignup($connection, $signupKey);
if (empty($signup)) {
    die("There is no data for signup key: " . $signupKey);
}
$players = GetPlayersForSignUp($connection, $signupKey);
if (count($players) == 0) {
    die("There are no players for signup code " . $_GET['signup']);
}
$t = GetTournament($connection, $tournamentKey);
if (empty($t)) {
    die("There is no tournament numbered " . $tournamentKey);
}
//var_dump($_POST);
$error = null;
$flightErrorList = array();
$Extra = array();
Example #2
0
function SendSignupEmail($connection, $tournament, $tournamentDates, $signupKey, $web_site)
{
    $signup = GetSignup($connection, $signupKey);
    if (empty($signup)) {
        return "Did not find a signup for key: " . $signupKey;
    }
    $players = GetPlayersForSignUp($connection, $signupKey);
    if (count($players) == 0) {
        return "There are no players for signup code " . $_GET['signup'];
    }
    // compose message
    $message = "You are signed up for the Coronado Mens Golf " . $tournament->Name . ' tournament on ' . $tournamentDates . '.';
    $message .= "\n\nPlayers in your group:";
    for ($i = 0; $i < count($players); ++$i) {
        $message .= "\n    " . $players[$i]->LastName;
    }
    $message .= "\n\nRequested time: " . $signup->RequestedTime;
    $message .= "\n\nDo not reply to this email.  Contact the tournament director (" . $tournament->ChairmanName . ") if you have any questions.\n";
    $player0Message = $message . "\nTo make changes to your signup, use this access code: " . $signup->AccessCode . "\n";
    // make sure each line doesn't exceed 70 characters
    //$message = wordwrap($message, 70);
    for ($i = 0; $i < count($players); ++$i) {
        $rosterEntry = GetRosterEntry($connection, $players[$i]->GHIN);
        if (!empty($rosterEntry) && !empty($rosterEntry->Email)) {
            // send email
            if ($i == 0) {
                mail($rosterEntry->Email, 'Coronado Mens Golf Tournament Signup', $player0Message, "From: DoNotReply@" . $web_site);
            } else {
                mail($rosterEntry->Email, 'Coronado Mens Golf Tournament Signup', $message, "From: DoNotReply@" . $web_site);
            }
        }
    }
    return null;
}
Example #3
0
$signup2 = null;
$selectGroupMessage = "Select the players to add to your group:";
if (isset($_POST['AccessCode1']) || isset($_POST['AccessCode2']) || isset($_POST['MergeGroup'])) {
    $accessCode1 = trim($_POST['AccessCode1']);
    if (empty($accessCode1)) {
        $errorAccessCode1 = "Fill in the access code for your group";
    } else {
        if ($signup->AccessCode != $accessCode1) {
            $errorAccessCode1 = "Invalid access code";
        }
    }
    if (!isset($_POST['MergeGroup'])) {
        $mergeError = $selectGroupMessage;
    } else {
        // get signup for 2nd group
        $signup2 = GetSignup($connection, $_POST['MergeGroup']);
        if (empty($signup2)) {
            die("There is no data for signup key (group to add): " . $_POST['MergeGroup']);
        }
        $accessCode2 = trim($_POST['AccessCode2']);
        if (empty($accessCode2)) {
            $errorAccessCode2 = "Fill in the access code for the group to add";
        } else {
            if ($signup2->AccessCode != $accessCode2) {
                $errorAccessCode2 = "Invalid access code";
            }
        }
    }
}
$hasError = false;
if (!empty($errorAccessCode1) || !empty($errorAccessCode2) || !empty($mergeError)) {
Example #4
0
function UpdateDatabase($connection, $tournamentKey, $submitKey, $payment, $payerName, $payerEmail, $logMessage)
{
    $logFile = "./logs/ipn." . $tournamentKey . ".log";
    error_log(date('[Y-m-d H:i e] ') . $logMessage . PHP_EOL, 3, $logFile);
    if ($connection->connect_error) {
        error_log(date('[Y-m-d H:i e] ') . $connection->connect_error . PHP_EOL, 3, $logFile);
        return;
    }
    $signup = GetSignup($connection, $submitKey);
    if (empty($signup)) {
        error_log(date('[Y-m-d H:i e] ') . "Failed to find submit key " . $submitKey . " in the signup table.  Were all the players removed from the group?" . PHP_EOL, 3, $logFile);
        return;
    }
    $updatedPayment = $signup->Payment + $payment;
    // Duplicate the UpdateSignup code here so the die messages can be replace with log messages
    //UpdateSignup($connection, $submitKey, 'Payment', $updatedPayment, 'd');
    $sqlCmd = "UPDATE `SignUps` SET `Payment`= ? WHERE `SubmitKey` = ?";
    $update = $connection->prepare($sqlCmd);
    if (!$update) {
        error_log(date('[Y-m-d H:i e] ') . $sqlCmd . " prepare failed: " . $connection->error . PHP_EOL, 3, $logFile);
        return;
    }
    if (!$update->bind_param('di', $updatedPayment, $submitKey)) {
        error_log(date('[Y-m-d H:i e] ') . $sqlCmd . " bind_param failed: " . $connection->error . PHP_EOL, 3, $logFile);
        return;
    }
    if (!$update->execute()) {
        error_log(date('[Y-m-d H:i e] ') . $sqlCmd . " execute failed: " . $connection->error . PHP_EOL, 3, $logFile);
        return;
    }
    $update->close();
    // Update payment date time
    $sqlCmd = "UPDATE `SignUps` SET `PaymentDateTime`= ? WHERE `SubmitKey` = ?";
    $update = $connection->prepare($sqlCmd);
    if (!$update) {
        error_log(date('[Y-m-d H:i e] ') . $sqlCmd . " prepare failed: " . $connection->error . PHP_EOL, 3, $logFile);
        return;
    }
    $date = date('Y-m-d H:i:s');
    if (!$update->bind_param('si', $date, $submitKey)) {
        error_log(date('[Y-m-d H:i e] ') . $sqlCmd . " bind_param failed: " . $connection->error . PHP_EOL, 3, $logFile);
        return;
    }
    if (!$update->execute()) {
        error_log(date('[Y-m-d H:i e] ') . $sqlCmd . " execute failed: " . $connection->error . PHP_EOL, 3, $logFile);
        return;
    }
    $update->close();
    // Update payer name
    $sqlCmd = "UPDATE `SignUps` SET `PayerName`= ? WHERE `SubmitKey` = ?";
    $update = $connection->prepare($sqlCmd);
    if (!$update) {
        error_log(date('[Y-m-d H:i e] ') . $sqlCmd . " prepare failed: " . $connection->error . PHP_EOL, 3, $logFile);
        return;
    }
    if (!$update->bind_param('si', $payerName, $submitKey)) {
        error_log(date('[Y-m-d H:i e] ') . $sqlCmd . " bind_param failed: " . $connection->error . PHP_EOL, 3, $logFile);
        return;
    }
    if (!$update->execute()) {
        error_log(date('[Y-m-d H:i e] ') . $sqlCmd . " execute failed: " . $connection->error . PHP_EOL, 3, $logFile);
        return;
    }
    $update->close();
    // Update payer email
    $sqlCmd = "UPDATE `SignUps` SET `PayerEmail`= ? WHERE `SubmitKey` = ?";
    $update = $connection->prepare($sqlCmd);
    if (!$update) {
        error_log(date('[Y-m-d H:i e] ') . $sqlCmd . " prepare failed: " . $connection->error . PHP_EOL, 3, $logFile);
        return;
    }
    if (!$update->bind_param('si', $payerEmail, $submitKey)) {
        error_log(date('[Y-m-d H:i e] ') . $sqlCmd . " bind_param failed: " . $connection->error . PHP_EOL, 3, $logFile);
        return;
    }
    if (!$update->execute()) {
        error_log(date('[Y-m-d H:i e] ') . $sqlCmd . " execute failed: " . $connection->error . PHP_EOL, 3, $logFile);
        return;
    }
    $update->close();
    error_log(date('[Y-m-d H:i e] ') . "Updated submit key " . $submitKey . " payment to " . $updatedPayment . PHP_EOL, 3, $logFile);
}