126

Re: Attachment Mod 2.0.1 by Frank H

great mod.

When browsing for the file to upload/attach, how do i change the button text "Browse" to something else? tq

127

Re: Attachment Mod 2.0.1 by Frank H

thnx

I think it's the browser that controls that text, unfortunately ... so it will depend on the language used on the client computer ...

Re: Attachment Mod 2.0.1 by Frank H

Hello,

It will be nice for guests to be able to see that one post has attachaments even if they can't download them. If he or she doesn't have the right to download the file, then, when the user clicks the attachament, it will be nice to inform him that he can only get that file if he makes an account...

P.S.: Sorry for my poor english!

Thanks,
Stefan

129

Re: Attachment Mod 2.0.1 by Frank H

I'm afraid it might not be that easy to do, due to the way the rules etc. are set up ... And, as it's a 'special case' scenario, I'm not so keen on messing up the code for a specific usergroup ... as it will only apply to those that allows guests read, but not dowload, and that download for guests is quite logical if they are allowed to read the posts... or at least write in the description of the forum that guests isn't allowed to see the attachments ... but need to register to be allowed to do so...

Might be better to have some other notice to guests that there "might be" attachments, and that by registering you're allowed to download al files ... but ... it's all about what rules you've decided to use ... and is therefore different between all forums ...


But I'll probably make the code a bit more effective in viewtopic.php sometime during the summer if I get some free time, so I'll look if there is an easy way to do it without messing up the code ...

Re: Attachment Mod 2.0.1 by Frank H

Ok! It was only a suggestion that in my opinion, can make more guests to register... The curiosity is a great thing smile Anyway, when I'll have a little time, I'll look at the code and if I'll find a solution I will inform you.

Thanks again,
Stefan

131 (edited by Superfane 2005-06-14 15:46)

Re: Attachment Mod 2.0.1 by Frank H

Ok, a simple solution will be this one (FIRST OF ALL, MAKE A BACKUPS OF THE ORIGINAL viewtopic.php AND  lang/english/attach.php):

1. Open viewtopic.php
2. Replace:

    // Attachment Mod Block Start
    $attach_allow_download = false;
    $attach_output = '';
    $attach_num = 0;
    // Check if this post has any attachments
    $result_attach = $db->query('SELECT af.id, af.filename, af.size, af.downloads FROM '.$db->prefix.'attach_2_files AS af WHERE af.post_id='.$cur_post['id']) or error('Unable to fetch if there were any attachments to the post', __FILE__, __LINE__, $db->error());
    $attach_num = $db->num_rows($result_attach);
    if($attach_num > 0){
        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);
            }
        }
        if($attach_allow_download){//check if the user is allowed to download it.
            $attach_output .= $lang_attach['Attachments:'].' ';
            while(list($attachment_id, $attachment_filename, $attachment_size, $attachment_downloads)=$db->fetch_row($result_attach)){
                $attachment_extension=attach_get_extension($attachment_filename);
                $attach_output .= '<br />'."\n\t\t\t\t\t\t".attach_icon($attachment_extension).' <a href="./attachment.php?item='.$attachment_id.'">'.$attachment_filename.'</a>, '.$lang_attach['Size:'].' '.number_format($attachment_size).' '.$lang_attach['bytes'].', '.$lang_attach['Downloads:'].' '.number_format($attachment_downloads);
            }
        }
    }
    // Attachment Mod Block End

