View Single Post
  #1  
Old 01-30-2006, 11:27 AM
  wjbrewer's Avatar 
wjbrewer wjbrewer is offline
Banned
 

X-Adept
  
Join Date: Feb 2005
Location: Pittsburgh, PA
Posts: 504
 

Default Download Time Estimations

I sell a lot of egoods, or downloadable products that are anywhere from 5mb to 500mb. I wrote this script to display estimated download times so the customers had an idea of the time it would take to download a file. I don't know if anyone else could use it, but here it is.

First create the file download_time.php containing this code
Code:
<? //calculate download times script 1-27-06 by Bill Brewer //set initial variables $filesize = $_GET['filesize']; $s56k_speed = 50000; $s128k_speed = 128000; $s640k_speed = 640000; $s1_2m_speed = 1200000; $s1_8m_speed = 1800000; // calculation script //56k modem $s56k_time = $filesize / $s56k_speed; $s56k_hours = intval(intval($s56k_time) / 3600); $s56k_minutes = intval(($s56k_time / 60) % 60); if ($s56k_hours == "0" && $s56k_minutes <= "01") {$s56k = "less than 1 minute";} elseif ($s56k_hours == "0" && $s56k_minutes >= "01") { $s56k = "$s56k_minutes minutes";} elseif ($s56k_hours >= "2" && $s56k_minutes >= "01") { $s56k = "$s56k_hours hours $s56k_minutes minutes";} else { $s56k = "$s56k_hours hour $s56k_minutes minutes";} //128k $s128k_time = $filesize / $s128k_speed; $s128k_hours = intval(intval($s128k_time) / 3600); $s128k_minutes = intval(($s128k_time / 60) % 60); if ($s128k_hours == "0" && $s128k_minutes <= "01") { $s128k = "less than 1 minute";} elseif ($s128k_hours == "0" && $s128k_minutes >= "01") { $s128k = "$s128k_minutes minutes";} elseif ($s128k_hours >= "2" && $s128k_minutes >= "01") { $s128k = "$s128k_hours hours $s128k_minutes minutes";} else { $s128k = "$s128k_hours hour $s128k_minutes minutes";} // 640k $s640k_time = $filesize / $s640k_speed; $s640k_hours = intval(intval($s640k_time) / 3600); $s640k_minutes = intval(($s640k_time / 60) % 60); if ($s640k_hours == "0" && $s640k_minutes <= "01") { $s640k = "less than 1 minute";} elseif ($s640k_hours == "0" && $s640k_minutes >= "01") { $s640k = "$s640k_minutes minutes";} elseif ($s640k_hours >= "2" && $s640k_minutes >= "01") { $s640k = "$s640k_hours hours $s640k_minutes minutes";} else { $s640k = "$s640k_hours hour $s640k_minutes minutes";} //1.2m $s1_2m_time = $filesize / $s1_2m_speed; $s1_2m_hours = intval(intval($s1_2m_time) / 3600); $s1_2m_minutes = intval(($s1_2m_time / 60) % 60); if ($s1_2m_hours == "0" && $s1_2m_minutes <= "01") { $s1_2m = "less than 1 minute";} elseif ($s1_2m_hours == "0" && $s1_2m_minutes >= "01") { $s1_2m = "$s1_2m_minutes minutes";} elseif ($s1_2m_hours >= "2" && $s1_2m_minutes >= "01") { $s1_2m = "$s1_2m_hours hours $s1_2m_minutes minutes";} else { $s1_2m = "$s1_2m_hours hour $s1_2m_minutes minutes";} //1.8m $s1_8m_time = $filesize / $s1_8m_speed; $s1_8m_hours = intval(intval($s1_8m_time) / 3600); $s1_8m_minutes = intval(($s1_8m_time / 60) % 60); if ($s1_8m_hours == "0" && $s1_8m_minutes <= "01") { $s1_8m = "less than 1 minute";} elseif ($s1_8m_hours == "0" && $s1_8m_minutes >= "01") { $s1_8m = "$s1_8m_minutes minutes";} elseif ($s1_8m_hours >= "2" && $s1_8m_minutes >= "01") { $s1_8m = "$s1_8m_hours hours $s1_8m_minutes minutes";} else { $s1_8m = "$s1_8m_hours hour $s1_8m_minutes minutes";} ?> <html> <head><title>Estimated Download Times</title> <style type="text/css"> <!-- .greytablebak1 { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; background-color: #C0C0C0; text-indent: 5px; } .normtablebak { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; text-indent: 5px; } .downloadtext { font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 14px; } .redstar {color: #FF0000} --> </style> </head> <body> <table width="495" border="0" cellpadding="0" cellspacing="0"> <tr> <td width="247" height="23" valign="middle" class="downloadtext">Connection Speed </td> <td width="248" valign="middle" class="downloadtext">Download Time </td> </tr> <tr> <td height="23" valign="middle" class="greytablebak1">56k - Dial-Up </td> <td valign="middle" class="greytablebak1"><? print "$s56k"?></td> </tr> <tr> <td height="23" valign="middle" class="normtablebak">128k - ISDN </td> <td valign="middle" class="normtablebak"><? print "$s128k"?></td> </tr> <tr> <td height="23" valign="middle" class="greytablebak1">640k - DSL</td> <td valign="middle" class="greytablebak1"><? print "$s640k"?></td> </tr> <tr> <td height="23" valign="middle" class="normtablebak">1.2m - T1/Cable</td> <td valign="middle" class="normtablebak"><? print "$s1_2m"?></td> </tr> <tr> <td height="23" valign="middle" class="greytablebak1">1.8m - T1/Cable</td> <td valign="middle" class="greytablebak1"><? print "$s1_8m"?></td> </tr> </table> <span class="redstar">*</span><span class="verdsmwhite">These are estimations, actual download times can vary.</span></p> </body> </html>

This script is pretty simple, to use it just enter a url like this
Code:
www.yoursite.com/download_time.php?filesize=4928282

Just replace the filesize with the size of the file in bits. (You can use this site http://www.onlineconversion.com/computer_base2.htm to convert from larger sizes to bits.

I think the best way to do this is to add a link like this to the item description.
Code:
<A HREF="javascript:void(0)" onclick="window.open('http://www.yoursite.com/download_time.php?filesize=83899283','downloadtime','width=550,height=250')"> Click here for estimated download times</A>

This will create a popup window displaying the download times.

Last edited by qualiteam : 10-11-2015 at 11:48 PM.
Reply With Quote