因此,出于某些原因,我可以使用GoDaddy将这个单独的PHP脚本上传到我们的服务器上,它将正常工作一两天,然后停止工作。我已经知道,如果我只是简单地重新上传文件,它就会重新开始工作。在这种情况发生了几次之后,我联系了GoDaddy支持。在与GoDaddy支持人员交谈后,当它不工作时,我们意识到该文件是完全空的。在我们的服务器上只有一个0字节的PHP文件。GoDaddy支持人员说,这不可能是他们的错,一定是我的脚本中有什么问题,但我不知道是什么原因可能会删除文件中的所有代码。这是更改了一些安全数据的完整文件,也许您可以找到它。
<?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 = 'info@cyclomundo.com';
$sendMail->FromName = 'Cyclomundo';
$sendMail->addAddress($email); // Add a recipient
$sendMail->addReplyTo('info@cyclomundo.com', '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>';
}
?>发布于 2015-06-25 00:23:03
为了好玩,这里有一个PHP文件,它会在两天后删除它自己的内容。
<?php
if (time() - filemtime(__FILE__) > 172800) {
$handle = fopen(__FILE__, 'r+');
ftruncate($handle, 0);
fclose($handle);
}我在你的文件中看不到任何可以实现这一点的东西,即使是间接的。
https://stackoverflow.com/questions/31031064
复制相似问题