3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php /*** * */ verifyPageAccessibility(); $viewTemplate = getProtectedFolder() . '.form_programSubmission'; define ('STATE_INPUT', 'FORM_INPUT_AREA', true); define ('STATE_CONFIRMED', 'DATA_CONFIRMED_AREA', true); define ('STATE_PROGRM_SUBMIT', 'Submit my program!', true); define ('FORM_LEVEL_ERROR', 'FORM_LEVEL_ERROR', true); define ('EMAIL_SENDER_IDENTIFIER', 'Rutgers Day Program Request Form Submission', true); $VIEW_ONLY_MODE= false; // Adding Multiple form recipients $emailRecipients = array('huacyang@gmail.com' => 'Hua Yang', 'dwsoares@ucm.rutgers.edu' => 'Danielle Weber-Soares'); //$emailRecipients = array('rudayforms@ucm.rutgers.edu' => 'Rutgers Day Program Submission Form'); //$emailRecipients = array('dwsoares@ucm.rutgers.edu' => 'Danielle Weber-Soares', 'rudayforms@ucm.rutgers.edu' => 'Rutgers Day Program Submission Form'); // Contains Form Display Building Funcitons App::loadFunction('forms.formFunctions'); App::loadFunction('forms.programSubmissionFormFunctions'); App::loadFunction('forms.fixProgramSubmissionFormData'); App::loadFunction('validation.programSubmissionFormValidationFunctions'); App::loadFunction('helpers.getSchoolListArray'); App::loadFunction('helpers.getCampusListArray'); App::loadFunction('helpers.getProgramCategoryArray'); App::loadFunction('helpers.getIndoorProgramRoomsList'); // Utility & helper classes App::loadClass('util.ErrorHandler'); App::loadClass('util.Sanitize'); App::loadClass('util.DataMsg'); App::loadClass('database.DBHandler'); // Load Aggregators App::loadClass('aggregators.ProgramAudienceAggregator'); App::loadClass('aggregators.ProgramTimeAggregator'); // Form Helpers App::loadClass('form.ProgramAudienceFormSubmission'); App::loadClass('form.ProgramTimeFormSubmission'); // Entities App::loadClass('entities.Program'); App::loadClass('entities.ProgramAudienceOption'); App::loadClass('entities.StudentOrg'); App::loadClass('entities.RudayProgramTimeOption'); App::loadClass('entities.IndoorProgramOption'); App::loadClass('entities.OutdoorProgramOption'); App::loadClass('entities.StagePerformanceOption'); // Load Persistent classes App::loadClass('persistent.ProgramPersistent'); App::loadClass('persistent.ProgramAudiencePersistent'); App::loadClass('persistent.StudentOrgPersistent'); App::loadClass('persistent.RudayProgramTimeOptionPersistent'); App::loadclass('persistent.IndoorProgramOptionPersistent'); App::loadclass('persistent.OutdoorProgramOptionPersistent'); App::loadclass('persistent.StagePerformanceOptionPersistent'); if (empty($_SESSION['FORM_EDIT_MODE']) && empty($_SESSION['FORM_VIEW_ONLY_MODE'])) { $_SESSION['FORM_EDIT_MODE'] = true; } // error handler $errorHandler = new ErrorHandler(); // instantiate program object $program = new Program(); $program->set('netid', $_SESSION['netid']); $studentOrg = new StudentOrg(); // $programAudienceFormSubmission = new ProgramAudienceFormSubmission(); $programTimeFormSubmission = new ProgramTimeFormSubmission(); $indoorProgramOption = new IndoorProgramOption(); $outdoorProgramOption = new OutdoorProgramOption(); $stagePerformanceOption = new StagePerformanceOption(); if (isset($_POST) && sizeof($_POST) > 0) { // fix data before continuing fixProgramSubmissionFormData(); foreach ($_POST as $key=> $value) { if (!is_array($value) && !is_numeric($value)) { $value = Sanitize::fix_ms_smart_quotes($value); } $program->set($key, $value); $programAudienceFormSubmission->set($key, $value); $studentOrg->set($key, $value); $programTimeFormSubmission->set($key, $value); $indoorProgramOption->set($key, $value); $outdoorProgramOption->set($key, $value); $stagePerformanceOption->set($key, $value); } // end of foreach ($_POST as $key=> $value) // validate submitted form data // Validate Program class instance validateSubmittedProgramData($program, $errorHandler); validateRudayContactPersonInformation($program, $errorHandler); // Validate Select which best describes your audience: (check all that apply) validateDescribeYourAudience($programAudienceFormSubmission, $errorHandler); // Only validate student Org information IFF `program provider` is 'Student Organization' $programProviderSelected = $program->get('prog_provider_cat'); if (strcasecmp($programProviderSelected , 'Student Organization') == 0) { validateStudentOrg($studentOrg, $errorHandler); } // Validate submitted programming times validateRutgersDayProgramTimes($programTimeFormSubmission, $errorHandler); // validate indoor programs $program_logistics_locality = $program->get('logistics_locality'); $indoorLocalityList = array ('Indoors', 'Either'); if (in_array($program_logistics_locality, $indoorLocalityList)) { validateIndoorProgramOptions($indoorProgramOption, $errorHandler); } // Validate Outdoor programs $outdoorLocalityList = array ('Outdoor', 'Either'); if (in_array($program_logistics_locality, $outdoorLocalityList)) { validateOutdoorProgramOptions($outdoorProgramOption, $errorHandler); } // Validate Stage Performance $program_desc_stage_performance = $program->get('prog_cat'); if (strcasecmp($program_desc_stage_performance, 'Stage Performance') == 0) { validateStagePerformanceOptions($stagePerformanceOption, $errorHandler); } if (!$errorHandler->isError()) { // IF NO ERRORS PROCESS FORM // Decide what to do with the submitted data $referrer = $_POST['referrer']; if (!empty($_SESSION['FORM_EDIT_MODE']) && ($_SESSION['FORM_EDIT_MODE'] === true) && (strcasecmp($referrer, STATE_INPUT) == 0) ) { $_SESSION['FORM_EDIT_MODE'] = false; unset($_SESSION['FORM_EDIT_MODE']); $_SESSION['FORM_VIEW_ONLY_MODE'] = true; //$viewTemplate = getProtectedFolder() . '.form_programSubmissionConfirm'; } else if (!empty($_SESSION['FORM_VIEW_ONLY_MODE']) && ($_SESSION['FORM_VIEW_ONLY_MODE'] === true) && (strcasecmp($referrer, STATE_CONFIRMED) == 0)) { $_SESSION['FORM_VIEW_ONLY_MODE'] = false; unset($_SESSION['FORM_VIEW_ONLY_MODE']); $clickedButton = $_POST['submit']; //echo $clickedButton; exit; if (!empty($clickedButton) && strcasecmp($clickedButton, STATE_PROGRM_SUBMIT) == 0) { // Insert submitted information into the DB // **** START INSERTING INTO DB **** // Insert Program Information $programPersistent = new ProgramPersistent($program); $dBHandler = new DBHandler(App::getDatabaseConnection()); $dBHandler->setEntity($programPersistent); $program = $dBHandler->insert(); if ($program && is_a($program, 'Program')) { // Program information submitted successfully // tracking number $trackingNumber = $program->get('program_id'); // class handles the db insert $audienceIdArray = $programAudienceFormSubmission->getAudienceIdArray(); if (is_array($audienceIdArray)) { foreach ($audienceIdArray as $audience_type_id) { if (is_numeric($audience_type_id)) { $programAudienceOption = new ProgramAudienceOption(); $programAudienceOption->set('audience_type_id', $audience_type_id); $programAudienceOption->set('program_id', $trackingNumber); $programAudiencePersistent = new ProgramAudiencePersistent($programAudienceOption); $dBHandler->setEntity($programAudiencePersistent); $dBHandler->insert(); } // end of if (is_numeric($audience_type_id)) } // end of foreach ($audienceObjectList as $programAudience) } // end of if (is_array($audienceObjectList)) // Insert student org information $studentOrg->set('program_id', $trackingNumber); $studentOrgPersistent = new StudentOrgPersistent($studentOrg); $dBHandler->setEntity($studentOrgPersistent); $dBHandler->insert(); $programTimesArray = $programTimeFormSubmission->getTimeArray(); if (is_array($programTimesArray)) { foreach ($programTimesArray as $time_id) { if (is_numeric($time_id)) { $rudayProgramTimeOption = new RudayProgramTimeOption(); $rudayProgramTimeOption->set('program_id', $trackingNumber); $rudayProgramTimeOption->set('time_id', $time_id); $rudayProgramTimeOptionPersistent = new RudayProgramTimeOptionPersistent($rudayProgramTimeOption); $dBHandler->setEntity($rudayProgramTimeOptionPersistent); $dBHandler->insert(); } // end of if (is_numeric($time_id)) } // end of foreach ($programTimesArray as $time_id) } // end of if (is_array($programTimesArray)) // Insert indoor program information $indoorProgramOption->set('program_id', $trackingNumber); $indoorProgramOptionPersistent = new IndoorProgramOptionPersistent($indoorProgramOption); $dBHandler->setEntity($indoorProgramOptionPersistent); $dBHandler->insert(); // Insert outdoor program information $outdoorProgramOption->set('program_id', $trackingNumber); $outdoorProgramOptionPersistent = new OutdoorProgramOptionPersistent($outdoorProgramOption); $dBHandler->setEntity($outdoorProgramOptionPersistent); $dBHandler->insert(); // Insert outdoor program information $stagePerformanceOption->set('program_id', $trackingNumber); $stagePerformanceOptionPersistent = new StagePerformanceOptionPersistent($stagePerformanceOption); $dBHandler->setEntity($stagePerformanceOptionPersistent); $dBHandler->insert(); // ----- Prepare the email with the submitted data ------------------- $submittedFormDataPage = getProtectedFolder() . '.programSubmissionConfirmationForm'; App::loadClass('util.RudayMailer'); include_once(App::importView($submittedFormDataPage)); // $data array is populated from the programSubmissionConfirmationForm.tpl.php page // Contains all the submitted data, this is used by the confirmation page to build the output // This will be used to build the email mesages as well. $txtOnlyMsg = ''; $htmlMsg = ''; $outputMsg = ''; if (is_array($data)) { $htmlMsg .= '<table border="1" width="100%" >'; foreach ($data as $dataMsg) { $header = $dataMsg->getSectionLabel(); if (!empty($header)) { $backgroundColor = 'background-color: #A9A9A9'; if (!$dataMsg->isHeader()) { $backgroundColor = 'background-color: #DCDCDC'; } $htmlMsg .='<tr style="'. $backgroundColor .'" >'; $htmlMsg .='<td colspan="2">'; $htmlMsg .= '<strong>'. $header . '</strong>'; $htmlMsg .= '</td>'; $htmlMsg .= '</tr>'; $outputMsg .= "\n". ''. $header . "\n"; } else { $label = $dataMsg->getLabel(); $ans = $dataMsg->getAnswersInLine(); // clean html characters $ans = Sanitize::htmlSpecialchars($ans); if (!empty($label) && empty($ans)) { $htmlMsg .='<tr style="'. $backgroundColor .'" >'; $htmlMsg .= '<td colspan="2">'; $htmlMsg .= '<strong>'; $htmlMsg .= $label; $htmlMsg .= '</strong>'; $htmlMsg .= '</td>'; $htmlMsg .= '</tr>'; } else { $htmlMsg .= '<tr>'; $htmlMsg .= '<td width="20%" >'; $htmlMsg .= '<strong>'; if (strpos($label, 'phone?') !== false) { $label = 'Microphone'; } $htmlMsg .= $label; $htmlMsg .= '</strong>'; $htmlMsg .= '</td>'; $htmlMsg .= '<td>'; if (strpos($label, 'audience') !== false) { $ans = preg_replace('/\s+/', ', ', $ans); } $htmlMsg .= $ans; $htmlMsg .= '</td>'; $htmlMsg .= '</tr>'; } $outputMsg .= ''. $label . ''; $outputMsg .= $ans; $outputMsg .= '\n\n'; } } $htmlMsg .= '</table>'; $rudayEmailer = new RudayMailer(); $rudayEmailer->isHTML(true); $rudayEmailer->setSubject(EMAIL_SENDER_IDENTIFIER); $rudayEmailer->setFrom(App::getDefaultEmailAddress(), EMAIL_SENDER_IDENTIFIER); $rudayEmailer->setBody($htmlMsg); $rudayEmailer->setAltBody($outputMsg); if (is_array($emailRecipients) && sizeof($emailRecipients) > 0) { foreach ($emailRecipients as $recipientAddress=>$recipient) { $rudayEmailer->AddAddress($recipientAddress, $recipient); } // end of foreach ($emailRecipients as $recipientAddress=>$recipient) }// end of if (is_array($emailRecipients) && sizeof($emailRecipients) > 0) $rudayEmailer->AddReplyTo('noreply@rutgersday.rutgers.edu', 'noreply'); // send email to the rutgers day administrators $rudayEmailer->Send(); $rudayEmailer->ClearAddresses(); // send another email to the client $emailThankYouMsg ="Thank you for submitting a program for Rutgers Day. Look for more information on our website about <a href=\"http://rutgersday.rutgers.edu\" target=\"_blank\">Rutgers Day</a> (http://rutgersday.rutgers.edu), along with tips for hosting a successful program.\r\n <p style=\"font-weight: bold;background-color: yellow; border-style:solid; padding: 10px;\" >Remember Your Tracking Number is: {$trackingNumber}</p> For questions or to make changes to your submission, please contact Terre Martin at 732-932-7823, ext. 672 or by email at rutgersday@rutgers.edu.\r\n Please use your tracking number on all correspondence, and when you call, so we can find your program in our database.\r\n\r\n"; $rudayEmailer->setBody( nl2br($emailThankYouMsg) . $htmlMsg); $rudayEmailer->setAltBody($emailThankYouMsg . $outputMsg); $rudayEmailer->AddAddress($program->get('prime_contact_email'),$program->get('prime_contact_first_name') . ' '. $program->get('prime_contact_last_name') ); $rudayEmailer->Send(); $rudayEmailer->ClearAddresses(); $rudayEmailer->IsHTML(false); header('Location:?q=programSubmissionThankyou&tracking_number=' . $trackingNumber ); exit(0); } // end of if (is_array($data)) { } // end of else { // if db insert error $errorHandler->addError(FORM_LEVEL_ERROR, _ERROR_DATABASE_, _ERROR_INSERT_FAILED_MSG_ . ' [PROGRAM ENTITY]'); } // end else } // end of if (!empty($clickedButton) && strcasecmp($clickedButton, STATE_PROGRM_SUBMIT) == 0) } // end of else if (strcasecmp($referrer, STATE_CONFIRMED) == 0) } // end of if (!$errorHandler->isError()) }// end of if (isset($_POST) && sizeof($_POST) > 0) else { $_SESSION['FORM_VIEW_ONLY_MODE'] = false; unset($_SESSION['FORM_VIEW_ONLY_MODE']); // Not Applicable $program->set('prime_contact_school', 'Not Applicable'); $program->set('prime_contact_campus', 'Not Applicable'); } if (!empty($_SESSION['FORM_VIEW_ONLY_MODE']) && ($_SESSION['FORM_VIEW_ONLY_MODE'] === true)) { $VIEW_ONLY_MODE = true; } else { $_SESSION['FORM_EDIT_MODE'] = true; $VIEW_ONLY_MODE = false; } include_once(App::importView($viewTemplate)); ?>
Output for 7.0.0 - 7.1.0
Fatal error: Uncaught Error: Call to undefined function verifyPageAccessibility() in /in/iTuYt:5 Stack trace: #0 {main} thrown in /in/iTuYt on line 5
Process exited with code 255.
Output for hhvm-3.12.0
Fatal error: Uncaught Error: Call to undefined function verifyPageAccessibility() in /in/iTuYt:5 Stack trace: #0 {main}
Process exited with code 255.
Output for 5.3.0 - 5.6.28, hhvm-3.10.0
Fatal error: Call to undefined function verifyPageAccessibility() in /in/iTuYt on line 5
Process exited with code 255.