Good afternoon. Sorry for my poor Eng.
I've installed two mods, Attachment 2.0 and Pun Upload Extra 1.0. Attachment or uploading files, seems to run ok. When i try to dowload the file, for exampe, using Pun Upload (it's much easier), i face two problems:
1) All files are not readeble, except .txt files. I only use .doc and .rar/zip extentions. .doc file, seems, obtains some headers, and it causes the file to loose encoding or something. When i open .doc file, the form of encoding choise appears, and there is no right encoding. Archives don't open at all. Archive opens with error, and it's shown to be empty. Txt files are Ok. I think, that forum somehow changes the header of the file. Unfortunately, i don't know PHP, and i can't solve the problem myself. Your help will be much appreciated.
Forum ver 1.2.15
Here's the part of the code in uploads.php file, which runs, when i execute file download:
// This block was taken from attachment.php (great thanks to Frank Hagstrom (frank.hagstrom+punbb@gmail.com),
// an author of Attachment mod).
// lets download a file
$file_name = $_GET['file'];
$file_name = strtr($file_name,'/',' '); // remove slashes
$file_name = strtr($file_name,'\\',' ');
if (!$upl_conf['p_view']) message($lang_common['No permission']);
if(!$upl_conf['p_globalview']) // check if user can access this file
{
$result = $db->query('SELECT uid FROM '.$db->prefix.'uploaded WHERE file=\''.$db->escape($file_name).'\' AND uid ='.$pun_user['id'].' LIMIT 1') or error('Error getting this file', __FILE__, __LINE__, $db->error());
if (!$db->fetch_assoc($result)) message($lang_common['No permission']);
}
// update number of downloads
$result = $db->query('UPDATE '.$db->prefix.'uploaded SET downs=downs+1 WHERE file=\''.$db->escape($file_name).'\' LIMIT 1') or error($lang_uploads['Err counter'], __FILE__, __LINE__, $db->error());
// get the file size
$file_size = @filesize(PUN_ROOT.'uploaded/'.$file_name);
if (!isset($file_size)) $file_size = 0;
// open a pointer to the file
$fp = @fopen(PUN_ROOT.'uploaded/'.$file_name, "rb");
if(!$fp){
message($lang_common['Bad request']);
}else{
$file_name=rawurlencode($file_name); // fix filename (spaces may still mess things up, perhaps add a specific MSIE thing later, not sure though)
//$file_name=urlencode($file_name); // fix filename (spaces may still mess things up, perhaps add a specific MSIE thing later, not sure though)
// send some headers
header('Content-Disposition: attachment; charset=utf8; filename='.$file_name);
//if(strlen($file_mime)!=0)
//header('Content-Type: text/html; charset=windows-1251'. $attach_mime );
//else
header('Content-type: application/octet-stream'); // a default mime is nothing is defined for the file
header('Pragma: no-cache'); //hmm, I suppose this might be possible to skip, to save some bw, but I'm far from sure, so I let the 'no cache stuff' be...
header('Expires: 0');
header('Connection: close'); // Thanks to Dexus for figuring out this header (on some systems there was a delay for 5-7s for downloading)
if($file_size!=0)
header('Content-Length: '.$file_size);
// and finally send the file, fpassthru might be replaced later, rumors say fpassthru use alot of memory...
fpassthru($fp);
//header('Location: '.$pun_config['o_base_url'].'/uploaded/'.$file_name);
}
die;
}
Default forum encoding is utf8.
Another roblem is, that when i try to download the file with cyrrilic name, the bowser download form shows the name as follows:
Opera: AC%FD%OF%ER%PO.doc (example)
IE (the same PC) .... similar problem
When i try to do it from another PC, it shows the name like this [1].doc
With english names everything is ok. I think, that this problem also lies in the code, i've inserted ....
If you'll need more information, i can give it ....
If you had similar problems or have any ideas, how to solve it, please, write something. I'll realy appreciate your help. Thank in advance.