有一篇文章将 PDF 发票存储在 ftp 上 http://whmcs.argentina--software.com.ar/index.php?title=Store_Pdf_Invoice_on_ftp有了这些信息:
1-更改此代码
INVOICESDIRECTORY
- 我保存 PDF 发票的目录
ADMINDIRECTORY
- 管理目录
2-将其粘贴到最后一行invoicepdf.tpl
文件在您的模板中。
if ($status=="Paid") {
if(strpos($_SERVER['PHP_SELF'],"ADMINDIRECTORY") === false) {
if((strpos($_SERVER['PHP_SELF'],"dl.php") !== false) || (strpos($_SERVER['PHP_SELF'],"dl.html") !== false)) {
if(!file_exists("./INVOICESDIRECTORY/".str_replace("/", "-", $invoicenum).".pdf")) {
$pdf->Output("./INVOICESDIRECTORY/".str_replace("/", "-", $invoicenum).".pdf", "F");
}
$fullPath = "./INVOICESDIRECTORY/".str_replace("/", "-", $invoicenum).".pdf";
if ($fd = fopen ($fullPath, "r")) {
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
$ext = strtolower($path_parts["extension"]);
switch ($ext) {
case "pdf":
header("Content-type: application/pdf"); // add here more headers for diff. extensions
header("Content-Disposition: attachment; filename=\"".str_replace("-", "/", $path_parts["basename"])."\""); // use 'attachment' to force a download
break;
default;
header("Content-type: application/octet-stream");
header("Content-Disposition: filename=\"".str_replace("-", "/", $path_parts["basename"])."\"");
}
header("Content-length: $fsize");
header("Cache-control: private"); //use this to open files directly
while(!feof($fd)) {
$buffer = fread($fd, 2048);
echo $buffer;
}
}
fclose ($fd);
exit;
}
}
else {
if(!file_exists("./../INVOICESDIRECTORY/".str_replace("/", "-", $invoicenum).".pdf")) {
$pdf->Output("./../INVOICESDIRECTORY/".str_replace("/", "-", $invoicenum).".pdf", "F");
}
}
}