function createAndSendEmail_SponsorEmail($sponsorName, $sponsorEmail, $sponsorMessage)
 {
     // create subject
     $sendSubject = "T9Hacks - Sponsor Question";
     // create message
     $sendMessage = "<html><head></head><body><table style='border-collapse: collapse'>";
     $sendMessage .= "<tr><td><b>Name: </b></td><td><p>{$sponsorName}</p></td></tr>";
     $sendMessage .= "<tr><td><b>Email: </b></td><td><p>{$sponsorEmail}</p></td></tr>";
     $sendMessage .= "<tr><td><b>Message: </b></td><td><p>{$sponsorMessage}</p></td></tr>";
     $sendMessage .= "</table></body></html>";
     // create sender's reply to
     $replyTo = "{$sponsorName} <{$sponsorEmail}>";
     // create send to
     //$sendTo = 'Brittany Ann Kos <*****@*****.**>, Jessie Albarian <*****@*****.**>';
     $sendTo = 'Brittany Ann Kos <*****@*****.**>';
     // create headers
     $sendHeaders = EmailHelperClass::createHeaders($sendSubject, $sendTo, $replyTo);
     // send email
     $emailResult = mail($sendTo, $sendSubject, $sendMessage, $sendHeaders);
     // return result
     return $emailResult;
 }
            }
            // test - empty inputs
            if ($emptyInputs != 0) {
                // bad - empty inputs
                $resultArray["EMPTY_INPUTS"] = 1;
                $resultArray["MESSAGE"] = "There was a problem with your registration.  Please check to make sure you have the required information entered in the form.";
                // success - empty inputs
            } else {
                // good - empty inputs
                $resultArray["EMPTY_INPUTS"] = 0;
                // send email
                $result = EmailHelperClass::createAndSendEmail_SponsorEmail($inputValues["name"], $inputValues["email"], $inputValues["message"]);
                $resultMessage = $result ? "Success!" : "There was a problem sending a email.  Please resubmit the form.";
                // create result array
                $resultArray = array("SUCCESS" => $result, "MESSAGE" => $resultMessage);
            }
            // end - empty test
        }
        // end - addition test
    }
    // end - honeypot test
}
// end - inputs exist
// json encode array
$jsonResult = json_encode($resultArray);
// print array to screen as results
print_r($jsonResult);
// send registration an email
//printArray($allInputValues); die();
EmailHelperClass::createAndSendEmail_Sponsor($resultArray, $inputValues);
die;
	</p>
	<p>
		T9Hacks is a 24 hour women's hackathon promoting gender diversity in technology.  It is held
		at the University of Colorado Boulder's ATLAS Institute on Feb 20-21.  T9Hacks brings students together 
		for a weekend of creativity, building, and hacking.
	</p>
	<p><b>
		Your friend has started your application, but to be considered for a spot at T9Hacks you will need to 
		complete your registration form.  If you do not complete your registration form by the end of Sunday, 
		February 7, 2016, we will remove your registration.
	</b></p>
	<p>
		Click on this link: 
		<br/>
		<a href='[[LINK]]' style='<?php 
echo $linkStyles;
?>
' target='_blank' wotsearchprocessed='true'>[[LINK]]</a> 
		<br/>
		(or copy and paste it into a web browser)  
		to go to the application page.
	</p>
	<p>
		Thank you,<br/>
		T9Hacks Team
	</p>
</td></tr>

