PDA

View Full Version : Question For all!


groovesalad
10-02-2002, 04:15 PM
Anyone know of a hack that limits people to download attachments if they don't have enough posts?

I see a lot of miminum posts in order to post a thread, etc, but not to download attachments. Thanks.

Logician
10-02-2002, 04:59 PM
edit attachment.php, find:


if (!$permissions[canview] or !$permissions[cangetattachment]) {
show_nopermission();
}


After that add:


if ($bbuserinfo['posts']<X)
{show_nopermission(); exit;}


Replace X with the post number you want..

Not tested but should work..

Enjoy..

groovesalad
10-02-2002, 05:29 PM
works great. Thank you :)

groovesalad
10-24-2002, 12:47 AM
Under what error template would I put down that you need a certain amount of posts in order to download?

Logician
10-24-2002, 10:08 AM
Replace the line :

{show_nopermission(); exit;}

as

{eval("standarderror(\"".gettemplate("error_cantdlattachments")."\");");exit}

then create a new template named "error_cantdlattachments" and you can customize it according to your wish..

groovesalad
10-27-2002, 04:28 PM
Logician - What if I wanted to make it 10 threads, instead of posts? Where would I go to edit that?

Logician
10-27-2002, 10:09 PM
Originally posted by groovesalad
Logician - What if I wanted to make it 10 threads, instead of posts? Where would I go to edit that?
Unlike post number, user's thread number is not kept in a seperate variable, so to achieve your goal you first have to query db to learn this count (that means it will add 1 query to your page load)..

Replace:

if ($bbuserinfo['posts']<X)
{show_nopermission(); exit;}

AS:


$user_thread_count=$DB_site->query_first("SELECT count(*) as tc FROM thread WHERE postuserid=$bbuserinfo[userid]");
if ($user_thread_count['tc']<X)
{show_nopermission(); exit;}

groovesalad
10-27-2002, 10:16 PM
Originally posted by Logician

Unlike post number, user's thread number is not kept in a seperate variable, so to achieve your goal you first have to query db to learn this count (that means it will add 1 query to your page load)..



Is that bad? 1 query?

Logician
10-27-2002, 10:23 PM
IMO no.. check the bottom of this page and you'll see it has 27 queries. What if would it be 28? 1 query does not harm much unless your server load is already too high..

groovesalad
10-27-2002, 10:25 PM
Oh, cool. I have music to download off my site, but I get a lot of leechers that don't contribute, so I originally put it that you had to get 10 posts to download. So, several people just would put garbage in the threads. So, I figured if I made it a minimum of 5 threads to download music, it might deter people that just leech.

Logician
10-27-2002, 10:39 PM
maybe you should also consider restricting them according to seniority. Eg. only people who has registered at least 7 days ago and has 5 threads can get them etc.

Otherwise a new registerer can still post 5 garbage threads, gets the file and will not come back again..

groovesalad
10-28-2002, 03:38 AM
Yeah, that's a good idea. How might I go about doing that? Also, can I have a certain usergroup not bound to these rules? I have a private group that I don't want this to affect. Thanks for all your help :)

Logician
10-28-2002, 07:42 AM
$user_thread_count=$DB_site->query_first("SELECT count(*) as tc FROM thread WHERE postuserid=$bbuserinfo[userid]");
if ((time()-$bbuserinfo[joindate])/(60*60*24)<=X) AND $bbuserinfo[usergroup]==2 AND $user_thread_count['tc']<Y)
{show_nopermission(); exit;}


Replace X with min. day after register, Y with min. thread number..

groovesalad
10-28-2002, 09:09 AM
cool. How do I get a certain usergroup to not have to follow that above rule?

Logician
10-28-2002, 11:02 AM
the code above applies to members usergroup only..

groovesalad
10-29-2002, 08:50 PM
Members? I dont think I have a usergroup called that. I created a Friends usergroup and for some reason they are affected.

Logician
10-29-2002, 09:05 PM
check its usergroup id. Only the group with usergroup id 2 should be affected..

groovesalad
10-29-2002, 09:33 PM
Hmmm, I'll try again