PDA

View Full Version : Minimum posts to download attachments..


EvilLS1
05-06-2003, 10:00 PM
This little hack will make it possible for you to require your users to have a minimum number of posts (which you define in the admin control panel) before they can download attachments.

Requested by TranceMaster and a couple of others in this thread:
https://vborg.vbsupport.ru/showthread.php?s=&threadid=48636

Updated: No more red Xs if the "view images" option is set to "yes". Now if "view images" is set to yes, everyone will be able to see the images in the threads, but not download other file types unless they have enough posts.. But if "view images" is set to no, users who do not have the minimum # of posts will still get the "not enough post" error message (even with images)...

Credits: Thanks to Sophocle for his help with this update.

If you downloaded the first version clear your browser cache and download the zip file again.

Screenshots included in the zip.

If you find this hack useful please click install. :)

Boofo
05-07-2003, 06:48 AM
Thanks! I'll give this a go. ;)

squawell
05-07-2003, 09:47 AM
one question can make this when u post a attach file set user

how many posts can download???can do that?thankz...

Koutaru
05-07-2003, 10:00 AM
Nice :) I'm still considering whether to use it or not but I just think I might

TranceMaster
05-07-2003, 10:59 AM
excellent man, thank you very much
ill go test it out just now
:)

edit: i was just thinking, would it be possible to only have this hack affect a certain forum.

i run a music production site, with various sub forums.
but the one forum that contains the most attachments is the samples forum.

right now people need 50 posts before they can even view it, would be good to let them view it but not download until they have enough posts.

and having it not effect any other forum would be great.
dunno if thats possible though
let me know
thanks again

TM

shungo
05-07-2003, 12:36 PM
thx alot :D !!!

I've searched it ... but without no results... thx again for your job :)

I'm going to translate it for my forum... in franch now.. would you like i post it here ? :)

Shimmy
05-07-2003, 03:25 PM
Thanks alot for responding to us...i'll give a try

Edit: it works perfectly on my site...and with vb 2.3.0

Thanks

EvilLS1
05-08-2003, 03:20 AM
squawell,
I don't understand what you're asking.


TranceMaster,
Sure, if you only want this to effect a single forum just remove the code that you added earlier to attachment.php..

Then find (in attachment.php):


$getforuminfo=$DB_site->query_first("SELECT forumid".
iif($postid,',attachmentid ','')."
FROM thread,post
WHERE post.threadid=thread.threadid ".
iif($postid,"AND post.postid='$postid'","AND post.attachmentid='$attachmentid'")."
");


Below it add:

// minimum post to view attachments
if ($bbuserinfo[posts] < $minpostattach and $getforuminfo['forumid']==X) {
eval("standarderror(\"".gettemplate("error_attachmoreposts")."\");");
exit;
}


Now in the code above, replace the red X with the forum ID of the one that you want this to effect.
I haven't tested this but it should work.

When I get some free time I might re-do this so that the minimum # of posts can be set on a forum by forum basis in the CP. So if ya want to be notified about updates just click install.


shungo,
Sure, go ahead and post the French version if you want.

squawell
05-08-2003, 09:02 AM
i mean when u start a new topic u can set the post number if

member over that number than he can download if not he cant..

can do this??

Sophocle
05-09-2003, 12:01 PM
To avoid the problem of the View Images option, I would suggest those modifications in the hack :

In spite of doing :
##### In attachment.php find:
require("./global.php");

##### Below add:
// minimum posts to download attachments hack
if ($minpostattach > $bbuserinfo[posts]) {
eval("standarderror(\"".gettemplate("error_attachmoreposts")."\");");
exit;
}
// end minimum posts to download attachments hack

Just do :
##### In attachment.php find:
updateuserforum($getforuminfo['forumid']);

##### Just before, add:

// minimum posts to download attachments hack
$extension=strtolower(substr(strrchr($attachmentin fo[filename],"."),1));
if (($minpostattach > $bbuserinfo[posts]) && $minpostattach!=0 && $extension!='gif' && $extension!='jpeg' && $extension!='png') {
eval("standarderror(\"".gettemplate("error_attachmoreposts")."\");");
exit;
}
// end minimum posts to download attachments hack

And if you are perfectionist, you can also suppress the line :
$extension=strtolower(substr(strrchr($attachmentin fo
which appears just after the headers of the attachment.

Boofo
05-09-2003, 12:40 PM
What does this mean?

"To avoid the problem of the View Images option"

I mean I'm not sure I understand what that would do if you didn't do it this way.

Sophocle
05-09-2003, 12:57 PM
Important! If you use this hack the "View Images" option in the admin control panel should be set to "no" or else guests & people who don't have enough posts will only see a red X.I thought it was a too big limitation, so my suggestion permit to show images attachments even if the user hasn't send the minimum number of messages.

Boofo
05-09-2003, 01:01 PM
So they will be allowed to see image attachments with your code?

Sophocle
05-09-2003, 02:15 PM
Yes :)

Boofo
05-09-2003, 02:22 PM
Then why bother to even install the hack? ;)

Sophocle
05-09-2003, 02:34 PM
To limit downloading attachments other than images of course ;)

Boofo
05-09-2003, 02:38 PM
So, if it is a link, they can't view it. But if the image is showing, they can view it instead of seeing a red x. Is that it? ;)

shungo
05-09-2003, 02:57 PM
Hi :)

