OPaNHsHJYK
AL_1

<?php
require("../core/core.php");

// $_GET['user']
// $_GET['place']
// $_GET['apikey']

if(!is_numeric($_GET['user'])){
	$json = array(
	'code' => '-1',
	'status' => 'error',
	'message' => 'Invalic UserId'
	);
	die(json_encode($json));
}
if(!is_numeric($_GET['place'])){
	$json = array(
	'code' => '-1',
	'status' => 'error',
	'message' => 'Invalid PlaceId'
	);
	die(json_encode($json));
}
if(!validateAPIKey($_GET['apikey'], $_GET['place'], $mysqlblox)){
	$json = array(
	'code' => '-1',
	'status' => 'error',
	'message' => 'Invalid API key'
	);
	die(json_encode($json));
}

$query = "SELECT * FROM blox_playerConnections WHERE UserId='".$_GET['user']."' AND PlaceId='".$_GET['place']."';";
$result = mysqli_query($mysqlblox, $query);
if(!$result){
	$json = array(
	'code' => '-1',
	'status' => 'error',
	'message' => 'Error in database 1'
	);
	die(json_encode($json));
}
if ($result->num_rows > 0) {
	while ($row = $result->fetch_assoc()) {
		$time = $row['Time'];
		echo $time;
	}
} else {
	$json = array(
	'code' => '-1',
	'status' => 'error',
	'message' => 'Not found'
	);
	die(json_encode($json));
}

$query = "DELETE FROM blox_playerConnections WHERE UserId='".$_GET['user']."' AND PlaceId='".$_GET['place']."'";
if(!mysqli_query($mysqlblox, $query)){
	$json = array(
	'code' => '-1',
	'status' => 'error',
	'message' => 'Error in database 2'
	);
	die(json_encode($json));
}
$time = str_replace(":","-",$time);
$query = "INSERT INTO blox_placeJoins (id, UserId, PlaceId, JoinTime) VALUES (DEFAULT, ".$_GET['user'].", ".$_GET['place'].", ".$time.");";
if(!mysqli_query($mysqlblox, $query)){
	$json = array(
	'code' => '-1',
	'status' => 'error',
	'message' => 'Error in database 3'
	);
	echo mysqli_error($mysqlblox);
	die(json_encode($json));
}

$json = array(
'code' => '1',
'status' => 'success',
'message' => 'User Removed',
'data' => array(
	'UserId' => $_GET['user'],
	'PlaceId' => $_GET['place'],
	'apikey' => $_GET['apikey']
	)
);
die(json_encode($json));
?>