26 (edited by Frank H 2005-04-13 16:20)

Re: Attachment Mod 2.0.1 by Frank H

check so that the post and edit scritps has the correct form encoding (easy to forget adding those steps, and sounds like a classic (I've done it a few times wink))

Edit: if you check the source for the post/edit page, the form should have this enctype

<form id="post" method="post" enctype="multipart/form-data"

27 (edited by Dexus 2005-04-13 18:14)

Re: Attachment Mod 2.0.1 by Frank H

Frank, previously i've get you wrong.. i thought you was saying about RESUME UPLOADS, not a downloads smile
for downloads it's all pretty clear
here's good descritpion with examples: http://www.vbip.com/winsock/winsock_http_08_01.asp

and by the way - the reason of delay of loading is in "keepalive" i think.. because i've make this parameter on server larger, and delay become very big...
i think there must be

        header('Connection: close');

near

        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');

file - attachment.php... near the end.
after adding this line picture previews became very rapid:)

Re: Attachment Mod 2.0.1 by Frank H

Frank H wrote:

check so that the post and edit scritps has the correct form encoding (easy to forget adding those steps, and sounds like a classic (I've done it a few times wink))

Edit: if you check the source for the post/edit page, the form should have this enctype

<form id="post" method="post" enctype="multipart/form-data"

Hrmm.. no luck I checked the form id's and they were all correct, I guess I will need to go thru each file and make sure I did everything right..

Now I am using IIS, and the directory should have sufficent privleges, but I remember last time we ran into an issue w/ IIS (only admins could upload files) but people were at least able to upload things.

Re: Attachment Mod 2.0.1 by Frank H

take a peak in my modified files, to see if you can spot any differences between yours and mine ... not sure if IIS would interfer with the copying of files... or, if the generated subfolder has the index and .htaccess files, I suppose the script can move/copy files ...

30

Re: Attachment Mod 2.0.1 by Frank H

just installed this mod, and i've noticed a performance hit...
after installing this mod i see an extra query for every post in a topic
like this:

0.00168      SELECT af.id, af.filename, af.size, af.downloads FROM pun_attach_2_files AS af WHERE af.post_id=563
0.00076     SELECT af.id, af.filename, af.size, af.downloads FROM pun_attach_2_files AS af WHERE af.post_id=567
0.00074     SELECT af.id, af.filename, af.size, af.downloads FROM pun_attach_2_files AS af WHERE af.post_id=568
0.00084     SELECT af.id, af.filename, af.size, af.downloads FROM pun_attach_2_files AS af WHERE af.post_id=593
0.00076     SELECT af.id, af.filename, af.size, af.downloads FROM pun_attach_2_files AS af WHERE af.post_id=594
0.00074     SELECT af.id, af.filename, af.size, af.downloads FROM pun_attach_2_files AS af WHERE af.post_id=595
0.00081     SELECT af.id, af.filename, af.size, af.downloads FROM pun_attach_2_files AS af WHERE af.post_id=597
0.00075     SELECT af.id, af.filename, af.size, af.downloads FROM pun_attach_2_files AS af WHERE af.post_id=600
0.00079     SELECT af.id, af.filename, af.size, af.downloads FROM pun_attach_2_files AS af WHERE af.post_id=651
0.00074     SELECT af.id, af.filename, af.size, af.downloads FROM pun_attach_2_files AS af WHERE af.post_id=653
0.00075     SELECT af.id, af.filename, af.size, af.downloads FROM pun_attach_2_files AS af WHERE af.post_id=654
0.00074     SELECT af.id, af.filename, af.size, af.downloads FROM pun_attach_2_files AS af WHERE af.post_id=655
0.00074     SELECT af.id, af.filename, af.size, af.downloads FROM pun_attach_2_files AS af WHERE af.post_id=668

31 (edited by Frank H 2005-04-14 02:14)

Re: Attachment Mod 2.0.1 by Frank H

yes, feel free to incorporate it in rickards query if you think you'll be able to ... I decided not to mess too much with PunBB's code, as few replaces as possible to make the mod less dependent on the rest of PunBB's code, and thus hopefully not as much dependent on minor updates on PunBB's code.
(and it's done in the same way as the old mod, noone complained about it then as far as I remember wink)
The topic query seems to be a hard enough query either way (as changeset 172 made a update after 1.2.5 on the query that fetches all info for the posts wink) ... step 43/44 is the readme handles PunBB's query for the posts ... to be able to make querys where I make them, I had to toggle the true to false in the buffered query ... that is perhaps the reason why you notice it ... as I doubt it's the 0.01084s longer time for the 13 extra queries...

But, there's no way adding a mod won't affect performance, and this mod is quite large, as you might have noticed when installing it ... but I'm not forcing you to use it ... I've done it for myself, and shared it to you all if more people want to attach files wink

32 (edited by Dexus 2005-04-14 03:14)

Re: Attachment Mod 2.0.1 by Frank H

Extra tinyint field in `posts` table that flags a presence of attachments on a respective post will help to gain a bit of performance... I guess...

Frank, what about "Connection: close" for downloads ??? I guess that's the reason of waiting before download, when "keepalive" option is set.
Also field 'notes' in `attach_2_files` will be usable, for picture dimensions, filled with getimagesize().

Re: Attachment Mod 2.0.1 by Frank H

First going to figure out what it does (pretty tired of w3c, stuff working ok on some places fail on other...) ... from the HTTP/1.1 spec

14.10 Connection

   The Connection general-header field allows the sender to specify
   options that are desired for that particular connection and MUST NOT
   be communicated by proxies over further connections.

   The Connection header has the following grammar:

       Connection = "Connection" ":" 1#(connection-token)
       connection-token  = token

   HTTP/1.1 proxies MUST parse the Connection header field before a
   message is forwarded and, for each connection-token in this field,
   remove any header field(s) from the message with the same name as the
   connection-token. Connection options are signaled by the presence of
   a connection-token in the Connection header field, not by any
   corresponding additional header field(s), since the additional header
   field may not be sent if there are no parameters associated with that
   connection option.

   Message headers listed in the Connection header MUST NOT include
   end-to-end headers, such as Cache-Control.

   HTTP/1.1 defines the "close" connection option for the sender to
   signal that the connection will be closed after completion of the
   response. For example,

       Connection: close

   in either the request or the response header fields indicates that
   the connection SHOULD NOT be considered `persistent' (section 8.1)
   after the current request/response is complete.

   HTTP/1.1 applications that do not support persistent connections MUST
   include the "close" connection option in every message.

   A system receiving an HTTP/1.0 (or lower-version) message that
   includes a Connection header MUST, for each connection-token in this
   field, remove and ignore any header field(s) from the message with
   the same name as the connection-token. This protects against mistaken
   forwarding of such header fields by pre-HTTP/1.1 proxies. See section
   19.6.2.

Hmm, are you behind a proxy perhaps, or I saw something about IE having trouble in the PHP page aswell (but for a 'moved permanently' header) ... need to look at it..
do you feel like telling what browser(& version) you're running, and if you're behind a proxy/firewall?

05:30am  now ... gotta get some sleep tongue

34 (edited by XuMiX 2005-04-14 03:37)

Re: Attachment Mod 2.0.1 by Frank H

2 Frank:
yes, thank you for a nice mod smile but you see.. i just point out some troubles ( i'm a QA engineer wink )
BTW after installing this mod the performance hit is much more than 13*0.00076 sec ( for this particular topic )
it is about 0.1 sec for the topic with 13 replies...
Edit:
BTW why have you turned off query cache ?

35

Re: Attachment Mod 2.0.1 by Frank H

Frank, nope.. not a firewall. I have connected to localhost even
Browsers.. well, explorer 6 and firefox 1.1 .. no matter which..
oh, there is one point - apache server (2.0.53) is configured like that:

#
# KeepAlive: Whether or not to allow persistent connections (more than
# one request per connection). Set to "Off" to deactivate.
#
KeepAlive On

#
# MaxKeepAliveRequests: The maximum number of requests to allow
# during a persistent connection. Set to 0 to allow an unlimited amount.
# We recommend you leave this number high, for maximum performance.
#
MaxKeepAliveRequests 100

#
# KeepAliveTimeout: Number of seconds to wait for the next request from the
# same client on the same connection.
#
KeepAliveTimeout 15

well, it's default apache settings.

Re: Attachment Mod 2.0.1 by Frank H

I double checked that I had made the appropriate changes.. but yeah they are all correct.. I even tried your files that worked for you, just copied them over and I got the same result.. Is it something w/ the DB or is the folder that im choosing to upload to? I just put the .htaccess file in the root as well as index.html.

I noticed there are 2 folders in that directory, with random names "1918c6b37c601f6bdbcf91fc784ac134" and they each have the same files in it as well (.htaccess and index.html)

anythoughts???

37 (edited by Dexus 2005-04-14 07:40)

Re: Attachment Mod 2.0.1 by Frank H

Frank, there is HUGE algorithmic nonoptimality in topicview.php
this code with "select from rules" executes EVERY message of topic... the point of this select - to determine, are attachments available for this user/group... but it's unnecessary to execute it every message.. one for topicview will be fine!

        if($pun_user['g_id']==PUN_ADMIN)$attach_allow_download=true;
        else{         //fetch the rules of the forum, and check so that the user is allowed to download.
            $result_attach_two = $db->query('SELECT ar.rules FROM '.$db->prefix.'attach_2_rules AS ar WHERE ar.group_id=\''.$pun_user['group_id'].'\' AND ar.forum_id='.$cur_topic['forum_id'].' LIMIT 1')or error('Unable to fetch rules for the attachments', __FILE__, __LINE__, $db->error());
            if($db->num_rows($result_attach_two)==1){
                list($attach_rules)=$db->fetch_row($result_attach_two);
                $attach_allow_download = attach_rules($attach_rules,ATTACH_DOWNLOAD);
            }
        }

Re: Attachment Mod 2.0.1 by Frank H

Xumix:

Frank H wrote:

to be able to make querys where I make them, I had to toggle the true to false in the buffered query

you will only see the first post in each thread if you toggle the cache back on wink

Dexus: Ok, I'm still running Apache 1 due to various things... so I suppose that's the only difference, will probably add that header, as soon as I have figured out what the hell the standard say, tried to read it this morning and I was just too tired wink
Yep, I'm aware of that one...will probably change it to next release

Smartmonkey: hmm, considering it has managed to create folders and put in the files there, it should be able to copy the files from upload to there aswell, so file rights is probably ok ... hmm... what upload restrictions do you have in php.ini (3 different variables, check documentation to see what they are called) and what have you set the max upload to be in the settings for the attachment mod?

39

Re: Attachment Mod 2.0.1 by Frank H

After updating got this when tried to open topics
" Unable to fetch if there were any attachments to the post. "

Checked veiwtopic and attachment folder - no result

Re: Attachment Mod 2.0.1 by Frank H

I feel sheepish..

I rebooted the server and the attachment mod now works awesome..


Great job frank smile

41

Re: Attachment Mod 2.0.1 by Frank H

I install the mod.   All appear to work fine, but the files are not writed in the HD, there are not any error.

Can you help me to resolve this.

PHP can upload files in php.ini

42

Re: Attachment Mod 2.0.1 by Frank H

is there a german lang file?

43 (edited by Frank H 2005-04-16 14:04)

Re: Attachment Mod 2.0.1 by Frank H

pl0x wrote:

After updating got this when tried to open topics
" Unable to fetch if there were any attachments to the post. "

Checked veiwtopic and attachment folder - no result

Sounds like you might have got an error during mod_install.php, what tables do you have in the database (make sure the attach_2_files and attach_2_rules tables are there)


Smartmonkey wrote:

I rebooted the server and the attachment mod now works awesome..

big_smile good to hear it works now though smile

jerryg wrote:

I install the mod.   All appear to work fine, but the files are not writed in the HD, there are not any error.

Do you have a folder with a bunch of random letters and numbers in your attachment folder, if so, do that folder contain two files, an index.html and an .htaccess?
Also, make sure the php settings are correct, so it allows fileuploads. (and you probably need to restart Apache (or whatever your websoftware is) to get PHP to alter it's settings, as Smartmonkey noticed wink)

flx wrote:

is there a german lang file?

No, not yet, only English as of now. But if you translate it, I'd love to have it as my german isn't so good wink

44

Re: Attachment Mod 2.0.1 by Frank H

They are there ! ... I checked ...
Can U advise me anything ?

Re: Attachment Mod 2.0.1 by Frank H

pl0x wrote:

They are there ! ... I checked ...
Can U advise me anything ?

I'm trying...

In the documentation (chapter 2.1.1), there's info on what columns the attach_2_files database should have, do your table have all those columns?

46

Re: Attachment Mod 2.0.1 by Frank H

Yes, all of them ...
Maybe there is a problem with attach dir =/
But it is writeble and I put there 2 files.

Re: Attachment Mod 2.0.1 by Frank H

Well, even if there is a problem with the attach dir, that doesn't explain that error, that error only comes from the database query that looks into the attach_2_files table ... can you enable debug and show queries (in common.php), and tell the output for that query? (you can also mail to frank [dot} hagstrom [at} gmail [dot} com if you don't want to show stuff in open wink)

48 (edited by flx 2005-04-16 15:26)

Re: Attachment Mod 2.0.1 by Frank H

flx wrote:

is there a german lang file?

No, not yet, only English as of now. But if you translate it, I'd love to have it as my german isn't so good ;)

just started.. ;)

edit:

german attach.php:

<?php

// Language definitions for frequently used strings
$lang_attach = array(

// viewtopic.php
'Attachments:'            =>    'Attachments:',    // Used in viewtopic before attachments in the post.
'Size:'                    =>    'Größe:',        // Used in viewtopic to show filesize of attachment.
'bytes'                    =>    'bytes',        // Used in viewtopic after the filesize.
'Downloads:'            =>    'Downloads:',    // Used in viewtopic to show number of downloads.

//post.php
'Attachment'            =>    'Attachment',    // Used in post the legend name
'Note'                    =>    'Hinweis: Das Attachment Feld wird geleert, wenn die Vorschau genutzt wird. Du musst also nach der Vorschau die Datei noch einmal auswählen.',    //Used in post to display a note under the attachment field

//edit.php
'Delete?'                =>    'Löschen?',        // Used in edit.php, after the delete checkbox for each attachment...
'Existing'                =>    'Vorhandene Attachments: (auswählen, um zu löschen)',    //Used in edit.php, before the existing attachments that you're allowed to delete
'Existing2'                =>    'Vorhandene Attachments: (darf nicht gelöscht werden)',    //Used in edit.php, before the existing attachments that you aren't allowed to delete
'Upload'                =>    'Neues Attachment hochladen, maximal: %%ATTACHMENTS%% Attachments',    //Used in edit.php, before the upload field, %%ATTACHMENTS%% must be there, it will show how many attachment the user has as a maximum...
'Note2'                    =>    'Hinweis: Alle Attachment Optionen werden gelöscht, wenn die Vorschau genutzt wird. Du musst also nach der Vorschau die Datei zum hochladen und die zu löschenden Dateien noch einmal auswählen.',    //Used in edit to display a note under the attachment field


// attach.php
'Image view - Attachment Mod'    =>    'Bilder Ansicht - Attachment Mod',    // Used in attach.php, header on the Image view frame.
'Download:'                        =>    'Download:'                        // Used in attach.php, where one can click the filename to download.
);

49 (edited by Frank H 2005-04-16 15:42)

Re: Attachment Mod 2.0.1 by Frank H

thanks flx smile

about plox issue, the $cur_post['id'] has gone missing, we're trying to figure out why ... so if it's a bug I'll defenetly post about it in the first post smile
Edit: with my viewtopic.php from the 'debug-zip' it seemed to work

50

Re: Attachment Mod 2.0.1 by Frank H

Hm ... now it works fine. I just corrected manually query and it started working.
I think everything is OK with $cur_post['id']

Thx anyway smile