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.

2

(2 replies, posted in PunBB 1.2 troubleshooting)

Thanx a lot, m8 smile

Really stupid sintax mistake

Good afternoon.
Sorry for my English.

I have some troubles while trying to sticky/close/move topic. Tried all account permissions, incl admin account.
When i click any of these functions, i have the following error:

Parse error: syntax error, unexpected T_IF in /*****/business/public_html/moderate.php on line 33

My moderate.php code looks like this:

define('PUN_ROOT', './');
require PUN_ROOT.'include/common.php';
require PUN_ROOT.'include/attach/attach_incl.php'


// This particular function doesn't require forum-based moderator access. It can be used
// by all moderators and admins.
if (isset($_GET['get_host'])) //////////////////////////// THIS IS THE ERROR LINE !!!
{
    if ($pun_user['g_id'] > PUN_MOD)
        message($lang_common['No permission']);

    // Is get_host an IP address or a post ID?
    if (@preg_match('/[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}/', $_GET['get_host']))
        $ip = $_GET['get_host'];
    else
    {
        $get_host = intval($_GET['get_host']);
        if ($get_host < 1)
            message($lang_common['Bad request']);

        $result = $db->query('SELECT poster_ip FROM '.$db->prefix.'posts WHERE id='.$get_host) or error('Unable to fetch post IP address', __FILE__, __LINE__, $db->error());
        if (!$db->num_rows($result))
            message($lang_common['Bad request']);

        $ip = $db->result($result);
    }

    message('The IP address is: '.$ip.'<br />The host name is: '.@gethostbyaddr($ip).'<br /><br /><a href="admin_users.php?show_users='.$ip.'">Show more users for this IP</a>');
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

This is the begining of the code. If you need the whole one, i can put it here ....

I've installed the following mods, which affected this file: attachment_mod, calendar_mod
Unfortunately, i dont know PHP, so i can't solve the problem myself sad

Thanx in advance for your help.