Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Download Time Estimations

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #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
  #2  
Old 01-30-2006, 09:50 PM
  B00MER's Avatar 
B00MER B00MER is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Keller, TX (Cart-Lab.com)
Posts: 3,165
 

Default Re: Download Time Estimations

Quote:
Originally Posted by wjbrewer
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.

Excellent Smithers!

Defiantly a bookmark for me.
__________________
Cart-Lab - 100+ Social Bookmarks for X-Cart.
Reply With Quote
  #3  
Old 02-03-2006, 01:36 PM
  wjbrewer's Avatar 
wjbrewer wjbrewer is offline
Banned
 

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

Default

If you want to use this with megabytes you can replace the code

Code:
$filesize = $_GET['filesize'];
with
Code:
$filesize = $_GET['filesize'] * 8388608;

Then use megabytes instead of bits in the url.

Code:
www.yoursite.com/download_time.php?filesize=38mb
Reply With Quote
  #4  
Old 06-21-2006, 11:27 AM
  designtrade's Avatar 
designtrade designtrade is offline
 

Member
  
Join Date: Apr 2006
Posts: 26
 

Default

is there a way to change this to kb?
__________________
- Janie Art Web Development Services
Reply With Quote
  #5  
Old 06-21-2006, 11:35 AM
  wjbrewer's Avatar 
wjbrewer wjbrewer is offline
Banned
 

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

Default

Yea. For kb replace:

Code:
$filesize = $_GET['filesize'];

with
Code:
$filesize = $_GET['filesize'] * 8192;
Reply With Quote
  #6  
Old 06-21-2006, 11:49 AM
  designtrade's Avatar 
designtrade designtrade is offline
 

Member
  
Join Date: Apr 2006
Posts: 26
 

Default

thank you so much! This script is neat for I only sell egoods online!
__________________
- Janie Art Web Development Services
Reply With Quote
  #7  
Old 07-13-2006, 06:18 AM
 
Amy Amy is offline
 

Senior Member
  
Join Date: Feb 2004
Posts: 147
 

Default

great mod - thanks!
__________________
X-Cart Pro 4.0.19; Unix

Other:
XAOM
XOffers
XGift Reg

Other Mods:
Customers Who Also Bought, Download Link Regenerate, Easy Checkout, Newest Products, SEO/CDSEO, Marketing Manager Pro, View Wishlist for Providers (custom by xcart), Email New Releases (a fav!), Telefirma's Dynamic Image Generator, Download Links on Invoice
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 06:16 PM.

   

 
X-Cart forums © 2001-2020