Billing Meter bit.ly link or Billing Meter tech0x20 link.

This isn’t perfect. First of all, some connections are just too slow for a constant refresh rate of less than 20-30 seconds. Secondly, I think many mobile browsers have a refresh cut-off at which point they will ask you if you really want to keep refreshing.

The first page, index.php, allows you to enter parameters:
?>

Billing Meter












Billing Rate per Hour
Update Interval (in seconds)
Press Submit to start the counter.


The second file, meter.php, does the display, calculation and refresh:
session_start();
if(strlen($_POST["BILLINGRATE"]))
{

$_SESSION["BILLINGRATE"] = (double)$_POST["BILLINGRATE"];
$_SESSION["REFRESHRATE"] = (int)$_POST["REFRESHRATE"];
if($_POST["STARTTIME"] == "-1")
{
$_SESSION["STARTTIME"] = time();
}
}

echo "";

$netseconds = time()-$_SESSION["STARTTIME"];
$cost = sprintf("%10.2lf", round($_SESSION["BILLINGRATE"]*((double)$netseconds)/3600.0,2));
?>

Billing meter

Time spent:
$time_counter = sprintf("%02d:%02d:%02d", $netseconds/3600, $netseconds / 60 % 60, $netseconds % 60);
?>

for($i=0; $i<8; $i++)
{
echo "

";
}
?>

".$time_counter[$i]."

Your bill:

for($i=0; $i<10; $i++)
{
if($cost[$i]==" ")
{
?>

}
else
{
echo "

";
}
}
?>

$   ".$cost[$i]."


Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • LinkedIn
  • Live
  • StumbleUpon
  • Tumblr
  • TwitThis
  • FriendFeed
  • Netvibes
  • Ping.fm
  • Posterous
  • Technorati
  • Tipd
  • Twitter
  • Yahoo! Buzz