• Working with quotas

    Author
    Topic
    #426594

    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!

    Viewing 2 reply threads
    Author
    Replies
    • #986273

      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 — sad — 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. grin

      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.

      • #986283

        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.

        • #986300

          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.

          • #986390

            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. bananas

            Thanks for your suggestions!

    • #986293

      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[/url%5D). 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…

    • #986530

      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

      • #986646

        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!

        • #986654

          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

          • #986671

            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 bash

            Thanks for the info on BitTorrent, though, it’s really interesting cool

    Viewing 2 reply threads
    Reply To: Working with quotas

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: