<?
	$basedir = $DOCUMENT_ROOT;
	$metoobasedir=DirL('displaymap.php');
	$nbfile=0;
	MakeList('');
	
	$fn=Inc("gamelist.csv");
	$fp = fopen ($fn, "r");
	if (filesize($fn)>0) { $passlist = fread($fp, filesize($fn)); }
	fclose($fp);
	Decrunch($passlist);
	$gamecell=$cell;
	$gamelin=$lin;
	$gamenb=$gamelin;
	for ($i=1; $i<=$gamenb; $i++) {
		$game_nb[$i]=$gamecell[$i][1];
		$game_name[$i]=$gamecell[$i][2];
		$game_pass[$i]=$gamecell[$i][3];
		$game_mode[$i]=$gamecell[$i][4];
		$game_check[$i]=$gamecell[$i][5];
		$game_side[$i]=$gamecell[$i][6];
		$game_status[$i]=$gamecell[$i][7];
		$game_past[$i]=$gamecell[$i][8];
	}
	
	$fn=Inc("userlist.csv");
	$fs=filesize($fn);
	$fp = fopen ($fn, "r");
	if (filesize($fn)>0) { $userlist = fread($fp, filesize($fn)); }
	fclose($fp);
	Decrunch($userlist);
	$usercell=$cell;
	$userlin=$lin;
	$usercol=$col;

	$i=0;
	$found=false;
	do {
		$i++;
		if ($cell[$i][1]==$login) { $found=true; }
	} while ((!$found) && ($i<$lin));
	$user=$i;
	$firstname = $cell[$i][3];
	$lastname = $cell[$i][4];
	$email = $cell[$i][5];
	$phone = $cell[$i][6];
	
	$adminuser=false;
	for ($i=1; $i<=$usercol; $i++) {
		if ($cell[$user][$i]=="adminMT") {
			$adminuser=true;
		}
	}
	
	for ($n=1; $n<=$gamenb; $n++) {
		$mustfound="access".$n;
		$mustfoundlimited="limitedaccess".$n;
		$getaccess[$n]=false;
		$getaccesslimited[$n]=false;
		for ($i=1; $i<=$usercol; $i++) {
			if ($cell[$user][$i]==$mustfound) {
				$getaccess[$n]=true;
			}
			if ($cell[$user][$i]==$mustfoundlimited) {
				$getaccesslimited[$n]=true;
				$limitedaccesscell[$n]=$cell[$user][$i+1];
			}
		}
		if ($adminuser) {
			$getaccess[$n]=true;
		}
	}
	
	if ($where!="displayres") {
		if (($game!=0) && ($game!=1)) {
			if ((!$getaccess[$game]) && (!$getaccesslimited[$game])) {
				echo "<br><center><font class='rougeboldpadd'>".$loc[$loctag[2]+5][$lang]."</font>";
				die();
			}
		}
		if ($where=="displaymap") {
			if (($game==0) && ($game_checked==0)) {
				echo "<br><center><font class='rougeboldpadd'>".$loc[$loctag[2]+5][$lang]."</font>";
				die();
			}
		}
	}
?>