<? include $DOCUMENT_ROOT."/zzzfilelist.inc"; ?>
<? if (!$dont_inc_general) { include Inc("functions_general.inc.php"); } ?>
<? include Inc("metoo.inc.php"); ?>
<? include Inc("metoo_loc.inc.php"); ?>
<html>
<head><title>MeToo : Middle-Earth Tool for Overcoming Opposition</title>
<link href="<? echo IncL('style_global.css'); ?>" rel="stylesheet" type="text/css">
</head>
<body>
<center>
<font size=+2><b>Middle-Earth Tool for Overcoming Opposition</b></font><br>
<?
	if (!$goingtologin) { include Inc("testlogin.php");	}
?>
<? $where="showmagic_enter"; include Inc("checkgameaccess.inc.php"); ?>
<? include Inc("loaddata.inc.php"); ?>
<?
	if ($action!="") {
		$game=$game_checked;
		$fnsave="Data ".$game.".csv";
		$fnsave = $basedir.$metoobasedir.'turn/data/'.$fnsave;

		if (file_exists($fnsave)) {
		} else {
			for ($i=1; $i<=5; $i++) {
				$datalin++;
				$data[$datalin][1]=$turntodisplay;
				$data[$datalin][2]="neutral";
				$data[$datalin][3]=$i;
				$data[$datalin][4]=0;
				$data[$datalin][5]=0;
			}
		}

		$datalin++;
		$data[$datalin][1]=$turn;
		$data[$datalin][2]="artefactupdated";
		$data[$datalin][3]=$num;
		$data[$datalin][4]=$name;
		$data[$datalin][5]=$people;
		$data[$datalin][6]=$hex;
		$datacol=max($datacol, 6);
		
		$savefile="";
		for ($i=1; $i<=$datalin; $i++) {
			if ($data[$i][1]!="") {
				for ($j=1; $j<=$datacol; $j++) {
					if ($j!=1) {
						$savefile.=";";
					}
					$savefile.=$data[$i][$j];
				}
				$savefile.=chr(10);
			}
		}
		
		$fp = fopen ($fnsave, "w");
		fwrite($fp, $savefile);
		fclose($fp);
		
		echo "<center><br><b>".$loc[$loctag[2]+18][$lang];
		echo "<form action='showmagic.inc.php' method='post'>";
		echo "<input type='hidden' name='show' value='artefacts'>";
		echo "<input type='hidden' name='game' value='$game'>";
		echo "<input type='submit' value='".$loc[$loctag[9]+45][$lang]."'>";
		echo "</form>";
	}
?>
<? include Inc("metoobottom.inc.php"); ?>