<?php

// iphone redirect
if (strpos($_SERVER['HTTP_USER_AGENT'], 'iPhone') !== FALSE) {
    header('Location: http://donpoo.net/movies/i/');
}

$srcfile = 'movies.txt';
if (!file_exists($srcfile)) die("No movie list available at this time");

$list = file($srcfile, FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES);
$mtime = filemtime($srcfile);
$list_count = sizeof($list);
if ($mtime) $list_date = date("F d Y H:i:s", $mtime);
else $list_date = 'Unknown';
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en-GB">
<head>
	<title>Movie List - <?=$list_count?> - <?=$list_date?></title>
	<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
	<link rel="icon" type="image/vnd.microsoft.icon" href="favicon.ico" />
	<link rel="stylesheet" type="text/css" href="movies.css" />
	<meta name="robots" content="noindex, nofollow" />
</head>
<body>

<div id="header">Movie List :: <?=$list_count?> as of <?=$list_date?></div>
<div class="colmask fullpage">
	<div class="col1"><p>
		<!-- Column 1 start -->
		<?php
		foreach ($list as $line) {
			$line = trim($line);
			if (!$line) continue;
			list($title, $year) = explode("\t", $line);
			if ($year == 0) $year = '(year unknown)';
			print htmlentities("$title - $year", ENT_COMPAT, 'UTF-8') . "<br />\n";
		}
		?>
		<!-- Column 1 end -->
	</p></div>
</div>
<div id="footer"></div>

</body>
</html>