with:

    // Attachment Mod Block Start
    $attach_allow_download = false;
    $attach_output = '';
    $attach_num = 0;
    // Check if this post has any attachments
    $result_attach = $db->query('SELECT af.id, af.filename, af.size, af.downloads FROM '.$db->prefix.'attach_2_files AS af WHERE af.post_id='.$cur_post['id']) or error('Unable to fetch if there were any attachments to the post', __FILE__, __LINE__, $db->error());
    $attach_num = $db->num_rows($result_attach);
    if($attach_num > 0){
        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);
            }
        }
        if($attach_allow_download){//check if the user is allowed to download it.
            $attach_output .= $lang_attach['Attachments:'].' ';
            while(list($attachment_id, $attachment_filename, $attachment_size, $attachment_downloads)=$db->fetch_row($result_attach)){
                $attachment_extension=attach_get_extension($attachment_filename);
                $attach_output .= '<br />'."\n\t\t\t\t\t\t".attach_icon($attachment_extension).' <a href="./attachment.php?item='.$attachment_id.'">'.$attachment_filename.'</a>, '.$lang_attach['Size:'].' '.number_format($attachment_size).' '.$lang_attach['bytes'].', '.$lang_attach['Downloads:'].' '.number_format($attachment_downloads);
            }
        }
        //////->Added
        else {
            $attach_output .= $lang_attach['Attachments:'].' ';
            while(list($attachment_id, $attachment_filename, $attachment_size, $attachment_downloads)=$db->fetch_row($result_attach)){
                $attachment_extension=attach_get_extension($attachment_filename);
                $attach_output .= '<br />'."\n\t\t\t\t\t\t".attach_icon($attachment_extension).$attachment_filename.', '.$lang_attach['Size:'].' '.number_format($attachment_size).' '.$lang_attach['bytes'].', '.$lang_attach['Downloads:'].' '.number_format($attachment_downloads);
            }
            $attach_output .= '<br /><b>'.$lang_attach['notallowed'].'</b>';
        }
        /////
    }
    // Attachment Mod Block End

3. Replace:

<?php if ($attach_allow_download) echo "\t\t\t\t\t".'<div class="postsignature"><hr />'.$attach_output.'</div>'."\n"; ## Attachment Mod row ?>

with:

<?php /*if ($attach_allow_download)*/ echo "\t\t\t\t\t".'<div class="postsignature"><hr />'.$attach_output.'</div>'."\n"; ## Attachment Mod row ?>

