I am creating a bandwidth quota program in PHP, however I am finding that to create it with PHP is a bit hard. As an example of what I am trying to do, the user can download 10GB per day, and after they have reached the bandwidth cap the user should be unable to connect.

I would like to find a program to record how much bandwidth the remote host uses (per remote IP address and remote port). The remote port is important to be able to identify that the user behind a NAT has downloaded the file.

I would like to know if it's possible to monitor a remote host not by IP but by username? Can I track how much bandwidth the user uses, making this more simple? It's something like the rapidshare trafficshare system. I need a system like this!

Can you give me some ideas and pointers how to create a system like this using PHP or any scripting language? I really appreciate it!

2 Answers 2


IP ports have absolutely nothing to do with the problem you describe

Forget about IP addresses. Many, many years ago when every computer on the internet had a fixed, public IP address it would have worked. But that time is long gone.

One user can connect from multiple client addresses. Multiple users can connect from a single ip address. Restrict all access to authenticated users and run all the downloads through a PHP script which

1) picks up the authenticated user from the session and redirects to login on failure.
2) identifies if they've sufficient quota to download the requested file or redirects to paid package page
3) updates the quota used at points throughout the download


  • okay i have my coding here can you help me to fix it? pastebin.ca/M2c6Cyj8 password ddd thanks!
    – Saxtor
    Jun 28, 2010 at 3:25
  • can you please give me more ideas and explation of how to do this process? it has been really hard for me i am trying to use my logic but it isn't sufficient can you give me any recommendation of any script, program opensource that i will be able to review the information and convert it, into php coding thanks i really thankful for an experience user that is able to understand what i'm saying and talking about, he is able to understand the idea and question!
    – Saxtor
    Jun 28, 2010 at 4:51

This is an old question, so I guess the OP is unlikely to still be looking for an answer. But I will add some input for the benefit of future visitors.

The internet is awash with small single-file scripts to control byte consumption (amount) and bandwidth (speed). However I haven't found any PHP systems that are (a) designed as an application rather than a single script, and (b) also open-source. I've therefore built my own, which I've released as an alpha for early feedback.

Anyone is welcome to try the software and to suggest features - it is free and open source. With a bit of patience at the install stage it is usable already, but it is probably not suitable for PHP beginners yet. Anyone who is building their own system of this kind is welcome to delve into the source for ideas, or to build on top of what I have already.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.