This is the French version of this hack, thx alot EvilLS1 :)

It works with VBB 2.x.x

Kikooo :)

Voici la version Fran?aise, compatible avec les versions 2.x.x de VBB. Je l'utilise pour ma part sur la 2.3.0.

EvilLS1
05-10-2003, 07:16 AM
Sophocle,
That is an excellent idea! The only problem that I saw with it is that perhaps some people prefer that users with less than the minimum # of posts not be able to download images.. And even with the "view images" option set to "no", they would still be able to download images that way.

But there's an easy solution..


if ($viewattachedimages==1) {
$extension=strtolower(substr(strrchr($attachmentin fo[filename],"."),1));
if (($minpostattach > $bbuserinfo[posts]) && $minpostattach!=0 && $extension!='gif' && $extension!='jpeg' && $extension!='jpg' && $extension!='png') {
eval("standarderror(\"".gettemplate("error_attachmoreposts")."\");");
exit;
}
} else if ($minpostattach > $bbuserinfo[posts] and $minpostattach!=0) {
eval("standarderror(\"".gettemplate("error_attachmoreposts")."\");");
exit;
}


With this code, if "view images" is set to no, users who do not have the minimum # of posts will still get the "not enough post" error message when attempting to download images.. But if "view images" is set to yes, everyone will be able to see the images in the threads, but not download other file types unless they have enough posts.

I've tested this and it works. :) I'll update the zip file in the first post.



{edit} I just noticed something.. As an added bonus, this hack will also stop people from hot linking images on other sites if you set view images to no and minimum posts > 0. :p

EvilLS1
05-10-2003, 07:56 AM
squawell,
I'm sure that could be done, but its not something that I would want for my forum and at the moment I don't have time to try it...sorry.

Boofo
05-10-2003, 10:00 AM
EvilLS1, The red x is still showing for me on attachments that are set to view. I have Slynderdale's "Show Image attachments" hack installed and it doesn't show the image with that, just the red x. I have "View image attachments" turned of in the Admin CP but with Slynderdale's hack, you can set it to view an attachment or a link. How would I get this to work with that?

Boofo
05-10-2003, 11:07 AM
Ok, I figured out how to do it by putting it in the postbit_attachmentimage template (using Logician's Dynamic Templates hack). In place of the actual image showing, they will see the contents of the error_attachmoreposts template. How can I pull the $minpostattach amount form the postbit_attachmentimage template? Right now, unless I hard code it, it shows nothing for the number.

EvilLS1
05-10-2003, 11:10 AM
Boofo,
Did you reinstall the updated version of the hack in the zip? I added Sophocle's fix aswell as another improvement which is described a couple of posts above this one. Try re-downloading the zip file in the first post & reinstalling the newer version. Let me know if that fixes it (it should).

Boofo
05-10-2003, 11:21 AM
I already installed that before I wrote the last message. The hack for show image attachments is what is messing it up. I like it the way I have it now where is shows the message in place of the image in the post. I just want to be able to have it show the $minpostattach amount in the postbit_attachmentimage without having to hard code it in. If they're not allowed to download attachments, they shouldn't be able to view them either. ;)

EvilLS1
05-10-2003, 11:29 AM
If you installed the code from Sophocle's post you will still get red Xs for images with the .jpg extension because he forgot to include $extension!='jpg' in his code. I added it in the zip though.

I'm not sure why the $minpostattach isn't working in that template for ya. I gotta hit the sack right now but I'll check it out when I get up.

Boofo
05-10-2003, 11:35 AM
The code I installed is from your hack. I help off until you changed yours. ;)

You might want to take a look at The Show images hack. It works with the viewimages set to off.

Somehow, I need to add something somewhere that will pull out that number, but I don't know where. ;)

EvilLS1
05-10-2003, 11:43 AM
Today at 01:35 PM Boofo said this in Post #26 (https://vborg.vbsupport.ru/showthread.php?postid=393300#post393300)
The code I installed is from your hack. I help off until you changed yours. ;)

You might want to take a look at The Show images hack. It works with the viewimages set to off.






{EDIT} OK, n/m. I know what your saying now.. I'll check out the show images hack. :)

Boofo
05-10-2003, 11:52 AM
The "Show Images hack" allows you to show an image in the post when the viewimages is turned off in the Admin CP. That way, you can show an image instead of a link on a post by post basis.

Right now, I have it set up to show the error template in place of the image inside the post. I think if they are not allowed to download attachments, they shouldn't be able to view them either. I accomplished this by doing a conditional in the postbit_attachmentimage template itself. What I can't get to show in the template is the number that is set for the $minpostattach variable. I have to hard code whatever number that is inside the template. I think I need to define that variable inside the attachment.php.

EvilLS1
05-10-2003, 11:58 AM
Boofo,
I just realized that you were talking about a completely different hack. At first when you said "show images hack" I thought you were referring to the post by Sophocle in the first page of this thread. I'm an idiot! lol

Boofo
05-10-2003, 12:06 PM
No, you're not an idiot. I was not explaining myself very well, I guess. ;)

All I really need now is to get the $minpostattach variable ammount to show up in the postbit_attachmentimage template.

Sophocle
05-10-2003, 03:06 PM
Boofo, I think you could code it very simply with the Advandced Templates Hack of Logician.

EvilS1, thank you very much for having updated the hack. You've perfectly completed my proposition ;)

I've translated your hack for french people (http://www.vbulletin-fr.com) and will change the hack in order to integrate new modifications. I respected all copyright restrictions. I'll send the complete adress to the hack when the translation is completed.

Boofo
05-10-2003, 03:10 PM
I did use the Advanced Templates Hack by Logician. Everything is working fine except the $minpostattach variable doesn't show up in the postbit_attachmentimage template. ;)

EvilLS1
05-10-2003, 11:39 PM
Boofo,
To make the $minpostattach variable work in the postbit_attachmentimage template:

In admin/functions.php find:


// global options
global $showdeficon,$displayemails,$enablepms,$allowsigna tures,$wordwrap,$dateformat,$timeformat,$logip,$re placewords,$postsperday,$avatarenabled,$registered dateformat,$viewattachedimages;


Replace it with:

// global options
global $showdeficon,$displayemails,$enablepms,$allowsigna tures,$wordwrap,$dateformat,$timeformat,$logip,$re placewords,$postsperday,$avatarenabled,$registered dateformat,$viewattachedimages,$minpostattach;


That should do it.


Sophocle,
Thanks again for you addition to the hack. Works great. ;)

Boofo
05-11-2003, 12:08 AM
Bingo! That was what I needed. I guess I should have known that, huh? Dohh!!! ;)

Thank you very much, sir. ;)

EvilLS1
05-11-2003, 01:28 AM
y/w. Glad I could help. :)

Sophocle
05-11-2003, 08:52 AM
Here is the thread for the updated french translation of the hack made for www.vbulletin-fr.com :
http://www.vbulletin-fr.com/forum/showthread.php?threadid=2551

You can also find the translation in the attached file.

ukbill69
12-07-2003, 06:59 PM
Will this work for vb3 gamma? I need this bad. Miss it from when i had vb2 :(

EvilLS1
12-07-2003, 07:46 PM
ukbill69,
No, vb2 hacks will not work with vb3. Alot of vb2 hacks will be ported over when the final version of VB3 is released though.

ukbill69
12-08-2003, 06:03 PM
Thanks for your reply.

Deska
07-27-2004, 12:28 PM
Anyone could convert this hack for vb3?
Thank's a lot....

EvilLS1
07-28-2004, 01:26 AM
Anyone could convert this hack for vb3?
Thank's a lot....

This hack is obsolete. It can be done with template conditionals or promotions in VB3. :)

Deska
07-28-2004, 10:39 AM
This hack is obsolete. It can be done with template conditionals or promotions in VB3. :)

Can you give me example if using template conditionals?
I really need it.

Thank's....

Andreas
07-28-2004, 10:43 AM
This hack is obsolete. It can be done with template conditionals [..] in VB3. :)
No, it can't.
Template conditionals will just hide the link, but won't keep users from downloading attachments.
But as already said here and in another thread, this hack isn't necessary for vB 3 as restricting downloads on a miminum amout of posts can be achieved by using promotions and usergroup permissions.

EvilLS1
07-28-2004, 06:52 PM
No, it can't.
Template conditionals will just hide the link, but won't keep users from downloading attachments.


True, but how many users would actually think about typing in the URL manually? My guess is none.

vB's promotions system really is the best way to do it though.

Deska,
Edit the standard usergroup so that users in that group can't view attachments. Then create a new usergroup that can DL attachments. Set up the promotions so that once a user has XXX amount of posts he gets promoted to that usergroup.

Andreas
07-28-2004, 06:54 PM
True, but how many users would actually think about typing in the URL manually? My guess is none.
Well ... I would, if the attachment was interesting enough ^.^

Deska
07-29-2004, 10:16 AM
Thank's for reply guys.
I got it now....