4. Save and upload
5. Open  lang/english/attach.php
6. After line 10, add (don't forget to change the text between ' ' with something else) :

'notallowed'            =>    'some text to inform guests that they can download files only if they have an account',

7. Save and upload


I hope this will make more users to register on your forum.
Sorry again for my poor english!


Stefan

132

Re: Attachment Mod 2.0.1 by Frank H

ah, seems to be simpler than I thought it would be, hope you didn't have a hard time to understand the code smile

do one really need to replace that big block in 'step 2'? ... have things changed other than a few rows? (took a quick peak at it ... and it looked like you only added the else statement?), an add perhaps would be simpler othervise?

133 (edited by Superfane 2005-06-14 16:26)

Re: Attachment Mod 2.0.1 by Frank H

Indeed, the only difference is the else statement.

P.S.: The code was very easy to understand 'cose is written very clean. Thank you for that! smile

Re: Attachment Mod 2.0.1 by Frank H

Replace:

<?php /*if ($attach_allow_download)*/ echo "\t\t\t\t\t".'<div class="postsignature"><hr />'.$attach_output.'</div>'."\n"; ## Attachment Mod row ?>

with:

<?php if ($attach_num > 0) echo "\t\t\t\t\t".'<div class="postsignature"><hr />'.$attach_output.'</div>'."\n"; ## Attachment Mod row ?>

in order to fix a minor display BUG (my mistake)

135

Re: Attachment Mod 2.0.1 by Frank H

aah ... hehe, simple to do such small things wink

Re: Attachment Mod 2.0.1 by Frank H

Feature request: Upload more than 1 attachment at a time. If the maximum attachment is 3, then display 3 attachment fields. Currently, you have to save the posting and then edit the posting to add more attachments. Thank you for your consideration.

137 (edited by Frank H 2005-06-16 12:47)

Re: Attachment Mod 2.0.1 by Frank H

Not really high on my list ... more code is needed, and I don't want to mess with any java features (not working everywhere) or temporary storage (risk for big mess, and lots of code and extra functions needed, to clean up after people only uploaded files, but never posted the message) ... this is the 'simplest'/lightest way to allow more than one file ... and that's exactly why I haven't borthered with adding lots of code to the uploads
(and you have the issue of php variables that can mess up even more ... what should the limit be set to? as if you upload 4 files at once, the post data becomes the total size of all files, and if the max allowed filesize needs to be a 4th of that, why cannot you upload one file with 3 times the size of the small ones? ... to solve that one would need to upload each file to a temporary storage, one by one, and use javascript/dhtml stuff to update the post or similar ... and to me that's just way too bloated ... I know vBulletin etc. solve it that way ... but not PunBB:ish over that IMHO wink)

(also, what happens with a limit of 100 attachments, or unlimited? shoud it have a limit on 4-5 then, but then people want to have 10, and so on ... and then one need to add it to be per forum basis... and then people want to have it per usergroup basis ... and so on ...)

So, I doubt I'll include it in later versions ... I feel it's too much bloat over it ... I added this mostly so people won't need to post 20 posts for 20 files, like it was in the first mod ... now there is a possibility to attach more files, for those that needs it ... and it doesn't mess upp the code too much...

(I think it has been discussed in this thread somewhere ... but it's 6 pages, so worth repeating wink)

138 (edited by damac 2005-06-20 13:52)

Re: Attachment Mod 2.0.1 by Frank H

I have weird problem with attacment mod. I edit files and upload them. instalation went OK. Problem is when I view topic (viewtopic.php?id=x), nothing shows. Just blank page. I also get blank page when clicking in administration area on Attacment Mod.

I have also download alredy modified files, but still getting blank pages.

The PunBB is last version without any mods added (for now:)).  Any ideas what could be wrong?

139 (edited by Frank H 2005-06-20 15:23)

Re: Attachment Mod 2.0.1 by Frank H

(most likely) your modifications in viewtopic.php wasn't done correctly ...

recheck that step 43 & 44 is done ... (and if you have added the changesets Rickard told about, then this query looks a little different, but you need to alter the true to false in that row ... )

(hmm ... could be some other stuff aswell ... so mail me if it doesn't work, easier to bughunt through email)

140

Re: Attachment Mod 2.0.1 by Frank H

Norwegian language file.

<?php

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

// viewtopic.php
'Attachments:'            =>    'Vedlegg:',    // Used in viewtopic before attachments in the post.
'Size:'                    =>    'Størrelse:',        // Used in viewtopic to show filesize of attachment.
'bytes'                    =>    'Filstørrelse',        // Used in viewtopic after the filesize.
'Downloads:'            =>    'Nedlastinger:',    // Used in viewtopic to show number of downloads.

//post.php
'Attachment'            =>    'Vedlegg',    // Used in post the legend name
'Note'                    =>    'OBS: Vedlegg blir fjernet om du bruker "Forhåndsvisning", så etter "Forhåndsvisning" må du velge hvilke filer du vil laste opp.',    //Used in post to display a note under the attachment field

//edit.php
'Delete?'                =>    'Slett?',        // Used in edit.php, after the delete checkbox for each attachment...
'Existing'                =>    'Eksisterende vedlegg: (merk boksen for å fjerne)',    //Used in edit.php, before the existing attachments that you're allowed to delete
'Existing2'                =>    'Eksisterende vedlegg: (ikke tillat å fjerne)',    //Used in edit.php, before the existing attachments that you aren't allowed to delete
'Upload'                =>    'Last opp nytt vedlegg, maks: %%ATTACHMENTS%% vedlegg',    //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'                    =>    'OBS: Alle vedlegg muligheter blir fjernet om du bruker "Forhåndsvisning", så etter "Forhåndsvisning" må du velge hvilke filer du vil laste opp og hvilke du vil fjerne.',    //Used in edit to display a note under the attachment field


// attach.php
'Image view - Attachment Mod'    =>    'Viser bilde - Vedleggs modifikasjon',    // Used in attach.php, header on the Image view frame.
'Download:'                        =>    'Last ned:'                        // Used in attach.php, where one can click the filename to download.
);

141

Re: Attachment Mod 2.0.1 by Frank H

Thanks, I uploaded it to punres, I hope it's ok, othervise just contact me and I'll remove it smile

142

Re: Attachment Mod 2.0.1 by Frank H

i use your files, but when i upload a file like a image, it isnt displayed. also the plugin say: "No attachments found." Can someone helps me? This is my board: http://www.meet-teens.de/board/viewforum.php?id=24

143

Re: Attachment Mod 2.0.1 by Frank H

have you set the max allowed size described in chapter 1.6 in the documentation?

144

Re: Attachment Mod 2.0.1 by Frank H

Frank H wrote:

have you set the max allowed size described in chapter 1.6 in the documentation?

ah thanks, it was only "2000 bytes" in the settings.

145

Re: Attachment Mod 2.0.1 by Frank H

yep, it's like that to force people to set the size according to their server (as it will be different on many servers, and if I set a higher default value, then it's a possibility people not checking this, will get 'odd errors' where some files upload, but not all (i.e. those beeing bigger than the server accepts, gets lost)

so ... that's why it's only 2000 bytes smile

146 (edited by worldofglenn 2005-07-05 20:38)

Re: Attachment Mod 2.0.1 by Frank H

Help!  I've read completely through all the posts on this mod and double checked every step.  My forum now shows the attachment option and will let you upload, however it never shows up on the post.  I've altered the rules to a) allow it in the forum I'm testing in and b) changed the max size.

While I don't have complete control over my environment (it's hosted so I don't know that I could reboot), I am able to check the MySql database and the two attach tables are in there, so that seems to be good.

One behavior I've noticed is that I can't delete the attachment directories or change their permissions, seems they are locked at 750.  Also when I go to look inside them, I get path errors on my file mananger.

Take a look at this:

http://www.worldofglenn.com/images/directory1

and then when I try to go into the directory
http://www.worldofglenn.com/images/directory2

I would really appreciate any help solving this.

Thanks,

Glenn

www.worldofglenn.com/forum

147 (edited by Frank H 2005-07-05 21:06)

Re: Attachment Mod 2.0.1 by Frank H

hmm ... I suppose your useraccount is not in the same group as the webserver is running ... so you should perhaps need 777 or something (same as the img/avatars if that one works) to be able to fiddle with everything ... to do that, open up include/attach/attach_func.php and replace 750 (search for it) with 777 (or what you want instead) ... if you create a new subfolder, then that new one should have 777 instead (and all new attachments will be stored there)

Re: Attachment Mod 2.0.1 by Frank H

Frank, looks like that did it, sort of.  I changed it from750 to 777 in the attach_func.php, but when it created the directory, it only created it as a 755.  Still no write access!

So, I created my own directory, assigned it 777 and then redirected to that instead of the randomly generated one and it worked.  Not pretty, probably not the most secure, but operable.

I'm still working on understanding permissions.  The fact that I could make a directory, but not be able to delete it because of a permission I assigned to it is morbidly amusing.  Of course, the directorys with the 750 permissions won't let me change their permissions either.

But it working, and you have my appreciation for the work you put into and how you've supported here!

Thanks,

Glenn

149

Re: Attachment Mod 2.0.1 by Frank H

Good to hear you managed to sort it out ... you could probably ask your host to set the chmod and owners on the subfolders to what you figured out worked.

I guess it's a PHP ini setting that's limiting the phpscript from setting a 777 directory ... but at least with 755 it's still possible to download fiels for backup ...

I knew when I 'left database storage' that these kind of things would come ... and so far, two (If I recall correctly) people has needed to alter the attach_func.php file (and also install_mod.php and upgrade has a 750 setting in there) ... luckily not that many more wink


oh, and you should probably edit out the images, as you have the foldernames visible (makes it a tad easier to bruteforce if you show the foldernames, only need to bruteforce the filenames)

150

Re: Attachment Mod 2.0.1 by Frank H

oke have found this forum software today i like it ...
wel i have been bussy with this addon could not get it to work wel maybe its .htacces file..
i could not upload this file to the server.
ik have uploaded the files http://elco.myfreewebs.net/index.php

ik have also made a pre edit from youre new mode its can be downloaded
here http://elco.cyberfreehost.com/index.php … h&id=7

common error`s
Attachment Mod
Notice: Undefined index: attach_cur_version in /home/vhosts/elco.myfreewebs.net/plugins/AP_Attachment_Mod.php on line 1169

© Copyright 2003, 2004, 2005 Frank Hagström


and this
 
In this subfolder the Attachment Mod will save the files.

<br /><b>Notice</b>:  Undefined index:  attach_subfolder in <b>/home/vhosts/elco.myfreewebs.net/plugins/AP_Attachment_Mod.php</b> on line <b>1025</b><br />
wen i try to set a dir like "/Attachment" and push update setting nothing happend the same line is coming back.

wel good luck with this!