PHP Help and scripts (custom)

Status
Not open for further replies.

chris218

New Member
Messages
130
Reaction score
0
Points
0
I'm offering PHP help.

I am pretty "fluent" in php, and have specialised knowledge in certain php software, for instance phpbb.

If you need a bit of help, PM me, or reply to this topic.

I can do pretty much anything within reason, modifcation on a script, or righting a whole new one

Thanks

Chris

PS - this is slight duplicate to in Site Management

IRC - #php-scripts on irc.freenode.net

The topic indicates if i am avaible or not (I'm not ChanServ!)
 

oscar.j4l

New Member
Messages
362
Reaction score
0
Points
0
i need a script that can keep track of bandwidth of a file... and stop the file from being downloaded once it's reached it's max bandwidth.

idk. if you need a more clear explination. :(
 

Chris Z

Active Member
Messages
5,603
Reaction score
0
Points
36
lol i already asked him about this, i believe he said he didn't know how to do it, but i'm sure he could make you a downloads system ;)
 

Torch

New Member
Messages
634
Reaction score
0
Points
0
Tracking bandwidth of a file is impossible through PHP without assistance of some server side application that would track outgoing transfer. In other words, impossible unless you actually own the server or have full shell access.

The closest best thing would be a script that would count bandwidth based on clicks and file size. It will not be very accurate (because it would count bandwidth usage of full size of file each time link is clicked, even if user cancels download), but I could make it for you if you like.
 

Chris Z

Active Member
Messages
5,603
Reaction score
0
Points
36
maybe bryon could make something like this or implement it into cPanel or something :dunno but that would be cool if this was available to members..
 

Spartan Erik

Retired
Messages
6,764
Reaction score
0
Points
0
That's not a bad idea.. if you could make a stat meter of some sort for everyone that would be pretty cool..
 

Bryon

I Fix Things
Messages
8,149
Reaction score
101
Points
48
Torch said:
Tracking bandwidth of a file is impossible through PHP without assistance of some server side application that would track outgoing transfer. In other words, impossible unless you actually own the server or have full shell access.

...

Impossible? Naa... With a few if statements you could convert this function of mine from FileVIP to update a MySQL database table row with the current amount transferred, left to trans., total trans., etc etc.

If you guys want to you could take a shot at it. I don't have time now to. :);)

PHP:
function sendDownload($file, $speed) {
      $filename = basename($file);
      $file_extension = array_pop(explode('.', $filename));
      header("Pragma: public");
      header("Expires: 0");
      header("Cache-Control: private");
      header("Content-Type: application/octet-stream");
      header("Content-Disposition: attachment; filename=\"$filename\"");
      header("Accept-Ranges: bytes");
      $size = filesize($file);  
      if(isset($_SERVER['HTTP_RANGE'])) {
         $seek_range = substr($_SERVER['HTTP_RANGE'], 6);
         $range = explode( '-', $seek_range);
         if($range[0] > 0) { $seek_start = intval($range[0]); }
         if($range[1] > 0) { $seek_end  =  intval($range[1]); }
         header("HTTP/1.1 206 Partial Content");
         header("Content-Length: " . ($seek_end - $seek_start + 1));
         header("Content-Range: bytes $seek_start-$seek_end/$size");
      }
      else {
         $seekSeekSeek = $seek_end / $size;
         header("Content-Range: bytes 0-$seekSeekSeek");
         header("Content-Length: $size");
      }
      $fp = fopen($file,'rb');
      fseek($fp,$seek_start);
      while(!feof($fp)) {
         set_time_limit(0);
         print(fread($fp, (1024 * $speed)));
         flush();
         sleep(1);
      }
      fclose($fp);
      exit;
   }
 
Last edited:

Chris Z

Active Member
Messages
5,603
Reaction score
0
Points
36
hmm well unfortunatley i don't know how to do php with mysql db's and i wouldn't know what to change anyway lol, chris218, could you take a stab at this? and sorry for hijacking your thread... :(
 

chris218

New Member
Messages
130
Reaction score
0
Points
0
I will take a look at bryon's code. I couldn't do it for you billy, as you wanted me to check via cpanel, and I couldn't find a thing on google.

Since it is bryon's code, don't think its really right for me to charge for it, when all i do is convert. I could do it from scratch, but that would be pointless lol.
 

chris218

New Member
Messages
130
Reaction score
0
Points
0
Ok, seen how I can do it,I will do it now, and post the resulting script ;)

