<?php 
	if (isset($_GET['id'])) { 
		$user = intval($_GET['id']); 
	} else { 
		echo '<script>window.location="index.php?id=1"</script>';
		die();
	}
	if ($user == 1) { echo '<script>window.location="index.php?id=1"</script>'; die(); }
	$login=false;
	$banned=false;
	session_start();
	if ($_SESSION['valid']) {
		$login=true;
		$myID = intval($_SESSION['id']);
	}else{

		echo '<link rel="stylesheet" href="style.css">';
		include 'header.php';
		echo('You are not logged.');
		die();
	}
	if ($myID==$user) {
		
		echo '<script>window.location="index.php?id="'.$user.'</script>';
		die();
	}
	$my_source = file_get_contents('u/'.$myID.'/user.json');
	$my_data = json_decode($my_source, true);
	if ($my_data["ban"]) {
		echo 'you are banned';
		die();
	}
	

?>	
<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title></title>
</head>
<body><div id="container">
<?php
	
	function folder_exist($folder){
	    $path = realpath($folder);
	    return ($path !== false AND is_dir($path)) ? $path : false;
	}

	include 'config.php';

	$json_source = file_get_contents(ADMINFOLDER.'/reported.json');
	$json_data = json_decode($json_source, true);
	
	// js date
	$date = time()*1000;

	$array = array(
	    "reported" => intval($user),
	    "date" => $date,
	    "by" => intval($myID),
	);

	array_push($json_data, $array);

	$json_dest = json_encode($json_data, JSON_PRETTY_PRINT);
	file_put_contents(ADMINFOLDER.'/reported.json', $json_dest);

	echo '<script>window.location="index.php?id='.$user.'"</script>';

?>
</div></body>
</html>
