So for some reason, I can upload this solely PHP script onto our server with GoDaddy, it will work fine for a day or two, then it stops working. I had figured out that if I simply re-uploaded the file it started working again. After a couple times this happened I contacted GoDaddy support. After chatting with the GoDaddy support while it wasn't working and we realized that the file was completely empty. Just a 0 byte PHP file on our server. GoDaddy support said that there's no way it was their fault and that it must be something in my script, but I have no idea what could possibly be deleting all of the code from the file. Here's the full file with some security data changed, maybe you can spot it.
<?php
//Script to send a questionnaire to a customer from a SalesForce Generated Link.
//Looks for a Client in FileMaker database based off of email address passed from SalesForce.
//If no matching client, creates one with First Name, Last Name, and Email.
//Creates a Correspondence with the Client Id of the referenced client and Date Sent of
//Questionnaire using the current day.
//Sends an email with the questionnaire link to be sent. The link includes ID's for both
//the Client and their Correspondence, as well as arrival date, tour name, supplier and region.
//Call FileMaker API and Mailer API
require_once('FileMaker.php');
require_once('class.phpmailer.php');
require_once('class.smtp.php');
//Pull values from URL to create stored link
$nm = $_GET['name'];
$eml = $_GET['email'];
$arrival = $_GET['arrival'];
$tour = $_GET['tour'];
$supplier = $_GET['supplier'];
$region = $_GET['region'];
//Pull values from URL (encoded with Base64)
$name = base64_decode($nm);
$firstName = substr($name, 0, strpos($name, ' '));
$lastName = substr($name, strpos($name, ' ') + 1, strlen($name));
$email = base64_decode($eml);
$searchEmail = str_replace('@', ' ', $email);
//Decode the Region
$decodedRegion = base64_decode($region);
//Connect to Post-Sales database
$account = new FileMaker();
$account->setProperty('database', 'PostSales');
$account->setProperty('hostspec', 'hostname.com');
$account->setProperty('username', 'ourUsername');
$account->setProperty('password', 'ourPassword');
//Search for Client record
$search = $account->newFindCommand('ClientPHP');
$search->addFindCriterion('email', $searchEmail);
$search->setRange(0, 1);
$results = $search->execute();
if (FileMaker::isError($results)) {
//Create Client if no client found
echo'No client found, creating client... <br />';
$addClient = $account->newAddCommand('ClientPHP');
$addClient->setField('name_first', $firstName);
$addClient->setField('name_last', $lastName);
$addClient->setField('email', $email);
$result = $addClient->execute();
$records = $result->getRecords();
$client = $records[0];
if(FileMaker::isError($client)) {
echo 'Client was unable to be created.<br>';
} else {
$firstName = $client->getField('name_first');
$lastName = $client->getField('name_last');
$email = $client->getField('email');
$clientID = $client->getField('__clientIDpk');
echo 'Client ' . $firstName . ' ' . $lastName .
' added with email address ' . $email . '<br>';
}
} else { //Pulls Client if found
$client = $results->getFirstRecord();
if (!FileMaker::isError($client)) {
$firstName = $client->getField('name_first');
$lastName = $client->getField('name_last');
$email = $client->getField('email');
$clientID = $client->getField('__clientIDpk');
echo 'Client ' . $firstName . ' ' . $lastName .
' found with email address ' . $email . '<br>';
} else {
echo 'No client found. Error: ' . $client->getMessage() . '<br>';
}
}
//Create Correspondence
$addCorrespondence = $account->newAddCommand('CorrespondencePHP');
$addCorrespondence->setField('_clientIDfk', $clientID);
$addCorrespondence->setField('giftcertificate_code', $gcCode);
$result = $addCorrespondence->execute();
$records = $result->getRecords();
$correspondence = $records[0];
if (!FileMaker::isError($correspondence)) {
echo 'Correspondence added<br>';
$correspondenceID = $correspondence->getField('__correspondenceIDpk');
} else if (FileMaker::isError($correspondence)) {
echo 'Correspondence unable to be added. Error: ' . $correspondence->getMessage() . '<br>';
} else {
echo 'Something went real wrong creating the correspondence. Try it again.';
}
//Create Questionnaire Link
$link = "http://www.cyclomundo-shop.com/questionnaire.php?clID=" . $clientID . "&coID=" . $correspondenceID . "&arr=" . $arrival . "&sup=" . $supplier . "&tour=" . $tour . "®i=" . $region;
if (!FileMaker::isError($correspondence) && !FileMaker::isError($client)) {
//Send email to client requesting that they fill out the Questionnaire
$sendMail = new PHPMailer;
$sendMail->isSMTP();
$sendMail->Host = localhost;
$sendMail->From = '[email protected]';
$sendMail->FromName = 'Cyclomundo';
$sendMail->addAddress($email); // Add a recipient
$sendMail->addReplyTo('[email protected]', 'Cyclomundo');
$sendMail->isHTML(true); // Set email format to HTML
$sendMail->Subject = 'Thanks for riding with us!';
$sendMail->Body = "Bonjour " . $firstName . ", <br /><br />" . //Email from Michelle
"How did you enjoy your cycling trip to " . $decodedRegion . "? Did the itinerary, meals, and accommodations live up to your expectations? <br /><br />" .
"We would really appreciate it if you would give us your honest feedback on your entire Cyclomundo experience in our questionnaire — it will take only a few moments for you to complete. <br /><br />" .
'You may complete our online questionnaire <a target="_blank" href="' . $link . '">here</a>.<br /><br />' .
"We'll take your comments, both positive and negative, and share them with everyone involved in bringing our trips to life. Your contribution makes a big difference to us at the office, everyone we work with, and all future Cyclomundo travelers — including you, we hope! <br /><br />" .
"To extend our gratitude for your contribution, you will be given a gift certificate for a 75 euro discount to be used on a Cyclomundo tour booked by December 31, 2016. This unique certificate can be used for any one of our tours of five days or more. You can keep it for yourself or give it to a friend for a fantastic gift! Please note it cannot be combined with any other discounts we offer. <br /><br />" .
"We look forward to hearing from you. <br /><br />" .
"Best regards, <br />" .
"Michelle <br />" .
"www.cyclomundo.com";
if(!$sendMail->send()) {
echo 'Message could not be sent.';
echo 'Mailer Error: ' . $sendMail->ErrorInfo;
} else {
$gcCode = strtoupper(substr($firstName, 0, 3)) . $correspondenceID;
$correspondence->setField('giftcertificate_code', $gcCode);
$correspondence->setField('questionnaire_date', date('m-d-Y'));
$correspondence->setField('questionnaire_link', $link);
$added = $correspondence->commit();
if(!FileMaker::isError($added)) {
echo 'Mail sent to ' . $email . ' and Correspondence updated with the correct Questionnaire Sent Date and Link<br>';
} else {
echo 'Mail sent to ' . $email . '. Error updating Questionnaire Sent Date of Correspondence. Error: ' . $added->getMessage() . '<br>';
}
}
} else {
echo 'Mail not sent due to error in Client or Correspondence records.<br>';
}
?>
Just for fun, here is a PHP file that will delete its own contents after two days.
I don't see anything in your file that would achieve this, even indirectly.