Go Back   vb.org Archive > Community Discussions > Modification Requests/Questions (Unpaid)
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 07-05-2005, 05:40 AM
shiva shiva is offline
 
Join Date: Apr 2002
Posts: 158
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Ability to Restrict amount of downloads from Attachments

I requested this before, but no one came up with a solution, so I am doing it again here.

I need the ability to restrict the amount of attachments for certain membergroups. The strain on my server because people are greedy is causing a lot of problems.

Either by a amount of attachments a member can download per day (like say just 5) or even the ability to have a page that comes up with a countdown of a time period, before the link will appear to be downloaded (Should not be a pop up page, just changes the page from the thread)

Please, I have no idea on scripting, and this has killed my server a few times, and one of these days, I may go over my bandwidth limit.

Help?
Reply With Quote
  #2  
Old 09-02-2005, 01:12 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Limiting the amount of DL/day should be fairly easy with a Plugin:
- Create a new Field in Table User for counting
- In Hook attachment_start check this field.
If we're over quota: eval(standard_error(fetch_error('dlquotareached')) );
If not: Increment the Counter
- Cronjob run at midnight to reset the counter.

Done.
Reply With Quote
  #3  
Old 10-06-2005, 05:09 PM
PixelFx PixelFx is offline
 
Join Date: Dec 2002
Posts: 1,117
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

......
Reply With Quote
  #4  
Old 10-10-2005, 08:30 PM
PixelFx PixelFx is offline
 
Join Date: Dec 2002
Posts: 1,117
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

please delete post
Reply With Quote
  #5  
Old 10-10-2005, 08:57 PM
Chris M's Avatar
Chris M Chris M is offline
 
Join Date: Dec 2001
Location: Northampton, England
Posts: 6,186
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

[sql]ALTER TABLE user ADD downloadcount INT (5) DEFAULT '0' NOT NULL[/sql]

[high]attachment_start[/high]
PHP Code:
$downloadlimit 10;
if (
$vbulletin->userinfo['downloadcount'] > $downloadlimit) {
eval(
standard_error(fetch_error('dlquotareached')));
exit;
} else {
$db->query_write("UPDATE user SET downloadcount = downloadcount + 1 WHERE userid = $vbulletin->userinfo['userid']");

Untested but should work - Then create a cron job to reset downloadcount = 0

[high]dlquotareached[/high]
Code:
You have already downloaded the maximum number of attachments for today. Please try again tomorrow!
Chris
Reply With Quote
  #6  
Old 11-26-2005, 10:47 AM
kahloz's Avatar
kahloz kahloz is offline
 
Join Date: Jun 2003
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hi, this is actually similar to what I'm looking for and I tried following your instructions but erhm... I couldn't find attachment_start and I have no clue how to do a Cron Job file

Though instead of downloaded attachments, I'd be more interested to know if we do a whole Bandwidth limit, but download attachments works fine too.

Can you walk me step by step for 3.5.1?

I'd greatly appreciate it.

Thanks!
Reply With Quote
  #7  
Old 11-26-2005, 01:40 PM
Chris M's Avatar
Chris M Chris M is offline
 
Join Date: Dec 2001
Location: Northampton, England
Posts: 6,186
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

  1. Goto your Admin CP
  2. Find the "Execute SQL Query" link on the navigation
  3. Paste the contents of the "SQL" box in my previous post into the textarea
  4. Click Continue
  5. Click Continue on the next page that appears
  6. Find the "Plugin Manager" link on the navigation
  7. Click "Add New Plugin" on the Plugin Manager Page
  8. Select [high]attachment_start[/high] as the hook location
  9. Enter "Download Count Restriction" as the title
  10. Paste the contents of the "PHP" box in my previous post into the textarea
  11. Click the "Yes" radio button next to the question of if the Plugin is active
  12. Save it
  13. Find the "Phrase Manager" link on the navigation
  14. Click "Add New Phrase" on the Phrase Manager Page
  15. Select "Error Messages" as the phrase type
  16. Enter "dlquotareached" as the varname
  17. Paste the contents of the "Code" box in my previous post into the textarea
  18. Save it
  19. Now create a cron job which resets the downloadcount field of the user table to 0 every 24 hours
It should work - I will check this thread to see if there are any problems

Chris
Reply With Quote
  #8  
Old 11-26-2005, 02:52 PM
kahloz's Avatar
kahloz kahloz is offline
 
Join Date: Jun 2003
Posts: 17
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Wow, you're da bomb!

You had me at hello!

Erhm, you had me up until cron job

I don't know how to create a Cron Job, I can find it in the Scheduled Tasks and I can enter all the necessary fields, but don't I need a PHP file? Like, Downloadlimitreset.php?

And if so, what should I put inside it? resetdownloadcount = 0 ?

*edit: ok, now I'm getting a MySQL error too

Code:
Invalid SQL:
UPDATE user SET downloadcount = downloadcount + 1 WHERE userid = Array['userid'];
Hey, is this possible to based on usergroups? like tell it that this group has a 10 daily limit while this other group has NO limit? That'd be awesome. :tired:
Reply With Quote
  #9  
Old 11-26-2005, 05:53 PM
Chris M's Avatar
Chris M Chris M is offline
 
Join Date: Dec 2001
Location: Northampton, England
Posts: 6,186
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You'll need to make a file with the following Query:
[sql]UPDATE user SET downloadcount = 0[/sql]
You should change the php code to the following:
PHP Code:
 $downloadlimit 10;
if (
$vbulletin->userinfo['downloadcount'] > $downloadlimit) {
eval(
standard_error(fetch_error('dlquotareached')));
exit;
} else {
$db->query_write("UPDATE user SET downloadcount = downloadcount + 1 WHERE userid = ' . $vbulletin->userinfo['userid'] . '");



I'll do the usergroup thing when I get more time

Chris
Reply With Quote
  #10  
Old 11-27-2005, 01:30 AM
PixelFx PixelFx is offline
 
Join Date: Dec 2002
Posts: 1,117
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by Chris M
You'll need to make a file with the following Query:
[sql]UPDATE user SET downloadcount = 0[/sql]
You should change the php code to the following:
PHP Code:
 $downloadlimit 10;
if (
$vbulletin->userinfo['downloadcount'] > $downloadlimit) {
eval(
standard_error(fetch_error('dlquotareached')));
exit;
} else {
$db->query_write("UPDATE user SET downloadcount = downloadcount + 1 WHERE userid = ' . $vbulletin->userinfo['userid'] . '");



I'll do the usergroup thing when I get more time

Chris
Darkwaltz kindly coded a custom system for me, thats quite advanced so I'm really happy .. this system above is really good as well thank you
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 12:13 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.05215 seconds
  • Memory Usage 2,271KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (3)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete