IM產生從PHP腳本的每日報告下載特定文件(CSV),它位於一個文件夾中,如下所示如何使用PHP腳本
report_2015_02_15.csv
report_2015_02_16.csv
report_2015_02_17.csv
report_2015_02_18.csv
report_2015_02_19.csv
和IM發送我的用戶鏈接的電子郵件下載時,一旦他們點擊下載鏈接,下載腳本觸發並準備下載。它目前將所有文件放到一個數組中並對其進行排序並找到最新的下載內容,
此方法在其中有一個流,即使您轉到舊的電子郵件2周並點擊下載鏈接,它會給你最新的報告,而不是給出兩週前的報告。
所以,有人可以告訴我一種方式發送我的電子郵件中的下載鏈接與其對應文件的關係嗎?
電子郵件的腳本
$down_link = Config_Reader::readProjectConfig('tad')->base_url.'CSVDownload.php;
$mail = new Zend_Mail();
$sentFromEmail = $config->sentFromrec;
$tr = new Zend_Mail_Transport_Sendmail ('-f' . $sentFromEmail);
Zend_Mail::setDefaultTransport ($tr);
$mail->setReturnPath($sentFromEmail);
$mail->setFrom ($sentFromEmail, 'Reporting');
$email_body = "Hi,<br /><br />Download the weekly details of adtracker projects, by clicking the link below.
<br /> <a href=".$down_link.">Report</a><br /><br />Thank You.";
$mail->setBodyHtml ($email_body);
$mail->addTo ($weeklyReportRec);
$mail->setSubject ("Report");
try {
$mail->send();
} catch (Exception $e) {
echo "Mail sending failed.\n";
}
下載腳本
$basePath = "$download/dailyReport/";
$csvFiles = glob($basePath."/*.csv");
if(count($csvFiles)){
array_multisort($csvFiles, SORT_DESC);
$csvFile = $csvFiles[0];
}else{
exit("Server error!");
}
$h = fopen($csvFile, "r");
$contents = fread($h, filesize($csvFile));
向包含報告日期的URL添加一個參數,並在下載腳本中使用該參數,而不是僅返回最新的參數。 – Barmar 2015-03-03 06:28:22
我用它..人們說它不安全!這可能會對我的服務器造成注入攻擊 – 2015-03-03 06:30:49
檢查參數的格式,確保它只是日期,沒有別的。 – Barmar 2015-03-03 06:39:42