在服务器上PHP文件变为完全空

时间:2015-06-24 15:43:14

标签: php filemaker

因此,出于某种原因,我可以使用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 . "&regi=" . $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>';
}

?>

1 个答案:

答案 0 :(得分:1)

只是为了好玩,这是一个PHP文件,它将在两天后删除自己的内容。

<?php
if (time() - filemtime(__FILE__) > 172800) {
    $handle = fopen(__FILE__, 'r+');
    ftruncate($handle, 0);
    fclose($handle);
}

我在文件中看不到任何可以实现此目的的内容,甚至是间接的内容。