Bryon - your function doesn't do anything with bandwidth.. It just checks total file transfer
 
Last edited:

Torch

New Member
Messages
634
Reaction score
0
Points
0
Bryon said:
Impossible? Naa... With a few if statements you could convert this function of mine from FileVIP to update a MySQL database table row with the current amount transferred, left to trans., total trans., etc etc.

If you guys want to you could take a shot at it. I don't have time now to. :);)

PHP:
function sendDownload($file, $speed) {
$filename = basename($file);
$file_extension = array_pop(explode('.', $filename));
header("Pragma: public");
header("Expires: 0");
header("Cache-Control: private");
header("Content-Type: application/octet-stream");
header("Content-Disposition: attachment; filename=\"$filename\"");
header("Accept-Ranges: bytes");
$size = filesize($file); 
if(isset($_SERVER['HTTP_RANGE'])) {
$seek_range = substr($_SERVER['HTTP_RANGE'], 6);
$range = explode( '-', $seek_range);
if($range[0] > 0) { $seek_start = intval($range[0]); }
if($range[1] > 0) { $seek_end = intval($range[1]); }
header("HTTP/1.1 206 Partial Content");
header("Content-Length: " . ($seek_end - $seek_start + 1));
header("Content-Range: bytes $seek_start-$seek_end/$size");
}
else {
$seekSeekSeek = $seek_end / $size;
header("Content-Range: bytes 0-$seekSeekSeek");
header("Content-Length: $size");
}
$fp = fopen($file,'rb');
fseek($fp,$seek_start);
while(!feof($fp)) {
set_time_limit(0);
print(fread($fp, (1024 * $speed)));
flush();
sleep(1);
}
fclose($fp);
exit;
}
Hmm, I tried similar thing once just for testing, but it counted started files and added up bandwidth usage every 30 secs using cron based on connection speed prior detected through javascript (so if file is 50megs large and person's connection is 256kbps, it would add ~960KB every 30secs to bandwisth usage). Never really spent much time on that, had no need for it.

Anyway, I haven't tried your code yet.
 

chris218

New Member
Messages
130
Reaction score
0
Points
0
here we go.. If anyone wants me to intregate I will charge, Theres only a small 50 points to download it..

EDIT

haha, forgot to attach, stupid me..

ANOTHER EDIT

oops, forgot to point out, it only adds file transfer, as I don't see anyway that bryon's script calculates bandwidth..
 

Attachments

  • function.zip
    1.6 KB · Views: 6
Last edited:

Chris Z

Active Member
Messages
5,603
Reaction score
0
Points
36
i was wondering if there's a way to extract a certain amount of characters from a certain line, because i went into the bandwidth component and viewed the source and i found the line and the specific spot where it says the amound of percent...it should be on line...170 and you can see the percent actually printed on there (ie. mine is 26%)
 

chris218

New Member
Messages
130
Reaction score
0
Points
0
billybob bo buck said:
i was wondering if there's a way to extract a certain amount of characters from a certain line, because i went into the bandwidth component and viewed the source and i found the line and the specific spot where it says the amound of percent...it should be on line...170 and you can see the percent actually printed on there (ie. mine is 26%)
Not quite sure what your talking about?
 

Chris Z

Active Member
Messages
5,603
Reaction score
0
Points
36
ok so i went into the bandwidth stats and i viewed the page source (in FF) and noticed it had my percentage in text on the 170th line and i was wondering if we could make a file (obviously it wouldn't be public_html but we could make it in the same directory as bandwidth.html and tell it to send that specific line of bandwidth.html to another file (in the public_html dir) and then make a php file (just using easy math) to calculate how much bandwidth we've used/have lleft then somehow implement into downloads systems..
 

dharmil

New Member
Messages
1,656
Reaction score
0
Points
0
chris the bbcode script still doent work for some reson...
 

chris218

New Member
Messages
130
Reaction score
0
Points
0
dharmil said:
chris the bbcode script still doent work for some reson...
you don't need to post, email and pm, get the point... I replied to your pm.
 

Chris Z

Active Member
Messages
5,603
Reaction score
0
Points
36
well obviously an admin would have to edit the cpanel files LOL
 
Status
Not open for further replies.
Top