<?PHP
session_start();
?>

<html>
	<head>
		<script type= "text/javascript" src= "Edit.js" ></script>
		<link rel="stylesheet" href="edit.css">
	</head>
<body>
<div id='editContainer' >
<?php
	require('../photo.php');
	
	//Idea: Read the 'json' file to grab all of the photos that a
    //			user has access to and can edit.
	$fp = fopen("../Photos.txt", 'rb');
	if (!$fp) {
        echo "<b> could not open file<p>";
        exit;
    }
	
	//Idea: Grab all of the photos that a user uploaded and give them
	//			the option to edit some of its information
	///$count = 0; //Maybe use this to give photos their own unique edit id/name
	while (!feof($fp)) {
        $temp = fgets($fp, 999);
        if (!$temp)
            break;
        $photo = new Photo();
        $photo->fillFromJSON($temp);
        
		if($photo->user == $_SESSION['valid_user']){ // || $_SESSION['valid_user'] == "admin") { //check if a photo was uploaded by the current user or user is an admin
		echo "<center> <form id= 'Edit' name= 'Edit' method = 'post' action= 'editPhoto.php'>";
			echo "<input type='submit' value='Edit Me' name= 'Edit Me' /> <input type= 'submit' value= 'Delete Me' name= 'Delete Me'/><br>";
			//CURRENTLY DOESN'T ACTUALLY EDIT OR DELETE THE DATA JUST RETRIEVES -> FINISH WRITING THE EDITPHOTO.PHP FILE
			
			if($photo->view == "public"){
				echo "<label> <input type= 'radio' name= 'view' id= 'private'
				value= 'private' /> Private </label>";
				echo "<label> <input type= 'radio' name= 'view' id= 'public'
				value= 'public' checked = 'checked' /> Public </label> <br>";
			}
			else{
				echo "<label> <input type= 'radio' name= 'view' id= 'private'
				value= 'private' checked = 'checked' /> Private </label>";
				echo "<label> <input type= 'radio' name= 'view' id= 'public'
				value= 'public' /> Public </label> <br>";
			}
			
			echo "User <input type= 'text' name= 'userID' id= 'userID'
			value= '$photo->user' readonly></input> <br>";
			
			echo "File Name <input type= 'text' name= 'fileName' id= 'fileName'
			value= '$photo->fileName' readonly></input> <br>";
			  
			echo "Date <input type= 'text' name= 'theDate' id= 'theDate' 
			value= '$photo->theDate' ></input> <br>";
			  
			echo "Time <input type= 'text' name= 'theTime' id= 'theTime'
			value= '$photo->theTime' ></input> <br>";
			
			echo "Latitude <input type= 'text' name= 'theLat' id= 'theLat'
			value= '$photo->theLat' ></input> <br>";
			
			echo "Longitude <input type= 'text' name= 'theLong' id= 'theLong'
			value= '$photo->theLong' ></input> <br>";
			
			echo "City <input type= 'text', name= 'theCity' id= 'theCity'
			value= '$photo->theCity' ></input>";
			
		echo "</form> </center>";
		echo "<br>";
		} //endif
    }
	fclose($fp);
?>

<center> <a href="../liveIndex.php">Return</a> </center>

</div>
</body>
</html>