<?php 
echo EmailHelperClass::createEmailFooter("[[NAME]]");
function registerPerson($db, $resultArray, $errorMessages, $inputs, $key, $typeCode)
{
    // create index keys for result array
    include 'resultArrayIndex.php';
    // get type
    $isParticipant = false;
    $isMentor = false;
    $isFriend = false;
    $isParticipantFriend = false;
    $isMentorFriend = false;
    $isFriend1 = false;
    $isFriend2 = false;
    $isFriend3 = false;
    if ($typeCode == 1) {
        $isParticipant = true;
    } else {
        if ($typeCode == 2) {
            $isMentor = true;
        } else {
            if ($typeCode >= 3) {
                $isFriend = true;
                if ($typeCode >= 6) {
                    $isMentorFriend = true;
                } else {
                    $isParticipantFriend = true;
                }
                if ($typeCode == 3 || $typeCode == 6) {
                    $isFriend1 = true;
                } else {
                    if ($typeCode == 4 || $typeCode == 7) {
                        $isFriend2 = true;
                    } else {
                        if ($typeCode == 5 || $typeCode == 8) {
                            $isFriend3 = true;
                        }
                    }
                }
            }
        }
    }
    // get inputs
    $inputNames = $inputs['inputNames'];
    $numReqFilledInputs = $inputs['numReqFilledInputs'];
    $numReqPresentInputs = $inputs['numReqPresentInputs'];
    // set initial keys
    if ($isParticipant) {
        $resultArray[$PARTICIPANT_KEY] = $key;
    } else {
        if ($isMentor) {
            $resultArray[$MENTOR_KEY] = $key;
        } else {
            if ($isFriend1) {
                $resultArray[$FRIEND_1_KEY] = $key;
            } else {
                if ($isFriend2) {
                    $resultArray[$FRIEND_2_KEY] = $key;
                } else {
                    if ($isFriend3) {
                        $resultArray[$FRIEND_3_KEY] = $key;
                    }
                }
            }
        }
    }
    /* ************************************ */
    /* 		Test For Remaining Inputs		*/
    /* ************************************ */
    // add to counter if does not exist
    $doesNotExist = 0;
    $doesNotExistNames = "";
    $i = 0;
    foreach ($inputNames as $name) {
        if ($i < $numReqPresentInputs && !array_key_exists($name, $_POST)) {
            $doesNotExist++;
            $doesNotExistNames .= $name;
        }
        $i++;
    }
    // test - missing inputs
    if ($doesNotExist != 0) {
        // bad - missing inputs
        if ($isParticipant || $isMentor) {
            $resultArray[$SELF_INPUTS_MISSING] = 1;
            $resultArray[$MESSAGE] = $errorMessages[$SELF_INPUTS_MISSING];
        } else {
            if ($isFriend) {
                $resultArray[$FRIEND_INPUTS_MISSING] = 1;
                $resultArray[$MESSAGE] = $errorMessages[$FRIEND_INPUTS_MISSING];
            }
        }
        $resultArray[$DETAIL_MESSAGE] = $doesNotExistNames;
        // success - missing inputs
    } else {
        // good - missing participant inputs
        if ($isParticipant || $isMentor) {
            $resultArray[$SELF_INPUTS_MISSING] = 0;
        } else {
            if ($isFriend) {
                $resultArray[$FRIEND_INPUTS_MISSING] = 0;
            }
        }
        /* ******************************** */
        /* 		Get Inputs from Names		*/
        /* ******************************** */
        // get form input values
        $inputValues = array();
        if ($isParticipant || $isFriend) {
            foreach ($inputNames as $name) {
                // agreement
                if ($name == "agree") {
                    $inputValues[$name] = 1;
                } else {
                    $inputValues[$name] = $_POST[$name];
                }
            }
        } else {
            if ($isMentor) {
                $i = 0;
                foreach ($inputNames as $name) {
                    if ($name == "agree") {
                        $inputValues[$name] = 1;
                    } else {
                        if ($i < $numReqPresentInputs) {
                            $inputValues[$name] = $_POST[$name];
                        } else {
                            $inputValues[$name] = array_key_exists($name, $_POST) ? 1 : 0;
                        }
                    }
                    $i++;
                }
            }
        }
        /*printArray($_POST);
        		printArray($inputNames);
        		printArray($inputValues);*/
        // set level of complete
        $isNew = $key == -1;
        $isComplete = !$isNew;
        /* ******************************** */
        /* 		Test For Empty Inputs		*/
        /* ******************************** */
        // count empty inputs
        $emptyInputs = 0;
        $i = 0;
        if (!empty($inputValues)) {
            foreach ($inputValues as $k => $v) {
                if ($i < $numReqFilledInputs) {
                    if ($v == null || empty($v) || $v == "" || removeWhiteSpace($v) == "") {
                        $emptyInputs++;
                    }
                }
                $i++;
            }
        }
        // test - empty inputs
        if ($emptyInputs != 0) {
            // bad - empty inputs
            if ($isParticipant || $isMentor) {
                $resultArray[$SELF_INPUTS_EMPTY] = 1;
                $resultArray[$MESSAGE] = $errorMessages[$SELF_INPUTS_EMPTY];
            } else {
                if ($isFriend) {
                    $resultArray[$FRIEND_INPUTS_EMPTY] = 1;
                    $resultArray[$MESSAGE] = $errorMessages[$FRIEND_INPUTS_EMPTY];
                }
            }
            // success - empty inputs
        } else {
            // good - empty inputs
            if ($isParticipant || $isMentor) {
                $resultArray[$SELF_INPUTS_EMPTY] = 0;
            } else {
                if ($isFriend) {
                    $resultArray[$FRIEND_INPUTS_EMPTY] = 0;
                }
            }
            /* ******************************** */
            /* 		Process Input Values		*/
            /* ******************************** */
            // process email for mentor and participant
            if ($isParticipant || $isMentor) {
                $inputValues['email'] = strtolower(removeWhiteSpace($inputValues['email']));
            } else {
                if ($isFriend) {
                    $inputValues['friendName'] = $inputValues['name'];
                    if ($isFriend1) {
                        $inputValues['name'] = $inputValues['friendName1'];
                        $inputValues['email'] = strtolower(removeWhiteSpace($inputValues['friendEmail1']));
                    } else {
                        if ($isFriend2) {
                            $inputValues['name'] = $inputValues['friendName2'];
                            $inputValues['email'] = strtolower(removeWhiteSpace($inputValues['friendEmail2']));
                        } else {
                            if ($isFriend3) {
                                $inputValues['name'] = $inputValues['friendName3'];
                                $inputValues['email'] = strtolower(removeWhiteSpace($inputValues['friendEmail3']));
                            }
                        }
                    }
                }
            }
            /* ******************************************** */
            /* 		Test For Email Already Registered		*/
            /* ******************************************** */
            $email = $inputValues['email'];
            $numEmailUsed = 0;
            // test only id new
            if ($isNew) {
                // test - participant email used
                if ($db->participantEmailRegistered($email)) {
                    $numEmailUsed++;
                    // bad - participant email used
                    $resultArray[$PARTICIPANT_EMAIL_USED] = 1;
                    $resultArray[$MESSAGE] = $errorMessages[$PARTICIPANT_EMAIL_USED];
                }
                // test - participant email used
                if ($db->mentorEmailRegistered($email)) {
                    $numEmailUsed++;
                    // bad - participant email used
                    $resultArray[$MENTOR_EMAIL_USED] = 1;
                    $resultArray[$MESSAGE] = $errorMessages[$MENTOR_EMAIL_USED];
                }
            }
            // test - any email used
            if ($numEmailUsed == 0) {
                // good - any email used
                $resultArray[$PARTICIPANT_EMAIL_USED] = 0;
                $resultArray[$MENTOR_EMAIL_USED] = 0;
                /* **************************************** */
                /* 		Participant Upload File Script		*/
                /* **************************************** */
                $fileUploadErrors = 0;
                if ($isParticipant) {
                    if (empty($_FILES["resume"]["name"])) {
                        $inputValues['resume'] = $inputValues['resumeName'];
                    } else {
                        //echo "uploading resume";
                        // get unique date
                        $date = date("YmdHis");
                        $fileNameAddition = "___" . $date;
                        // get names and extensions
                        $defaultFileName = basename($_FILES["resume"]["name"]);
                        $tmpFileName = $_FILES["resume"]["tmp_name"];
                        $fileType = pathinfo($defaultFileName, PATHINFO_EXTENSION);
                        $extensionPos = strrpos($defaultFileName, '.');
                        // find position of the last dot, so where the extension starts
                        // test - file size
                        $maxsize = 2097152;
                        if ($_FILES['resume']['size'] >= $maxsize || $_FILES["resume"]["size"] == 0) {
                            // bad - file size
                            $fileUploadErrors++;
                            $resultArray[$FILE_SIZE_TOO_LARGE] = 1;
                            $resultArray[$MESSAGE] = $errorMessages[$FILE_SIZE_TOO_LARGE];
                            // success - file size
                        } else {
                            // good - file size
                            $resultArray[$FILE_SIZE_TOO_LARGE] = 0;
                        }
                        // get updated name
                        $updatedFileName = substr($defaultFileName, 0, $extensionPos) . $fileNameAddition . substr($defaultFileName, $extensionPos);
                        $inputValues['resume'] = $updatedFileName;
                        // test - successful upload
                        $targetFile = "../hidden/resumes/" . $updatedFileName;
                        if (!move_uploaded_file($tmpFileName, $targetFile)) {
                            // bad - successful upload
                            $fileUploadErrors++;
                            $resultArray[$FILE_UPLOAD_ERROR] = 1;
                            $resultArray[$MESSAGE] = $errorMessages[$FILE_UPLOAD_ERROR];
                            // success - successful upload
                        } else {
                            // good - successful upload
                            $resultArray[$FILE_UPLOAD_ERROR] = 0;
                        }
                    }
                    // end else not empty resume -> so upload it
                }
                // end if participant
                // test - file upload
                if ($fileUploadErrors == 0) {
                    // good - file upload
                    /* **************************** */
                    /* 		Create Record Test		*/
                    /* **************************** */
                    // create key
                    if ($isNew) {
                        $keyPrefix = $isParticipant || $isParticipantFriend ? "P-" : "M-";
                        $key = $keyPrefix . substr(str_shuffle("abcdefghjkmnpqrstuvwxyzABCDEFGHJKMNPQRSTUVWXYZ23456789"), 0, 6);
                        // set new keys
                        if ($isParticipant) {
                            $resultArray[$PARTICIPANT_KEY] = $key;
                        } else {
                            if ($isMentor) {
                                $resultArray[$MENTOR_KEY] = $key;
                            } else {
                                if ($isFriend1) {
                                    $resultArray[$FRIEND_1_KEY] = $key;
                                } else {
                                    if ($isFriend2) {
                                        $resultArray[$FRIEND_2_KEY] = $key;
                                    } else {
                                        if ($isFriend3) {
                                            $resultArray[$FRIEND_3_KEY] = $key;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //printArray($inputValues); die();
                    // add record
                    $insertResult = false;
                    if ($isParticipant) {
                        $insertResult = $db->addParticipant($inputValues, $key, $isNew);
                    } else {
                        if ($isMentor) {
                            $insertResult = $db->addMentor($inputValues, $key, $isNew);
                        } else {
                            if ($isParticipantFriend) {
                                $insertResult = $db->addParticipantFriend($inputValues, $key);
                            } else {
                                if ($isMentorFriend) {
                                    $insertResult = $db->addMentorFriend($inputValues, $key);
                                }
                            }
                        }
                    }
                    // test - insert record
                    if (!$insertResult) {
                        // bad - insert record
                        if ($isParticipant || $isMentor) {
                            $resultArray[$SELF_RECORD_ERROR] = 1;
                            $resultArray[$MESSAGE] = $errorMessages[$SELF_RECORD_ERROR];
                        } else {
                            $resultArray[$FRIEND_RECORD_ERROR] = 1;
                            $resultArray[$MESSAGE] = $errorMessages[$FRIEND_RECORD_ERROR];
                        }
                        // success - insert record
                    } else {
                        // good - insert record
                        if ($isParticipant || $isMentor) {
                            $resultArray[$SELF_RECORD_ERROR] = 0;
                        } else {
                            if ($isFriend) {
                                $resultArray[$FRIEND_RECORD_ERROR] = 0;
                            }
                        }
                        /* ******************************** */
                        /* 		Send Self Email Test		*/
                        /* ******************************** */
                        $emailSuccess = false;
                        // send email
                        $emailResult = false;
                        if ($isNew) {
                            if ($isParticipant || $isMentor) {
                                $emailResult = EmailHelperClass::createAndSendEmail_Confirmation($inputValues, $key, $isParticipant);
                            } else {
                                if ($isFriend) {
                                    $emailResult = EmailHelperClass::createAndSendEmail_RegistrationNotice($inputValues, $key, $isParticipant);
                                }
                            }
                        } else {
                            $emailResult = true;
                        }
                        // test - send self email
                        if (!$emailResult) {
                            // bad - send self email
                            if ($isParticipant || $isMentor) {
                                $resultArray[$SELF_EMAIL_ERROR] = 1;
                                $resultArray[$MESSAGE] = $errorMessages[$SELF_EMAIL_ERROR];
                            } else {
                                if ($isFriend) {
                                    $resultArray[$FRIEND_EMAIL_ERROR] = 1;
                                    $resultArray[$MESSAGE] = $errorMessages[$FRIEND_EMAIL_ERROR];
                                }
                            }
                            // success - send self email
                        } else {
                            // good - send self email
                            if ($isParticipant || $isMentor) {
                                $resultArray[$SELF_EMAIL_ERROR] = 0;
                            } else {
                                if ($isFriend) {
                                    $resultArray[$FRIEND_EMAIL_ERROR] = 0;
                                }
                            }
                            $emailSuccess = true;
                        }
                        // test - email success - final test?
                        if ($emailSuccess) {
                            // good - complete registration !!!
                            if ($isParticipant) {
                                $resultArray[$PARTICIPANT_SUCCESS] = 1;
                            } else {
                                if ($isMentor) {
                                    $resultArray[$MENTOR_SUCCESS] = 1;
                                } else {
                                    if ($isFriend1) {
                                        $resultArray[$FRIEND_1_SUCCESS] = 1;
                                    } else {
                                        if ($isFriend2) {
                                            $resultArray[$FRIEND_2_SUCCESS] = 1;
                                        } else {
                                            if ($isFriend3) {
                                                $resultArray[$FRIEND_3_SUCCESS] = 1;
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        // end else for send self email
                    }
                    // end else for insert self record test
                }
                // end else file upload test
            }
            // end else for participant and mentor email already used test
        }
        // end else for empty inputs test
    }
    // end else for missing inputs test
    return array("resultArray" => $resultArray, "inputValues" => $inputValues);
}
Example #5
0
                            echo $friendSuccesCount;
                            if ($friendSuccesCount == $numFriends) {
                                $resultArray[$FRIEND_GEN_SUCCESS] = 1;
                                $end = true;
                            }
                        }
                    }
                }
                // end
                if ($end) {
                    $resultArray[$MESSAGE] = $errorMessages[$END_SUCCESS];
                    $resultArray[$SUCCESS] = true;
                }
                // close database helper
                $db->close();
            }
            // end - signup test
        }
        // end - honeypot
    }
    // end - num friends
}
//end - hidden inputs
// json encode array
$jsonResult = json_encode($resultArray);
// print array to screen as results
print_r($jsonResult);
// send registration an email
//printArray($allInputValues); die();
EmailHelperClass::createAndSendEmail_Register($resultArray, $allInputValues);
die;
Example #6
0
             break;
         case "2weeksparticipantsfar":
             $db->updateRecord($type == 1, $id, "sent_2_weeks", 1);
             EmailHelperClass::createAndSendEmail_Reminder2WeeksParticipantsFar($db->getPeopleFromId($type == 1, $id));
             break;
         case "2weeksmentors":
             $db->updateRecord($type == 1, $id, "sent_2_weeks", 1);
             EmailHelperClass::createAndSendEmail_Reminder2WeeksMentors($db->getPeopleFromId($type == 1, $id));
             break;
         case "tomorrowparticipants":
             $db->updateRecord($type == 1, $id, "sent_tomorrow", 1);
             EmailHelperClass::createAndSendEmail_ReminderTomorrowParticipants($db->getPeopleFromId($type == 1, $id));
             break;
         case "tomorrowmentors":
             $db->updateRecord($type == 1, $id, "sent_tomorrow", 1);
             EmailHelperClass::createAndSendEmail_ReminderTomorrowMentors($db->getPeopleFromId($type == 1, $id));
             break;
         case "confirmed":
             $db->updateRecord($type == 1, $id, "confirmed_attending", 1);
             break;
         case "unconfirmed":
             $db->updateRecord($type == 1, $id, "confirmed_attending", 0);
             break;
         default:
             break;
     }
     //die();
     header('Location: view.php');
     $db->close();
 }
 // run sql stmt
Example #7
0
$link = "www.t9hacks.org/signupPages/signup-participant2.php?key={$key}";
// test confirmation email
if (false) {
    echo EmailHelperClass::createEmail_Confirmation($inputValues, $key, true);
    echo EmailHelperClass::createEmail_Confirmation($inputValues, $key, false);
}
// test registration email
if (false) {
    echo EmailHelperClass::createEmail_RegistrationNotice($inputValues, $key, true);
    echo EmailHelperClass::createEmail_RegistrationNotice($inputValues, $key, false);
}
// test registration email
if (false) {
    echo EmailHelperClass::createEmail_Approval("a");
    echo EmailHelperClass::createEmail_Rejection("a");
    echo EmailHelperClass::createEmail_ReminderToCompleteRegistration("a", "key");
}
// reminder
if (true) {
    // create email message
    $message = file_get_contents("emails/2weeksparticipant.php");
    // replace variables
    $message = str_replace("[[HEADER]]", $header, $message);
    $message = str_replace("[[FOOTER]]", $footer, $message);
    $message = str_replace("[[LINKSTYLES]]", $linkStyles, $message);
    $message = str_replace("[[NAME]]", $name, $message);
    $message = str_replace("[[LINK]]", $link, $message);
    $dist = "\r\n\t\t<li style='padding: 0 0 20px;'>\r\n\t\t\t<p style='margin: 0; padding: 0;'>\r\n\t\t\t\t<b style='color: #553377;font-size: 1.2em;'>CONFIRM THAT YOU ARE COMING!</b>  We noticed\r\n\t\t\t\tthat you are traveling to T9Hacks from out of state.  We require confirmation from participants\r\n\t\t\t\tthat are traveling from a distance. Keep in mind that we we cannot cover or reimburse any \r\n\t\t\t\ttravel costs.  Please confirm with Brittany (brittany.kos@colorado.edu) if you are attending or \r\n\t\t\t\tnot.  If we do not hear from you by the end of Monday, February 8, 2016, we will remove your \r\n\t\t\t\tregistration.\r\n\t\t\t</p>\r\n\t\t</li>\r\n\t\t\t";
    $message = str_replace("[[DISTANCE_REQ]]", $dist, $message);
    echo $message;
    // create email message