<?php require_once('../../../../../../../Connections/conn_ama.php'); 
	include("../../../../../../functions/functions.php");    
	    
	if (!isset($_SESSION)) {
	  session_start();
	}
	
//echo $_POST["MM_insert"];
$curr_time = date("Y-m-d H:i:s");

if ((isset($_POST['MM_insert'])) && ($_POST['MM_insert'] == "add-new-sub-metro")) {
	
	
	define('MAX_FILE_SIZE',10121200);
		// if(array_key_exists('add_new_team', $_POST))
		// {	
		
			
			define('UPLOAD_DIR', '../submetrosmaps/');
			
			$file = trim(str_replace(" ","_",$_FILES['image']['name']));
			
			$kilobytes = MAX_FILE_SIZE/1024;
			$formatted = number_format($kilobytes, 1);
			$max = $formatted."KB";
			$permitted = array('image/gif','image/jpeg','image/pjpeg','image/png','image/tiff');
			$sizeok = false;
			$typeok = false;
			if($_FILES['image']['size'] > 0 && $_FILES['image']['size'] <= MAX_FILE_SIZE)
				{
					$sizeok = true;
				}
				foreach($permitted as $type){
					if($type==$_FILES['image']['type'])
					{
						$typeok = true;
						break;
					}
				 }
			if($sizeok && $typeok)
			{
			  switch($_FILES['image']['error']){
			   case 0:
				 include('create_both_logo.inc.php');
				 break;
				 case 3:
				 $result = "Error uploading $file. Please try again";
				 default:
				 $result = "System error uploading $file. Please contact webmaster";
				}
			}
			elseif($_FILES['image']['error']==4)
			{
			  //$result = "No image selected";	

			  /* $insertSQL = sprintf("INSERT INTO players (seasonID, roundID, teamID, fname, mname, lname, dob, jerseyNumber, positionID, countryID) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s , %s)",
	                       GetSQLValueString($_SESSION['seasonID'], "int"),
	                       GetSQLValueString($_POST['roundID'], "int"),
						   GetSQLValueString($_SESSION['t'], "int"),
	                       GetSQLValueString($_POST['fname'], "text"),
						   GetSQLValueString($_POST['mname'], "text"),
	                       GetSQLValueString($_POST['lname'], "text"),
	                       GetSQLValueString($_POST['dob'], "text"),
	                       GetSQLValueString($_POST['jerseyNumber'], "text"),
						   GetSQLValueString($_POST['positionID'], "int"),
						   GetSQLValueString($_POST['countryID'], "int"));

	  			$Result1 = mysqli_query($conn_ama, $insertSQL) or die(mysqli_error($conn_ama));
	  			if($Result1){
	  				$result = "datasent";
	  			} */

			}
			else{ $result = "$file cannot be uploaded. Maximum size: $max. Acceptable file type:
			gif, jpeg, png, tiff";}
		//}
		//if(isset($result)){ echo $result;}
		
}
?>