<?php 
/**
 ********************************************
 * Masters of Endurance tracker / LFS-Tracker 
 ********************************************
 * 
 * Copyright © 2007 Wolfgang Tom (WolleT)
 * v1.0 originally written by Wolfgang Tom
 * 
 * Copyright © 2009-2011 Michael Booth (Boothy)
 * v2.0 tracker modified by Michael Booth
 * 
 * Thanks also to Casper Roescher (Kaspur).  
 * 
 * Latest tracker version available from the LFS forum thread - http://www.lfsforum.net/showthread.php?t=73414
 * Any code changes/improvements can be submitted for inclusion in the public tracker version. 
 * E-mail me at web@michaelbooth.me.uk or PM me via http://www.lfsforum.net/private.php?do=newpm&u=202039
 * 
 ********************************************
 * 
 * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
 * Version 2, December 2004

 * Copyright © 2004 Sam Hocevar <sam@hocevar.net>

 * Everyone is permitted to copy and distribute verbatim or modified
 * copies of this license document, and changing it is allowed as long
 * as the name is changed.

 * DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
 * TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

 * 0. You just DO WHAT THE FUCK YOU WANT TO. 
 * 
 ******************************************** 
 * See http://sam.zoy.org/wtfpl/ for more information
 **/
$windowtitleadmin = "Tracker Admin - Track Status"; 
include '../header.admin.php';

$filename = "../trackstatus.txt"; // set file to read
$h3 = "Track Status";


$newdata = null;
if (isset($_POST['newd']) && $_POST['newd'] != "")
    $newdata = $_POST['newd'];

if ($newdata != '')
{

    // open file
    $fw = fopen($filename, 'w') or die('Could not open file!');
    // write to file
    // added stripslashes to $newdata
    $fb = fwrite($fw, stripslashes($newdata)) or die('Could not write to file');
    // close file
    fclose($fw);
}

// open file
$fh = fopen($filename, "r") or die("Could not open file!");
// read file contents
if (filesize($filename) == 0)
{
    $data = "No value";
} else
{
    $data = fread($fh, filesize($filename)) or die("Could not read file!");
    fclose($fh);
}


echo "<h3>$h3</h3>
<form method='post'>
<h4>Current value: $data</h4>
<h5>Last modified: " . date("l, F jS Y \a\\t H:i O", filemtime($filename)) . "</h5>
<br>
<select size='1' name='newd'>
	<option value='GREEN FLAG'>Green Flag</option>
	<option value='SAFETY CAR DEPLOYED'>Safety Car Deployed</option>
	<option value='RED FLAG'>Red Flag</option>
	<option value='CHEQUERED FLAG'>Chequered Flag</option>
	<option value='PRE-RACE'>Pre-Race</option>
</select>
<br>
<input type='submit' value='Update track status'>
</form>"; ?>
</div></div>
</body>
</html>