<? include $DOCUMENT_ROOT."/zzzfilelist.inc"; ?>
<? include Inc("metootop.inc.php"); ?>
<? $where="validateaccess"; include Inc("checkgameaccess.inc.php"); ?>
<?
	if ($game_mode[$askinggame]!=$user) {
		echo "<br><center><font class='rougeboldpadd'>".$loc[$loctag[2]+5][$lang]."</font>";
		die();
	} else {
		if ($refuse=="yes") {
			$text="<html>You have been refused access to game ".$askinggame." on MeToo !<br>";
			$text.="Game ".$askinggame." is '".$gamecell[$askinggame][2]."'<br>";
			$text.="</html>";
			$headers  = "MIME-Version: 1.0\r\n";
			$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
			echo "<center><br><font  class='orangenormal'><b>Mail sent !</b></font>";
			mail($usercell[$askinguser][5], "MeToo game access refused !", $text, $headers);

			echo "<center><font class='orangenormal'>Access refused !</font>";
		} else {
			$text="<html>You can now access game ".$askinggame." on MeToo !<br>";
			if ($limited=="yes") { $text.="This is a limited access.<br>"; }
			$text.="Game ".$askinggame." is '".$gamecell[$askinggame][2]."'<br>";
			$text.="The password to this game is ".$gamecell[$askinggame][3]."<br>";
			$text.="</html>";
			$headers  = "MIME-Version: 1.0\r\n";
			$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
			echo "<center><br><font  class='orangenormal'><b>Mail sent !</b></font>";
			mail($usercell[$askinguser][5], "MeToo game access granted", $text, $headers);
		
			$done=false;
			for ($j=8; $j<=$usercol; $j++) {
				if ((!$done) && ($usercell[$askinguser][$j]=="")) {
					if ($limited=="yes") {
						$usercell[$askinguser][$j]="limitedaccess".$askinggame;
					} else {
						$usercell[$askinguser][$j]="access".$askinggame;
					}
					$done=true;
				}
			}
			if (!$done) {
				if ($limited=="yes") {
					$usercell[$askinguser][$usercol+1]="limitedaccess".$askinggame;
				} else {
					$usercell[$askinguser][$usercol+1].="access".$askinggame;
				}
				$usercol++;
			}
	
			$savefile="";
			for ($i=1; $i<=$userlin; $i++) {
				for ($j=1; $j<=$usercol; $j++) {
					$savefile.=$usercell[$i][$j].";";
				}
				$savefile.=chr(10);
			}
	#		echo $savefile."<br>";
			
			$fp = fopen ($DOCUMENT_ROOT.$metoobasedir.'data/userlist.csv', "w");
			fwrite($fp, $savefile);
			fclose($fp);
			echo "<center><font class='orangenormal'>Access granted !</font>";
		}
	}
?>
<br><br>
<? include Inc("metoobottom.inc.php"); ?>