<?php session_start(); ?>
<html>
<head>
<style>
html, input{
	font-size: 25px;
	background-color: rgb(30,30,30);
	color: white;
}
table, td{
	border: solid 2px white;
	font-size: 25px;
}
td{
	padding: 4px;
	padding-top: 1px;
	padding-bottom: 1px;
}
.button{
	padding: 0px;
	width: 30px;
	height: 35px;
}
</style>
</head>
<body>
<?php
require_once("../../mysql_connect.php");
$username=$_POST['username'];
$password=$_POST['password'];

$userc="true";
if($username!="iceyrazor"){
	$userc="false";
} else {
	$stmt = $dbc->prepare("select * from accounts where username=?");
	$stmt->execute([$username]);
	$getpass=$stmt->fetch()['password'];
	if(password_verify($password,$getpass)){
		$passwordc="true";
	} else {
		$passwordc="false";
	}
}
$stmt = $dbc->query("select username,discord,email from unver_accounts");

$getusername=array();
$getdiscord=array();
$i=0;
while($row = $stmt->fetch()){
	$getusername[$i]=$row['username'];
	$getdiscord[$i]=$row['discord'];
	$i++;
}
$dbc=null;
?>
<script language="javascript">
	if('<?php echo $userc; ?>' == "false"){
		if(alert('only the owner has permission to use this page')) {
			window.location.replace("loginM.php");
		} else {
			window.location.replace("loginM.php");
		}
		throw new Error('This is not an error. This is just to abort javascript');
	}
	if('<?php echo $passwordc; ?>' == "false"){
		if(alert('password is incorrect')) {
			window.location.replace("loginM.php");
		} else {
			window.location.replace("loginM.php");
		}
		throw new Error('This is not an error. This is just to abort javascript');
	}
</script>
<div align="center"><table><tr style="background-color: rgb(0,50,120);"><td>user</td><td>discord</td></tr>
<form target="_blank" align="center" method="post" action="poster.php" onsubmit="prefresh()">
<script language="javascript" type="text/javascript">
var uname=JSON.parse('<?php echo json_encode($getusername) ?>');
var discord=JSON.parse('<?php echo json_encode($getdiscord); ?>');
for(i=0;i<uname.length;i++){
	document.write("<tr>");
	document.write("<td>"+uname[i]+"</td>");
	document.write("<td>"+discord[i]+"</td>");
	document.write('<td><input autocomplete="off" type="radio" name="user" value="'+uname[i]+'" /></td>');
	document.write("</tr>");
}
</script>
</table></div><br>
<div align="center">
action: <select autocomplete="off" name="action">
	<option autocomplete="off" value="accept">accept</option>
	<option autocomplete="off"value="deny">deny</option>
</select><br><br>
<input autocomplete="off" type="text" name="reason" value="reason" /><br><br>
<input autocomplete="off" type="submit" name="manageconfirm" value="confirm" />
</div></form>

<script language="javascript">
function prefresh(){
	setTimeout(() => { location.reload(); }, 1000);
}
</script>
</body>
</html>