<?php
require_once 'conf/link.php';
$player_name = $_POST['player_name'];

$lst_assoc = (isset($_POST['lst_assoc'])) ? $_POST['lst_assoc'] : '';

$res_x = $_POST['res_x'];
$res_y = $_POST['res_y'];
$x0 = $_POST['x0'];
$y0 = $_POST['y0'];

$start = (isset($_POST['hour_start'])) ? $_POST['hour_start'] : '07:00';
$hour_start_aux = explode(':', $start);
$hour_start = $hour_start_aux[0];
$min_start = $hour_start_aux[1];

$end = (isset($_POST['hour_end'])) ? $_POST['hour_end'] : '23:59';
$hour_end_aux = explode(':', $end);
$hour_end = $hour_end_aux[0];
$min_end = $hour_end_aux[1];

$user = (isset($_POST['user'])) ? $_POST['user'] : 'admin';


$datecreate = date("Y-m-d");

$sql  = "INSERT INTO players ( player_name, lst_assoc, res_x, res_y, x0, y0, hour_start, min_start, hour_end, min_end, datecreate, user) ";
$sql .= "VALUES ( '$player_name', '$lst_assoc', '$res_x', '$res_y', '$x0', '$y0', '$hour_start', '$min_start', '$hour_end', '$min_end', '$datecreate', '$user')";
//echo '<br>'.$sql;
$home = "Players/";

$dir = $home.$player_name;
echo "<br>".$dir;
if (mkdir($dir))
{
	$result = mysqli_query($conexion, $sql);
	if ($result)
	{
		echo "<br>Exito";
	}
	else
	{
		echo "<br>Fallo : ";
		printf (mysqli_error($conexion));
	}
}
else
{
	echo "<br>Error al crear el directorio.";
}
?>