Menu

#1 Fixing download bug

open
nobody
None
9
2006-01-02
2006-01-02
R A Y U B
No

While PGD files were downloaded Internet Explorer,
clicking on SAVE prompt resulted file not found. It
worked fine in Mozilla firefox. To fix replace dl.php
with this one or manually add

header('Cache-Control: max-age=10800, private');

after each..

header('Content-Disposition: attachment; ....)

--------x-------------
dl.php
--------x-------------
<?php
/****

I especially thank Dmitri Ivanov for reporting me
security flaw in the download php, dl.php.

****/

include("config.php");
require_once("libgmailer.php");

$attid = (isset($_REQUEST["a"]))? $_REQUEST["a"] : 0;
$mid = (isset($_REQUEST["m"]))? $_REQUEST["m"] : 0;
$fname = (isset($_REQUEST["f"]))? $_REQUEST["f"] : 0;
$zipped = isset($_REQUEST["z"])? $_REQUEST["z"] : 0;
$acn = isset($_REQUEST["n"])? $_REQUEST["n"] : 0;

if ($attid && $mid && $fname) {
$gm = new GMailer();
$gm->setLoginInfo($gmail_user[$acn],
$gmail_password[$acn], "+8");
global $session_method;

if ($gmailer->created) {
if (isset($session_method))
$gmailer->setSessionMethod($session_method);
}
if ($gm->connect()) {
header("Content-Type: application/octet-stream");
if ($zipped) {
header('Content-Disposition: attachment;
filename="'.$mid.'.zip"');
//IE bug fix
header('Cache-Control: max-age=10800,
private');
$gm->getAttachment($attid, $mid,
"php://output", true);
$gm->disconnect();
exit();
} else {
header('Content-Disposition: attachment;
filename="'.$fname.'"');
//IE bug fix
header('Cache-Control: max-age=10800,
private');
$gm->getAttachment($attid, $mid,
"php://output", false);
$gm->disconnect();
exit();
}
}
}
echo "Download error.";
?>

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.