Well I decided to host some files on my paid for site (not my frihost one) as a mirror link but I am concerned because I only have 10GB bandwidth and the file is 60MB so that means (If I can do maths properly) I could get almost 170 downloads. So I thought I would make a script that counted the downloads but I don't know if the file has been downloaded and if it has used up my bandwidth because the counter just checks if the page is loaded.
Is there any way to keep the download available until you have 1GB of bandwidth left or is there a better way to do this?
Thanks.
Well, you could somehow try to link to frih.net:2222 (if you're on server 2) and parse the HTML output to see how full your bandwidth limit is. Or if there was another similar tracker...
| Fire Boar wrote: |
| Well, you could somehow try to link to frih.net:2222 (if you're on server 2) and parse the HTML output to see how full your bandwidth limit is. Or if there was another similar tracker... |
I was thinking about trying that with curl but I thought it would be a bit too awkward.
I was looking for alternatives.
Why not make a link tracker so u know how many people has downloaded it.
Eg... They click the link ---> count.php?id=1 --> your_file.zip
They click the link the php script updates (+1) then it redirects to the file.
The problem with this (which I think the OP was hinting at) is that it only counts page views and not actual downloads. What happens if a person cancels the download after 1 mb? Unless every person completely downloads the file, you'll end up with an inaccurate bandwidth count.
The only way I can think of is to load the DirectAdmin page, parse out the bandwidth info, and then use that.
The tough part will probably be getting your script to submit the username/password so that DirectAdmin loads properly. After you do that, you can easily parse the source of the page. Manually go to the line that contains the bandwidth info, and you can then parse that line to find the actual number.
It isn't necessarily a quick or easy solution, but it's a doable and effective one.
Good luck,
- Walkere
Yeah I suppose. I will try and make a curl script to do this. Thanks guys.
If I manage to get it do you want me to post the script?
[Edit]Since I use cPanel on my other host I managed to find and edit a script to login to cpanel which I am sure can be adapted for direct admin. The script I found was to login to the mail section so I edited it:
<?php
// Domain Details
$username = "cpanel username";
$password = "cpanel password";
$domain = "yourdomain.com";
//DO NOT MODIFY BELOW!
$theme = "x2";
$curl = curl_init();
$url = "http://" . $username . ":" . $password . "@" . $domain . ":2082/frontend/" . $theme . "/index.html?";
curl_setopt($curl, CURLOPT_URL, $url);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 15);
$curl_result = curl_exec ($curl);
curl_close ($curl);
echo $curl_result;
?>
It works great!
| DanielXP wrote: |
Why not make a link tracker so u know how many people has downloaded it.
Eg... They click the link ---> count.php?id=1 --> your_file.zip
They click the link the php script updates (+1) then it redirects to the file. |
This could work, but what if someone just started the download then exits it. It won't give you an accurate result.