<?php
	echo "<html><head><title>Phone pictures</title></head><body>\n";
	$lastfile = file_get_contents("last");
	echo "<a href=\"gallery.html\">Gallery</a><br/>";
	echo "<center>\n";
	$imgnum = $_GET["num"];
	if(!is_numeric($imgnum)) {
		$imgnum = $lastfile;
	}
	if(file_exists("$imgnum.mp4")) {
		echo "<video preload=\"none\" src=\"$imgnum.mp4\" poster=\"$imgnum.jpg\" controls></video></br>\n";
	} else {
		echo "<img src=\"$imgnum.jpg\"/></br>\n";
	}
	$nextnum = $imgnum + 1;
	$prevnum = $imgnum - 1;
	if(file_exists("$prevnum.jpg")) {
		echo "<a href=\"index.php?num=$prevnum\">previous</a> \n";
	}
	echo "<a href=\"index.php?num=$imgnum\">this</a> \n";
	if(file_exists("$nextnum.jpg")) {
		echo "<a href=\"index.php?num=$nextnum\">next</a></br>\n";
	}
	echo "</center>\n";
	echo "</body></html>\n";

?>
