I've had a good luck around for something along the lines of what i wanted, all to no avail.
Was just wondering if anyone knew of a way to record bandwidth usage?
I've had a good luck around for something along the lines of what i wanted, all to no avail.
Was just wondering if anyone knew of a way to record bandwidth usage?
Good Question! I'm looking forward is someone gives a good reply.
I can give you an idea though...
When user clicks on a bandwidth checking link, send some data to the user's browser. And when the data reaches completely, tell JavaScript to send it back.
Calculate time between start of sending and end of receiving that data.
Divide the data size by (4 * $seconds_taken) . May be it could tell you the bandwidth.
But what if user is downloading or uploading something along with?
Good Question! I'm looking forward is someone gives a good reply.
I can give you an idea though...
When user clicks on a bandwidth checking link, send some data to the user's browser. And when the data reaches completely, tell JavaScript to send it back.
Calculate time between start of sending and end of receiving that data.
Divide the data size by (4 * $seconds_taken) . May be it could tell you the bandwidth.
But what if user is downloading or uploading something along with?
PS: Don't laugh!! :p
no one's laughing, i wouldn't have thought of that.....okay maybe i would have...but you went into detail.
I say so what if he's downloading something, that's his bandwidth currently at this time he's browsing the website, display the info (quality) based on that bandwidth.
If he comes back another time with more bandwidth he can see the better quality vido/flash/porn/etc...
I say so what if he's downloading something, that's his bandwidth currently at this time he's browsing the website, display the info (quality) based on that bandwidth.
When user clicks on a bandwidth checking link, send some data to the user's browser. And when the data reaches completely, tell JavaScript to send it back.
When user clicks on the link, create a hidden iframe and give src of an HTML file, something like this:[html]<html>
<body onload="documen t.forms[0].submit()">
<form acton="return_d ata.php" method="post">
<input type="hidden" name="data" value="----------fake text of size say50Kb---------" />
</form>
</body>
</html>[/html]
Since the iframe is hidden, nothing would be shown on the browser.
When the server gets the request from a user for that file, save start time somewhere (of course corresponding to the user id or IP), and when return_data.php gets back the whole data, save the end time.
I hope it can work, but not sure! This is just a first try. I've never done anything like this.
Comment