PHP: check data transfer on certain directories?

12-22-03, 09:58 PM
|
|
Newbie Coder
|
|
Join Date: Dec 2003
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
PHP: check data transfer on certain directories?
Hi,
suppose I wanted to write a script that gives free web sites (just supposing, I'm not writing one), and each user gets their own directory. If I were to limit each user directory's bandwidth, how would I write my script to check this?
I've heard of some scripts that can do this, but the only possible way I can think of is something that involves checking in the server logs/site statistics kind of log and determine how many bytes of data transfer certain directories are taking. If one doesn't have access those, one can't do that at all.
thanks for any ideas.
|

12-24-03, 02:49 AM
|
 |
Junior Code Guru
|
|
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi there,
I have seen a script like that for webhosting resellers (no longer distributed). The trick that it used was to access WebHostingManager's log and get the bandwidth/disc usages per domain with PHP and report it to you via email (you can set a cron job for that). That way, whatever WHM keeps track of can be referred to.
If you have a bandwitdh stats log on HTTP, FTP, POP..., then you can perhaps access those in a similar way and group them by directories.
...well, it's not much different from what you mentioned, but if you need to do this, you need to use some kind of method to keep track of bandwitdh usage, I suppose.
__________________
Blavv =|
|

12-25-03, 06:08 AM
|
|
Newbie Coder
|
|
Join Date: Dec 2003
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
|
Originally Posted by blaw
Hi there,
I have seen a script like that for webhosting resellers (no longer distributed). The trick that it used was to access WebHostingManager's log and get the bandwidth/disc usages per domain with PHP and report it to you via email (you can set a cron job for that). That way, whatever WHM keeps track of can be referred to.
If you have a bandwitdh stats log on HTTP, FTP, POP..., then you can perhaps access those in a similar way and group them by directories.
...well, it's not much different from what you mentioned, but if you need to do this, you need to use some kind of method to keep track of bandwitdh usage, I suppose.
|
Yeah, what I was wondering was that, I have actually just found a script online (whose URL I won't mention..) that lets you give free web site accounts, and one of its features is checking and limiting each user's bandwidth. If one would have to access some stats log in some ways in order to do this, how can a commercial script include a feature like this? (given that it wouldn't know what kind of stats log the customer's server has)
[edit]
From the FAQ in the web site of this script:
Quote:
My bandwidth monitoring is not working in the program, how can I get it to work?
The bandwidth monitor only works with Apache operating systems, as this web server uses .htaccess files to record the user's bandwidth. We recommend installing the program on Unix/Linux operating systems running with Apache web server. The Apache web server can be freely downloaded from their website - www.apache.org. If you are running IIS on a Windows operating system, the bandwidth feature will not work on the program.
|
What does .htaccess files have to do with bandwidth?
Last edited by Agum; 12-25-03 at 06:14 AM.
|

12-25-03, 03:23 PM
|
 |
Junior Code Guru
|
|
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
|
__________________
Blavv =|
Last edited by blaw; 12-25-03 at 04:10 PM.
|

12-25-03, 07:39 PM
|
|
Newbie Coder
|
|
Join Date: Dec 2003
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Your best bet is to take a statistics script out, tear it apart and reverse engineer a similar one. I'm just a newbie to PHP so I can't help you... I think it could be done though, though I don't know exactly how . ( not even the slightest bit )
|

12-25-03, 09:58 PM
|
|
Newbie Coder
|
|
Join Date: Dec 2003
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I haven't found a free script on www.hotscripts.com or php.resourceindex.com with a feature like this. The normal statistics scripts are of no use because they require you to put its own tracker on the pages, and then it tracks those pages. If you want to track the bandwidth usage of an entire directory (including images and other files, and not needing to put a tracker on the pages) you probably need something different. 
|

12-26-03, 05:17 PM
|
 |
Junior Code Guru
|
|
Join Date: Dec 2003
Location: Vancouver, BC, Canada
Posts: 550
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi again,
There are some statistics scripts that can let you keep track of all the files without placing the "tracker" on each page. You need to install it on your server, though.
There are couple of famous ones that you may be interested:
MRTG
http://people.ee.ethz.ch/~oetiker/webtools/mrtg/
Webalizer
http://www.mrunix.net/webalizer/
You can try stripping these programs' log toget the data.
__________________
Blavv =|
|

12-30-03, 04:58 AM
|
 |
Junior Code Guru
|
|
Join Date: Jun 2003
Location: Utrecht, The Netherlands
Posts: 599
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
I don't understand them mentioning .htaccess for stats, unless the script uses the .htaccess file to keep stats by calling the script... that is an option. normally, apache doesn't use .htaccess though
I have not really heard of a script with this functionality either though, so I can't really help you. sorry.
|
|
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
|
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|