Results 1 to 10 of 10
  1. #1
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Working with quotas

    Hi All!

    I have a website that I host a file for a bunch of people to download (yes, it is a legal file ;-). The problem is that my host doesn't allow a lot of bandwidth, but other people in the group are willing to host for a bit each month, to share the cost.

    So what I'd like to do is have a script (in cgi, php, or javascript or something similarly universal) that checks to see how much of my bandwidth I've used for the month (or even as simple as the file's been clicked on X number of times, I don't need to get too technical), and when it gets near the end (x number of clicks, or % of my allowed bandwidth), goes to a list of alternate sites and uses that file for a few clicks, and then on for a few clicks at the next site.

    Is this possible? Where do I start?

    This is all nonprofit, so I don't have the funds to buy a big fancy program to do mirroring and passwording and all. I only have one file, and I'll always only have one file, and I don't need any of this to be exact. And it needs to be simple, so older folk can get in there too ;-)

    Thanks in advance for any ideas!

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Working with quotas

    Maybe you could... have a page with a list of sites to download from. You could use a little script to "shuffle" the order of the sites randomly every time the page loads. I don't actually know how to write such a script -- <img src=/S/sad.gif border=0 alt=sad width=15 height=15> -- but maybe there's one on the web ready to go? Or you could give different links for different days of the week: tell people, if it's Tuesday, use this site. <img src=/S/grin.gif border=0 alt=grin width=15 height=15>

    The reason I suggest these approaches is that I really don't know how you can tap into your web host's tally of bandwidth used.

  3. #3
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Working with quotas

    Hi!

    Well, that is part of the problem. The few scripts that I have seen that do this sort of thing are big & complex. I was thinking that if I could count clicks on the file, which I have seen many people do, then I could estimate how much bandwidth is being used based on the size of the file. If I could write a script that shuffled the links, then it would probably do what I need it to, because I could just display one of those links based on how many times it's been clicked that month?

    Does that make sense? I was kinda hoping to find someplace that I could find the pieces and maybe put them together, but I'm not exactly sure how to go about it.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Working with quotas

    The only server-side scripting language I have used very much is ASP, which usually runs only on Microsoft's IIS web server (apparently there is a way to get it to run on some other servers, but web hosts typically don't offer that). Using ASP or PHP or another server-side scripting language, you could update a text file or database on the server each time the file was downloaded. The problem with client-side languages, such as Javascript, is that there's no easy way for them to update a file on the server.

  5. #5
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Working with quotas

    It sounds like the quota is with your web host rather than your ISP. Is this correct?

    If so, you could carefully expose a computer from your location to the internet via FTP or web server with the desired file shared publically. Then set up a dynamic DNS service (for free - see http://www.dyndns.org). Finally, point the url from your website to that file hosted on the designated PC. You will essentially gain unlimited bandwidth from the site hosted on your own computer.

    Granted, if the bandwidth restriction is with your ISP then this will not help at all...

  6. #6
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Working with quotas

    Hi Mark--

    Wow, that sounds interesting! Thanks for the link. I will definitely check it out, although for this project, I don't think I want to keep my computer on 24/7.

    Jscher, PHP is kinda what I had in mind. I was hoping someone might know of something that was already written like this (or at least the two separate parts of it), because I don't know either ASP or PHP. Apparently I'll be taking up a new language ;-)

    At the very least, talking about this has helped me map out what I want to do (heh, I think I could even write it in VB). Count # of times file has been clicked (write each click to a text file). When # of clicks exceeds the max number of clicks (which could even be read in from a text file, in case each link has a different requirement), then change to the next hyperlink. On a predetermined date (the end of the month) start the counting all over again.

    Revised: a mySQL table with the following fields: ID, LinkPath, Count, MaxCount. When the link is clicked, it checks count for the first ID and compares it to MaxCount, if count is less than MaxCount, then use the LinkPath for that ID. If not, go to the next field and try the test again. When it finally finds an ID it can use, it increases Count by one and serves the link. Now I just need to learn PHP. <img src=/S/bananas.gif border=0 alt=bananas width=33 height=35>

    Thanks for your suggestions!

  7. #7
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Working with quotas

    Hoping that this doesn't make you nervous - as it shouldn't. Bit Torrent would more than adequately fill your needs & save you a very large amount of the design/administrative hassle. The guide is in the link. As all links are through IP addresses, there is no anonymity. It will also work through end-user defined Ports - lowering the risk of "botnet" intrusions. Make each of the "other people in the group" Seeders (see the terminology) and, subject only to connection quality, the bandwidth usage should be automatically shared equally between you. You may also want to look at the FAQ. (The more General stuff as "Yes, it really is free. If you were charged for it.. you may be the victim of fraud" and "No, BitTorrent contains no spyware, adware, viruses, or any other kind of malicious software...To avoid this problem, don't download from websites you don't trust." is towards the bottom. HTH
    Gre

  8. #8
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Working with quotas

    I had pretty much crossed BitTorrent off my list of possibilities...Isn't stuff like this illegal?

    The other side is that what I'm doing isn't big enough to warrant a huge file-sharing scheme. I don't want people to need to install software to hear the broadcast, because that would limit people who are not knowledgeable, and I don't want to have to support that stuff.

    The plus side is that I've already sort of modified some php code to read from a mysql database and write to it each time someone clicks on the file. I've revised the database to have the fields I need, so I'm up to the part of the selection of the site that is next in the list (which I think is the hardest part of the whole thing). The coding itsself is driving me crazy, as it's not nearly as intuititive as VB, and I've still got some errors to work out, but it looks like I'm getting there!

  9. #9
    Platinum Lounger
    Join Date
    Nov 2001
    Location
    Vienna, Wien, Austria
    Posts
    5,009
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Working with quotas

    There's no point in derailing a functioning solution - so if you've got something already running, stay with it.

    You originally talked about downloading, but it now appears you are talking about streaming audio - which raises different issues.

    The full documentation is available off this page. Although the bandwidth can be shared out over a very large number of users, the "tracker" is only available on one machine; which means that you could "lock down" access to the data. That said, I have not seen BitTorrent used for streaming data. Given that BitTorrent is fundamentally asynchronous and streaming is definitely synchronous, it may not support your issue in any event.

    HTH
    Gre

  10. #10
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    San Francisco, California, USA
    Posts
    358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Working with quotas

    Yes, I think that's more what I'm going for, is streaming. I don't have a functioning solution yet, but I think I'm getting closer. And I think I like the satisfaction of creating it myself, even if it's tough going <img src=/S/bash.gif border=0 alt=bash width=35 height=39>

    Thanks for the info on BitTorrent, though, it's really interesting <img src=/S/cool.gif border=0 alt=cool width=15 height=15>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •