<html>
<head>
<?php session_start(); ?>
<style>
html, input{
	font-size: 25px;
	background-color: rgb(30,30,30);
	color: white;
}
input{
	padding: 4px;
}
fieldset, td{
	border: solid 2px white;
	font-size: 25px;
}
td{
	padding: 4px;
}
.messagebox{
	width: 50%;
}
</style>
</head>
<body>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<!--get log-->
<?php
$xml=simplexml_load_file("log.xml");
$i=0;
foreach($xml as $read){
	$logf[$i]=strval($xml->user[$i]);
	$logfname[$i]=strval($xml->user[$i]['name']);
	$logfaction[$i]=strval($xml->user[$i]['action']);
	$i++;
}
?>
<!--register-->
<div align="center">
<form method="post" action="poster.php" target="_blank" onsubmit="prefresh()">
username: <input autocomplete="off" type="text" name="usernameR" required /><br><br>
password: <input autocomplete="off" type="password" name="passwordR" required /><br><br>
discord name (with #numbers): <input autocomplete="off" type="text" name="discord" /><br><br>
(optional, for contact if discord goes down, also will be used as verifing you if you 
lose your password)<br>
email: <input autocomplete="off" type="email" name="email" /><br><br>
<p align="center"><code style="color: orange;">note:</code> that when registering, 
your account will be validated by a mod, you will have to wait</p>

<!--message-->
<div align="center"><div id="messagebox" class="messagebox"></div></div>
<script language="javascript">
if("<?php echo $_SESSION['message']; ?>"=="complete"){
	$("#messagebox").html("complete");
	$("#messagebox").css("background-color","green");
} else if("<?php echo $_SESSION['message']; ?>"=="user allready exist"){
	$("#messagebox").html("user allready exist");
	$("#messagebox").css("background-color","red");
} else if("<?php echo $_SESSION['message']; ?>"=="internal server error"){
	$("#messagebox").html("internal server error");
	$("#messagebox").css("background-color","red");
} else if("<?php echo $_SESSION['message']; ?>"!=""){
	$("#messagebox").html("a unknown error has occured");
	$("#messagebox").css("background-color","red");
}
console.log("<?php echo $_SESSION['message']; ?>");
</script><br>
<a href="../TOS and privacy.html">terms of service</a><br><br>
<input autocomplete="off" type="submit" name="register_submit" value="register" />
</form>
</div>

<!--read/print log-->
<br><br><br><br>
<div align="center"><fieldset style="width: 70%;"><table>
<legend>verified log</legend>
<tr style="background-color: rgb(0,50,120);"><td>user</td><td>action</td><td>reason</td></tr>
<script language="javascript" type="text/javascript">
var logf=JSON.parse('<?php echo json_encode($logf); ?>');
var logfname=JSON.parse('<?php echo json_encode($logfname); ?>');
var logfaction=JSON.parse('<?php echo json_encode($logfaction); ?>');
for(i=0;i<'<?php echo $i; ?>';i++){
	document.write("<tr>");
	document.write("<td>"+logfname[i]+"</td>");
	document.write("<td>"+logfaction[i]+"</td>");
	document.write("<td>"+logf[i]+"</td>");
	document.write("</tr>");
}
//reload
function prefresh(){
	setTimeout(() => { location.reload(); }, 500);
}
</script>
</table></fieldset></div><br>
<div align="center"><a href="manage.php" target="blank" style="color: white;">manager</a></div><br><br><br><br>

</body>
<?php $_SESSION['message']=""; ?>
</html>