<?php
// Electoral Vote Link Button (electoral-vote.com)
// (c) Donald Tetto http://donald.tetto.org/kerry/
// You'll need http://donald.tetto.org/kerry/digits_big.gif and http://donald.tetto.org/electoral_big.gif
$time=time();
if(
$time>@filemtime("current_big.png")+86400) {
  
$xml=@file_get_contents("http://dietrich.ganx4.com/president/server.php?rest");
  
$kerryvotes=substr($xml,strpos($xml,"<kerry>")+7,3);
  
$bushvotes=substr($xml,strpos($xml,"<bush>")+6,3);
  if(
strlen($kerryvotes)&&strlen($bushvotes)&&$kerryvotes>0&&$bushvotes>0) {
    
$image=imagecreatefromgif("electoral_big.gif");
    
$digits=imagecreatefromgif("digits_big.gif");
    
imagecolorset($digits,imagecolorexact($digits,0,0,0),255,255,255);
    
imagecopy($image,$digits,5,10,$kerryvotes[0]*8,0,8,9);
    
imagecopy($image,$digits,13,10,$kerryvotes[1]*8,0,8,9);
    
imagecopy($image,$digits,21,10,$kerryvotes[2]*8,0,8,9);
    
imagecopy($image,$digits,61,10,$bushvotes[0]*8,0,8,9);
    
imagecopy($image,$digits,69,10,$bushvotes[1]*8,0,8,9);
    
imagecopy($image,$digits,77,10,$bushvotes[2]*8,0,8,9);
    
imagepng($image,"current_big.png");
  }
}
header ("Content-type: image/png");
imagepng(imagecreatefrompng("current_big.png"));
?>