Apple was kind enough to put their counter into javascript so we can all take a look at the current numbers for the store.
Since Apple is giving away stuff to each 100,000*nth song buyer, and to the 100,000,000 song buyer, I figured I should make a simple linear projection based on the sales of the past few hours, that has a larger base of numbers every 5 minutes.
Here is the link to the promotion:
http://www.apple.com/itunes/100million/
Here is the link to my projection program:
http://www.blargatron-systems.com/applecount/
If you'd like to make your own, or see how this program works, or tweak/correct my half-assed hurried language, here's the program:
Some of the code was borrowed from one of my other programs, here's how to setup your own:
1. copy the above code and paste it into anyfile.php
2. visit the page in your web browser
3. wait 5 minutes
4. the past and present numbers should be different now, so it's good to use
This creates a file "apple.counter" to store the original number, so please put this into a directory it has permissions to add to (chmod -R 777 should do the trick).
Since Apple is giving away stuff to each 100,000*nth song buyer, and to the 100,000,000 song buyer, I figured I should make a simple linear projection based on the sales of the past few hours, that has a larger base of numbers every 5 minutes.
Here is the link to the promotion:
http://www.apple.com/itunes/100million/
Here is the link to my projection program:
http://www.blargatron-systems.com/applecount/
If you'd like to make your own, or see how this program works, or tweak/correct my half-assed hurried language, here's the program:
Code:
<html>
<head>
<META HTTP-EQUIV="refresh" content="300;URL=Javascript:document.count.submit()">
<title>Applemonkey</title>
<script src="http://phobos.apple.com/external_counter.js" language="JavaScript" type="text/javascript"></script>
</head>
<body>
<font face="arial" size="3">
This page will refresh every 5 minutes, which is when the apple counter refreshes.<Br>
<Br>
Refreshing early is not recommended.<Br>
<Br>
This uses linear functions, which are not accounting for time of day, trends, or anything like that.<Br>
<br>
Hit this button if you don't see any numbers, otherwise don't.<br>
The numbers will be most accurate right after the refresh.
<?PHP
echo '<form method="post" action="'.$_SERVER['PHP_SELF'].'" name="count">
<script type="text/javascript" language="javascript">
<!--
document.write(\'<input name="counter" type="hidden" value="\' + count() + \'">\');
//-->
</script>
<input type="hidden" name="time" value="'.time().'">
<input type="submit" value="Get Current Amount">
</form>';
if($_POST['counter'])
{
if(!file_exists("apple.counter"))
saveDB("apple.counter",array(array(time(), $_POST['counter'])));
}
list($mintime, $minval) = explode("¶¶",file_get_contents("apple.counter"));
$countdiff = $_POST['counter'] - $minval;
$timediff = time() - $mintime;
$num = (int)($_POST['counter'] / 100000);
$num *= 100000;
$num += 100000;
$next100k = $num - $_POST['counter'];
$to100m = 100000000 - $_POST['counter'];
$hourstonext100k = (int)($next100k / ($countdiff / (($timediff/60)/60)));
$hoursto100m = (int)($to100m / ($countdiff / (($timediff/60)/60)));
$rminstonext100k = ((int)($next100k / ($countdiff / ($timediff/60)))) - ($hourstonext100k * 60);
$rminsto100m = ((int)($to100m / ($countdiff / ($timediff/60)))) - ($hoursto100m * 60);
if($_POST['counter'])
echo '
increase/minute: ' . number_format((int)($countdiff / ($timediff/60))).
'/minute<br>
increase/hour: ' . number_format((int)($countdiff / (($timediff/60)/60))).
'/hour<br>
<b>Time to next 100k ('.number_format($num).'): '.$hourstonext100k.' Hours, '
.$rminstonext100k.' Minutes</b><br>
<b>Time to 100m: '.$hoursto100m.' Hours, '.$rminsto100m.' Minutes</b><br>
Amount at '.date("m/d/y g:i a",$mintime).': '.number_format($minval).'<br>
Amount at last refresh ('.date("m/d/y g:i a",$_POST['time']).'): ' . number_format($_POST['counter']);
function saveDB($filename,$dBase)
{
$go = TRUE;
for($j=0;$go;$j++)
{
if(!$dBase[0][$j])
break;
}
$colsTot = $j;
$savedata = "";
for($j=0;$j < count($dBase); $j++)
{
if($j != 0 && file_exists($filename))
$savedata .= "??";
for($k=0;$k < $colsTot;$k++)
{
if($k==0)
$savedata .= $dBase[$j][$k];
else
$savedata .= "¶¶" . $dBase[$j][$k];
}
}
$fp=fopen($filename,"w");
fputs($fp,stripslashes($savedata)); // save log file
fclose($fp);
}
?>
</body>
</html>
Some of the code was borrowed from one of my other programs, here's how to setup your own:
1. copy the above code and paste it into anyfile.php
2. visit the page in your web browser
3. wait 5 minutes
4. the past and present numbers should be different now, so it's good to use
This creates a file "apple.counter" to store the original number, so please put this into a directory it has permissions to add to (chmod -R 777 should do the trick).