Hi I've never submitted a patch before so maybe this is
not quite the way to do it-
but.. I just finished hacking some code in
/mods/document/class/Document.php which make the
function _downloadFile() work better.
The problems were: in Mozilla downloads worked on PC
and MAC but did not include the file extention. Then
the browser "sniffer" code was not working (I found
some alternate code on php.net unter the readfile()
documentation that I used instead.). So the files where
not being downloaded in IE6 - they were just opening in
a new window. Now the downloads work for IE6 but still
not for IE5.5 on a MAC. alas. Maybe someone out there
can clean it up a little more but i think these are
essential fixes.
this code starts on line 411:
function _downloadFile() {
if($_SESSION['OBJ_user']->allow_access("documents",
"download_file")
||
$_SESSION['JAS_DocumentManager']->settings['userdownload']
|| ($_SESSION["OBJ_user"]->isUser() &&
!JAS_USE_USER_RIGHTS)) {
if(is_numeric($_REQUEST['JAS_File_id'])) {
$id = $_REQUEST['JAS_File_id'];
$sql = "SELECT name, type FROM
".PHPWS_TBL_PREFIX."mod_documents_files WHERE id='$id'";
$result = $GLOBALS['core']->quickFetch($sql);
$filename =
PHPWS_HOME_DIR.JAS_DOCUMENT_DIR.$result['name'];
header("Content-Type: {$result['type']}");
header('Content-Length: '.filesize($filename));
//db added this- not sure if it's essential
header( "Content-Description: File Transfer");
// fix for a bug in IE5.5+ that causes the
content-disposition header to be read improperly
//db added strtolower
$browser = strtolower($_SERVER["HTTP_USER_AGENT"]);
//db remove this line
//if (preg_match('/msie 5.5/', $browser) ||
preg_match('/msie 6.0/', $browser))
//db added this line instead
if ((is_integer (strpos($user_agent, "msie")))
&& (is_integer (strpos($user_agent, "win"))))
{
//db added .$fext.' to both instances
$saveasname = basename($filename);
header('Content-Disposition:
filename="'.$saveasname.'.'.$fext.'"');
}
else
{
$fext = array_pop(explode('.', $filename));
$saveasname = basename($filename, '.'.$fext);
header('Content-Disposition: attachment;
filename="'.$saveasname.'.'.$fext.'"');
}
//not sure if below might be neccessary for some file types
// header("Cache-control: private");
// not sure why this is here
header('Content-Transfer-Encoding: binary');
readfile(PHPWS_HOME_DIR.JAS_DOCUMENT_DIR.$result['name']);
exit();
}
Logged In: YES
user_id=225888
This function fails in IE6 under SLL.
Logged In: YES
user_id=225888
Applied by Darren
Few fixes from Steven
Changes now in CVS