![]() |
Fellow coders I need some advice
I want to make a script that restricts the member area bandwidth usage per member per hour. My question is how do I check the used bandwidth without having to pass all content through scripts. So far the only whatso usable solution to this problem is using iptables for bandwidth info per IP. If anybody can give me any advice, it'd be greatly appreciated.
Thanks in advance, Andrew P.S. Hope you all have a Happy New Year :) |
Think ftvcash does this how much you can allow per day, stops people from downloading everything
|
Many sites have that actually
|
Build a table with the content size of each piece of media.
Use a redirect script (like traffic trading: /cgi-bin/media.cgi?url=/themedia.mpg) to print "location: /themedia.mpg\n\n" The redirect script reads the content size table based on the url and adds to a cookie and IP file the total amount of bandwidth and redirects to an error page if bandwidth exceeded. There's several other ways but this is probably the easiest. Using htaccess to hide the redirect script can help make it harder to defeat. |
Quote:
good idea, but this assumes that the person viewed the entire file... so if the mpg file is 400meg, and they got their satisfaction around 100meg point, then they got "over charged" (assuming content was streaming vs. downlaoded as a whole clip). you can have a background cron job that runs every minute that does b/w stat checks by IP (as you were thinking) to fill in a table, and your PHP script checks that table based on IP. (this method would help with streamed content) Most ppl have the same IP during their session with you... AOL users can have IP change in the middle of their time on your site... Fight the .02! |
afaik, there are some robust production grade scripts available for this... I think guy who made strongbox has script for this too (it's actualy an apache module)
|
Quote:
ah, yes, apache modules... found this: http://digg.com/linux_unix/Manage_Ap...th_ mod_cband Fight the 411! |
Quote:
|
Quote:
$n="dontstop"; while ($n eq "dontstop") { &manage_bandwidth; sleep(60); if (-e "killme.txt") {exit;} } |
Doesnt Throttlebox do this?
|
Quote:
|
there are numerous apache modules that do this.
|
Quote:
|
Quote:
|
Quote:
The "&manage_bandwidth" is a subroutine to do whatever you want. If you have dedicated server then this is easy way to do some things but maybe some host is paranoid on shared hosting and don't like it. It's just a choice other than cron; not better in anyway. |
Apache logs show both (a) the authenticated member name and (b) the size of the object it has delivered. It shouldn't be hard to write a script that continuously "tails" the logs and keeps stats on how much each member has downloaded. You could then set up something to modify/rewrite htaccess to redirect any further requests from that member to a page explaining that they've exceeded their quota.
Are you actually having a problem with excessive downloads or are you just being careful? Sometimes pissing off members may cost you more than savings in bw. :2 cents: |
NOTE: to my last post.
The "killme.txt" file can only turn it off! I has to be executed again to restart. |
cron is still better to use then because if you reboot the box it will still do what needs to be done.
as for the issue at hand, I can't think of any way you could limit this outside of an apache module. |
Quote:
|
Quote:
|
Quote:
Quote:
ITELLIGENT way. Just counting bandwidth without more intelligence than that seems to cause more problems than it solves. I wouldn't want to redirect every hit, or even count everything through iptables, the overhead seems to high to me. Instead we track bandwidth only when it actually matters, and we do it using a custom Apache module. This is something we worked on for a few years, so you may find that it makes much more sense to take advantage of all of the time that we spent on this, all of the research, the discussions we had with university professors about declining averages, etc. rather than either doing all of that work over again yourself or skipping the hard part and building something that doesn't work so well. |
Quote:
|
Give mod_leech a shot,
http://toroid.org/ams/mod_leech |
Quote:
Edit: ROFL the shady hosting company name got changed to hahahahahaha |
Quote:
Ok, good luck with it. Be forwarned to get something to actually work well and not create problems is a bigger job than it first appears. |
| All times are GMT -7. The time now is 02:25 PM. |
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2026, vBulletin Solutions, Inc.
©2000-, AI Media Network Inc123