vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   Modification Requests/Questions (Unpaid) (https://vborg.vbsupport.ru/forumdisplay.php?f=112)
-   -   Ability to Restrict amount of downloads from Attachments (https://vborg.vbsupport.ru/showthread.php?t=91647)

shiva 07-05-2005 05:40 AM

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?

Andreas 09-02-2005 01:12 AM

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.

PixelFx 10-06-2005 05:09 PM

......

PixelFx 10-10-2005 08:30 PM

please delete post

Chris M 10-10-2005 08:57 PM

[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

kahloz 11-26-2005 10:47 AM

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!

Chris M 11-26-2005 01:40 PM

  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

kahloz 11-26-2005 02:52 PM

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:

Chris M 11-26-2005 05:53 PM

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

PixelFx 11-27-2005 01:30 AM

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 :D so I'm really happy .. this system above is really good as well thank you :D

kahloz 11-27-2005 04:15 AM

Hey Chris,

I did your changes, the Cron Job works fine I tested it, however I'm still getting a MySql error.

Code:

Invalid SQL:
UPDATE user SET downloadcount = downloadcount + 1 WHERE userid = ' . Array['userid'] . ';

MySQL Error  : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'userid'] . '' at line 1
Error Number : 1064

Perhaps PixelFX will be kind enough to share his code? :)


All times are GMT. The time now is 05:02 AM.

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.01134 seconds
  • Memory Usage 1,749KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_code_printable
  • (3)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (11)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete