<?php
// If we get a download request, then we process it
if ($_POST['download'] == '1') {
  header("Location: " . $_POST['firmware']);
  exit;
}

// Define firmware locations
include("functions.php");
$apple = _parse_ini_file("firmware.txt", true);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
	<head>
		<title>iPod/iPhone Firmware Download</title>
		<link rel="stylesheet" type="text/css" media="screen" href="style.css" />
		<script type="text/javascript" src="script.js"></script>
	</head>
	<body onload="showIcon('iPodIcon', document.getElementById('iPodSelect')); showIcon('iPhoneIcon', document.getElementById('iPhoneSelect'));">
		<form method="post" action="">
			<input type="hidden" name="download" value="1">
			<b>iPod</b><br />
			<span id="iPodIcon"></span>
			<select id="iPodSelect" name="firmware" style="width: 300px; height: 20px;" onchange="showIcon('iPodIcon', this);">
<?php
foreach ($apple as $version => $firmware) {
  if ($version == "ipodtouch") { continue; }
  foreach ($firmware as $model => $link) { 
    print '<option value="'.$link.'" class="icon '.$version.'">'.$model.'</option>'. "\n";
  }
}
?>
			</select>
			<input type="submit" value="Download" onclick="download('iPodSelect'); return false;" style="height: 25px;">
		</form>
		<br />
		<form method="post" action="">
			<input type="hidden" name="download" value="1">
			<b>iPhone / iPod touch</b><br />
			<span id="iPhoneIcon"></span>
			<select id="iPhoneSelect" name="firmware" style="width: 300px; height: 20px;" onchange="showIcon('iPhoneIcon', this);">
<?php
foreach ($apple as $version => $firmware) {
  if ($version != "ipodtouch") { continue; }
  foreach ($firmware as $model => $link) { 
    print '<option value="'.$link.'" class="icon '.$version.'">'.$model.'</option>'. "\n";
  }
}
?>
			</select>
			<input type="submit" value="Download" onclick="download('iPhoneSelect'); return false;" style="height: 25px;">
		</form>
	</body>
</html>
