Fixed bug that created zsh donation when an error occured
Signed-off-by: Edouard Poitras <edouard@eclipse.org>
diff --git a/thankyou.php b/thankyou.php
index b27ca1f..48f0c4d 100644
--- a/thankyou.php
+++ b/thankyou.php
@@ -95,140 +95,139 @@
setcookie ("thankyou_page[donation]", TRUE, time() + (3600 * 24 * 279), '/', '.eclipse.org');
// A/B Testing
logABTesting($Paypal, $App);
-}
+ // Sanitize Variables
+ $_POST['first_name'] = $App->sqlSanitize(filter_var($_POST['first_name'], FILTER_SANITIZE_FULL_SPECIAL_CHARS));
+ $_POST['last_name'] = $App->sqlSanitize(filter_var($_POST['last_name'], FILTER_SANITIZE_FULL_SPECIAL_CHARS));
+ $_POST['comment'] = $App->sqlSanitize(filter_var($_POST['comment'], FILTER_SANITIZE_FULL_SPECIAL_CHARS));
+ $_POST['login'] = $App->sqlSanitize(filter_var($_POST['login'], FILTER_SANITIZE_EMAIL));
-// Sanitize Variables
-$_POST['first_name'] = $App->sqlSanitize(filter_var($_POST['first_name'], FILTER_SANITIZE_FULL_SPECIAL_CHARS));
-$_POST['last_name'] = $App->sqlSanitize(filter_var($_POST['last_name'], FILTER_SANITIZE_FULL_SPECIAL_CHARS));
-$_POST['comment'] = $App->sqlSanitize(filter_var($_POST['comment'], FILTER_SANITIZE_FULL_SPECIAL_CHARS));
-$_POST['login'] = $App->sqlSanitize(filter_var($_POST['login'], FILTER_SANITIZE_EMAIL));
+ // Handle User Updating Information (anonymity, comments, etc)
+ $Paypal->set_comment($_POST['comment']);
+ $Paypal->set_email(getActiveEmail($Friend, $Paypal));
+ if ($Friend->getFirstName()) $Paypal->set_first_name($Friend->getFirstName());
+ else if ($_POST['first_name'] != "") $Paypal->set_first_name($_POST['first_name']);
+ if ($Friend->getLastName()) $Paypal->set_last_name($Friend->getLastName());
+ else if ($_POST['last_name'] != "") $Paypal->set_last_name($_POST['last_name']);
+ // Anonymity
+ if (isset($_POST['save'])) { // On Save/POST
+ $Paypal->set_anonymous($_POST['os1'] === 'Private');
+ } else { // First time always anonymous
+ $Paypal->set_anonymous(TRUE);
+ }
+ // Ready Transaction Data
+ $data = $Paypal->get_transaction_data();
+ $data['uid'] = getLDAPUIDFromEmail(getActiveEmail($Friend, $Paypal));
-// Handle User Updating Information (anonymity, comments, etc)
-$Paypal->set_comment($_POST['comment']);
-$Paypal->set_email(getActiveEmail($Friend, $Paypal));
-if ($Friend->getFirstName()) $Paypal->set_first_name($Friend->getFirstName());
-else if ($_POST['first_name'] != "") $Paypal->set_first_name($_POST['first_name']);
-if ($Friend->getLastName()) $Paypal->set_last_name($Friend->getLastName());
-else if ($_POST['last_name'] != "") $Paypal->set_last_name($_POST['last_name']);
-// Anonymity
-if (isset($_POST['save'])) { // On Save/POST
- $Paypal->set_anonymous($_POST['os1'] === 'Private');
-} else { // First time always anonymous
- $Paypal->set_anonymous(TRUE);
-}
-// Ready Transaction Data
-$data = $Paypal->get_transaction_data();
-$data['uid'] = getLDAPUIDFromEmail(getActiveEmail($Friend, $Paypal));
-
-sendEmail($data);
-// Check to see if this transaction has already been processed.
-$check_contribution = new Contribution();
-$check_transaction = $check_contribution->selectContributionExists($data['transaction_id']);
-if ($check_transaction == FALSE) { // Contribution Doesn't Already Exist
- //Check to see if user already exists in friends
- $check_friends = new Friend();
- $ldapuid = getLDAPUIDFromEmail(getActiveEmail($Friend, $Paypal));
- $friend_id = $check_friends->selectFriendID("uid", $ldapuid);
- if ($friend_id != 0) { // User Already Exist
- // Lets Update the Friend Information
- $new_friend = new Friend();
- $new_friend->selectFriend($friend_id); // Want to keep existing date_joined
- $new_friend->setFirstName($data['firstname']);
- $new_friend->setLastName($data['lastname']);
- $new_friend->setIsAnonymous($data['anonymous']);
- $new_friend->setIsBenefit($data['benefit']);
- $new_friend->setFriendID($friend_id);
- $new_friend->setLDAPUID($ldapuid);
- $new_friend_id = $new_friend->insertUpdateFriend();
- // Friend_id does not equal 0 so we have an existing user. We need to add a new contribution
- $insert_contribution = new Contribution();
- $insert_contribution->setFriendID($friend_id);
- $insert_contribution->setAmount($data['amount']);
- $insert_contribution->setMessage($data['comment']);
- $insert_contribution->setTransactionID($data['transaction_id']);
- $insert_contribution->insertContribution();
- //Record Inserted
- } else {
- // No friend_id found so add a new friend record then add the contribution record.
- $new_friend = new Friend();
- $new_friend->setFirstName($data['firstname']);
- $new_friend->setLastName($data['lastname']);
- $new_friend->setLDAPUID($ldapuid);
- $new_friend->setIsAnonymous($data['anonymous']);
- $new_friend->setIsBenefit($data['benefit']);
- $new_friend_id = $new_friend->insertUpdateFriend();
- $insert_contribution = new Contribution();
- $insert_contribution->setFriendID($new_friend_id);
- $insert_contribution->setAmount($data['amount']);
- $insert_contribution->setMessage($data['comment']);
- $insert_contribution->setTransactionID($data['transaction_id']);
- $insert_contribution->insertContribution();
- }
-}
-// User submitted an Eclipse.org ID
-if (isset($_POST['login']) && $_POST['login'] != "") {
- // Need to reload friend incase we're dealing with a non-logged in user
- // Update Anonymity
- $check_contribution->selectContributionWithTransaction($data['transaction_id']);
- $anon_friend = new Friend();
- $anon_friend->selectFriend($check_contribution->getFriendID());
- $anon_friend->setIsAnonymous($data['anonymous']);
- // Update Name
- $check_friends = new Friend();
- $ldapuid = getLDAPUIDFromEmail($_POST['login']);
- $friend_id = $check_friends->selectFriendID("uid", $ldapuid);
- if (!$friend_id) { // If no friend_id found, create the friend based on ldap information
- // Should move this to using LDAP attributes instead
- $sql = "SELECT userid, realname FROM profiles WHERE login_name = " . $App->returnQuotedString($_POST['login']);
- $result = $App->bugzilla_sql($sql);
- $values = mysql_fetch_array($result);
- $name = explode(' ', $values['realname']);
- $firstname = $name[0];
- $lastname = $name[1];
- $anon_friend->setFirstName($firstname);
- $anon_friend->setLastName($lastname);
- $anon_friend->setEmail($_POST['login']);
- $anon_friend->setLDAPUID($ldapuid);
- $data['firstname'] = $firstname;
- $data['lastname'] = $lastname;
- $anon_friend->insertUpdateFriend();
- $check_contribution->setFriendID($anon_friend->getFriendID());
- $check_contribution->updateContribution();
- } else {
- $existing_friend = new Friend();
- $existing_friend->selectFriend($friend_id);
- $existing_friend->setIsAnonymous($data['anonymous']);
- $existing_friend->insertUpdateFriend();
- $data['firstname'] = $existing_friend->getFirstName();
- $data['lastname'] = $existing_friend->getLastName();
- $check_contribution->setFriendID($friend_id);
- $check_contribution->updateContribution();
- }
-}
-
-// Check to see if this transaction has already been processed.
-$check_contribution = new Contribution();
-$check_transaction = $check_contribution->selectContributionExists($data['transaction_id']);
-if ($check_transaction == TRUE) { // Contribution Already Exist - Check for name and message change
- // Update contribution
- $check_contribution->selectContributionWithTransaction($data['transaction_id']);
- $check_contribution->setMessage($data['comment']);
- $check_contribution->updateContribution();
- // Get friend from friend_id from transaction
- $check_friends = new Friend();
- $check_friends->selectFriend($check_contribution->getFriendID());
- if ($check_friends->getFriendID() != 0) { // User Already Exist
- // Update Anonymity
- $check_friends->setIsAnonymous($data['anonymous']);
- $check_friends->insertUpdateFriend();
- } else {
+ sendEmail($data);
+ // Check to see if this transaction has already been processed.
+ $check_contribution = new Contribution();
+ $check_transaction = $check_contribution->selectContributionExists($data['transaction_id']);
+ if ($check_transaction == FALSE) { // Contribution Doesn't Already Exist
+ //Check to see if user already exists in friends
+ $check_friends = new Friend();
$ldapuid = getLDAPUIDFromEmail(getActiveEmail($Friend, $Paypal));
- $check_friends->setFirstName($data['firstname']);
- $check_friends->setLastName($data['lastname']);
- $check_friends->setIsAnonymous($data['anonymous']);
- $check_friends->setIsBenefit($data['benefit']);
- $check_friends->setLDAPUID($ldapuid);
- $check_friends->insertUpdateFriend();
+ $friend_id = $check_friends->selectFriendID("uid", $ldapuid);
+ if ($friend_id != 0) { // User Already Exist
+ // Lets Update the Friend Information
+ $new_friend = new Friend();
+ $new_friend->selectFriend($friend_id); // Want to keep existing date_joined
+ $new_friend->setFirstName($data['firstname']);
+ $new_friend->setLastName($data['lastname']);
+ $new_friend->setIsAnonymous($data['anonymous']);
+ $new_friend->setIsBenefit($data['benefit']);
+ $new_friend->setFriendID($friend_id);
+ $new_friend->setLDAPUID($ldapuid);
+ $new_friend_id = $new_friend->insertUpdateFriend();
+ // Friend_id does not equal 0 so we have an existing user. We need to add a new contribution
+ $insert_contribution = new Contribution();
+ $insert_contribution->setFriendID($friend_id);
+ $insert_contribution->setAmount($data['amount']);
+ $insert_contribution->setMessage($data['comment']);
+ $insert_contribution->setTransactionID($data['transaction_id']);
+ $insert_contribution->insertContribution();
+ //Record Inserted
+ } else {
+ // No friend_id found so add a new friend record then add the contribution record.
+ $new_friend = new Friend();
+ $new_friend->setFirstName($data['firstname']);
+ $new_friend->setLastName($data['lastname']);
+ $new_friend->setLDAPUID($ldapuid);
+ $new_friend->setIsAnonymous($data['anonymous']);
+ $new_friend->setIsBenefit($data['benefit']);
+ $new_friend_id = $new_friend->insertUpdateFriend();
+ $insert_contribution = new Contribution();
+ $insert_contribution->setFriendID($new_friend_id);
+ $insert_contribution->setAmount($data['amount']);
+ $insert_contribution->setMessage($data['comment']);
+ $insert_contribution->setTransactionID($data['transaction_id']);
+ $insert_contribution->insertContribution();
+ }
+ }
+ // User submitted an Eclipse.org ID
+ if (isset($_POST['login']) && $_POST['login'] != "") {
+ // Need to reload friend incase we're dealing with a non-logged in user
+ // Update Anonymity
+ $check_contribution->selectContributionWithTransaction($data['transaction_id']);
+ $anon_friend = new Friend();
+ $anon_friend->selectFriend($check_contribution->getFriendID());
+ $anon_friend->setIsAnonymous($data['anonymous']);
+ // Update Name
+ $check_friends = new Friend();
+ $ldapuid = getLDAPUIDFromEmail($_POST['login']);
+ $friend_id = $check_friends->selectFriendID("uid", $ldapuid);
+ if (!$friend_id) { // If no friend_id found, create the friend based on ldap information
+ // Should move this to using LDAP attributes instead
+ $sql = "SELECT userid, realname FROM profiles WHERE login_name = " . $App->returnQuotedString($_POST['login']);
+ $result = $App->bugzilla_sql($sql);
+ $values = mysql_fetch_array($result);
+ $name = explode(' ', $values['realname']);
+ $firstname = $name[0];
+ $lastname = $name[1];
+ $anon_friend->setFirstName($firstname);
+ $anon_friend->setLastName($lastname);
+ $anon_friend->setEmail($_POST['login']);
+ $anon_friend->setLDAPUID($ldapuid);
+ $data['firstname'] = $firstname;
+ $data['lastname'] = $lastname;
+ $anon_friend->insertUpdateFriend();
+ $check_contribution->setFriendID($anon_friend->getFriendID());
+ $check_contribution->updateContribution();
+ } else {
+ $existing_friend = new Friend();
+ $existing_friend->selectFriend($friend_id);
+ $existing_friend->setIsAnonymous($data['anonymous']);
+ $existing_friend->insertUpdateFriend();
+ $data['firstname'] = $existing_friend->getFirstName();
+ $data['lastname'] = $existing_friend->getLastName();
+ $check_contribution->setFriendID($friend_id);
+ $check_contribution->updateContribution();
+ }
+ }
+
+ // Check to see if this transaction has already been processed.
+ $check_contribution = new Contribution();
+ $check_transaction = $check_contribution->selectContributionExists($data['transaction_id']);
+ if ($check_transaction == TRUE) { // Contribution Already Exist - Check for name and message change
+ // Update contribution
+ $check_contribution->selectContributionWithTransaction($data['transaction_id']);
+ $check_contribution->setMessage($data['comment']);
+ $check_contribution->updateContribution();
+ // Get friend from friend_id from transaction
+ $check_friends = new Friend();
+ $check_friends->selectFriend($check_contribution->getFriendID());
+ if ($check_friends->getFriendID() != 0) { // User Already Exist
+ // Update Anonymity
+ $check_friends->setIsAnonymous($data['anonymous']);
+ $check_friends->insertUpdateFriend();
+ } else {
+ $ldapuid = getLDAPUIDFromEmail(getActiveEmail($Friend, $Paypal));
+ $check_friends->setFirstName($data['firstname']);
+ $check_friends->setLastName($data['lastname']);
+ $check_friends->setIsAnonymous($data['anonymous']);
+ $check_friends->setIsBenefit($data['benefit']);
+ $check_friends->setLDAPUID($ldapuid);
+ $check_friends->insertUpdateFriend();
+ }
}
}