【php开源代码栏目提醒】:网学会员在php开源代码频道为大家收集整理了download.php提供大家参考,希望对大家有所帮助!
<?
// load session management
include("session_management.php");
// check for all parameters
if( !isset($bound)||
!isset($part) ||
!isset($ix)) die("<script language=\"javascript\">location = 'error.php?msg=".urlencode($error_other)."&sid=$sid&lid=$lid';</script>");
// choose correct session
$sessiontype = ($folder == "inbox")?"headers":"folderheaders";
$mail_info = $sess[$sessiontype][$ix];
$localname = $mail_info["localname"];
// check if the file exists, otherwise, do a error
if (!file_exists($localname)) die("<script language=\"javascript\">location = 'error.php?msg=".urlencode($error_other)."&sid=$sid&lid=$lid';</script>");
// read the email
$email = read_file($localname);
// start a new mime decode class
$md = new mime_decode();
// split the mail, body and headers
$email = $md->fetch_structure($email);
$header = $email["header"];
$body = $email["body"];
// split the parsts of email if it have more than one parts
if($bound != "") {
$parts = $md->split_parts(base64_decode($bound),$body);
// split the especified part of mail, body and headers
$email = $md->fetch_structure($parts[$part]);
$header = $email["header"];
$body = $email["body"];
}
// check if file will be downloaded
$isdown = (isset($down))?1:0;
// get the attachment
$md->download_attach($header,$body,$isdown);
unset($md);
?>