$success_msg[] = 'You have been successfully confirmed for ' . $songcircle_name . '!'; $success_msg[] = 'Check your inbox for more details.'; // construct log text $log_text = ' Confirmed --- User ID: ' . $user_id . ' confirmed for Songcircle ID: ' . $songcircle_id; // write to log file_put_contents(SITE_ROOT . '/logs/songcircle_' . date("m-d-Y") . '.txt', $currentUTCTime . $log_text . PHP_EOL, FILE_APPEND); } } // end of: if($message = initiateEmail()) } else { // error $err_msg = " -- ERROR: " . $_SERVER['PHP_SELF'] . " (line " . __LINE__ . ") case 'confirm_registration' - "; $err_msg .= "Could not confirm " . $user_id . " for songcircle " . $songcircle_id; // write to log file_put_contents(SITE_ROOT . '/logs/error_' . date("m-d-Y") . '.txt', $currentUTCTime . $err_msg . PHP_EOL, FILE_APPEND); notifyAdminByEmail("Error confirming user id {$user_id} for songcircle id {$songcircle_id}\r\nSee error log"); $error_msg[] = 'There was an error confirming your registration. If this problem is not addressed within 24 hours, please contact support at <a href="mailto:support@songfarm.ca">support@songfarm.ca</a>.'; $error_msg[] = 'Our sincerest apologies for the inconvenience.'; } } } else { // else for: if( $user->hasLocation($user_id) ) // craft err_msg $err_msg = " -- ERROR: " . $_SERVER['PHP_SELF'] . " (line " . __LINE__ . ") case 'confirm_registration' - "; $err_msg .= 'Unable to retrieve user location for user id ' . $user_id; // write to log file_put_contents(SITE_ROOT . '/logs/error_' . date("m-d-Y") . '.txt', $currentUTCTime . $err_msg . PHP_EOL, FILE_APPEND); $error_msg[] = 'No timezone exists for ' . $username; $error_msg[] = 'Please contact support at <a href="mailto:support@songfarm.ca">support@songfarm.ca</a> if this problem has not been addressed within 24 hours.'; $error_msg[] = 'Our sincere apologies for the inconvenience.'; }
// 5th arg. possible bug if ($result) { echo "Thank you, {$name}, for getting in touch!"; $user_data = ["name" => $name]; if (!($message = initiateEmail($email_data['contact_us'], $user_data))) { // NOTE: log error $err_msg = " -- ERROR: " . $_SERVER['PHP_SELF'] . " (line " . __LINE__ . ") -- initiateEmail failed"; file_put_contents(SITE_ROOT . '/logs/error_' . date("m-d-Y") . '.txt', date("G:i:s") . $err_msg . PHP_EOL, FILE_APPEND); notifyAdminByEmail("Contact Form autoresponder failed to send -- {$_SERVER['PHP_SELF']}"); } else { $to = "{$name} <{$email}>"; $from = "Songfarm <*****@*****.**>"; $subject = "Message Received!"; $headers = "From: {$from}\r\n"; $headers .= "Content-Type: text/html; charset=utf-8"; if (!($result = mail($to, $subject, $message, $headers, '-fsongfarm'))) { // NOTE: write to error log $err_msg = " -- ERROR: " . $_SERVER['PHP_SELF'] . " (line " . __LINE__ . ") -- PHP mail method failed. Unable to send autoresponse"; file_put_contents(SITE_ROOT . '/logs/error_' . date("m-d-Y") . '.txt', date("G:i:s") . $err_msg . PHP_EOL, FILE_APPEND); notifyAdminByEmail($err_msg); } } } else { echo "We were unable to send your message at this time. Our team has been notified of this error. Please try again later."; // NOTE: log error here: failed to send contact form comment via mail method PHP notifyAdminByEmail("Failed to send contact form comment via mail method -- {$_SERVER['PHP_SELF']}"); } } } else { $name = $email = $subject = $message = ""; }