2019-05-18 14:55:49 +02:00
|
|
|
<?php
|
|
|
|
require_once '../classes/dao.php';
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($_GET['function'])) {
|
2019-05-19 20:04:02 +02:00
|
|
|
if ($_GET['function'] == "save_scores")
|
2019-05-18 14:55:49 +02:00
|
|
|
save_scores();
|
2019-05-19 20:04:02 +02:00
|
|
|
elseif ($_GET['function'] == "get_scores")
|
2019-05-18 14:55:49 +02:00
|
|
|
get_scores();
|
2019-05-19 20:04:02 +02:00
|
|
|
elseif ($_GET['function'] == "get_map_info")
|
|
|
|
get_map_info();
|
|
|
|
elseif ($_GET['function'] == "save_map_info")
|
|
|
|
save_map_info();
|
2019-05-20 17:56:19 +02:00
|
|
|
elseif ($_GET['function'] == "get_activities_of_day")
|
|
|
|
get_activities_of_day();
|
|
|
|
elseif ($_GET['function'] == "save_day_activities")
|
|
|
|
save_day_activities();
|
2019-05-18 14:55:49 +02:00
|
|
|
} else
|
|
|
|
show_error();
|
|
|
|
|
|
|
|
|
|
|
|
function save_scores() {
|
|
|
|
if (isset($_GET['lines']) && isset($_GET['team'])) {
|
|
|
|
$dao = new Dao('../');
|
|
|
|
$dao->save_scores($_GET['lines'], $_GET['team']);
|
|
|
|
echo "Réussite";
|
|
|
|
} else
|
|
|
|
show_error();
|
|
|
|
}
|
|
|
|
|
|
|
|
function get_scores() {
|
|
|
|
if (isset($_GET['team'])) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
$dao = new Dao('../');
|
|
|
|
echo json_encode($dao->get_score_team($_GET['team']));
|
|
|
|
} else {
|
|
|
|
show_error();
|
|
|
|
}
|
2019-05-19 20:04:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function get_map_info() {
|
|
|
|
if (isset($_GET['selector'])) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
$dao = new Dao('../');
|
|
|
|
echo json_encode($dao->get_map_info($_GET['selector']));
|
|
|
|
} else {
|
|
|
|
show_error();
|
|
|
|
}
|
|
|
|
}
|
2019-05-18 14:55:49 +02:00
|
|
|
|
2019-05-19 20:04:02 +02:00
|
|
|
function save_map_info() {
|
|
|
|
if (isset($_GET['selector']) && isset($_GET['info'])) {
|
|
|
|
$dao = new Dao('../');
|
|
|
|
$dao->save_map_info($_GET['selector'], $_GET['info']);
|
|
|
|
echo "Réussite";
|
|
|
|
} else {
|
|
|
|
show_error();
|
|
|
|
}
|
2019-05-18 14:55:49 +02:00
|
|
|
}
|
|
|
|
|
2019-05-20 17:56:19 +02:00
|
|
|
function get_activities_of_day() {
|
|
|
|
if (isset($_GET['day'])) {
|
|
|
|
header('Content-Type: application/json');
|
|
|
|
$dao = new Dao('../');
|
|
|
|
echo json_encode($dao->get_activities_of_day($_GET['day']));
|
|
|
|
} else {
|
|
|
|
show_error();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function save_day_activities() {
|
|
|
|
if (isset($_GET['day']) && isset($_GET['entries'])) {
|
|
|
|
$dao = new Dao('../');
|
|
|
|
$dao->save_day_activities($_GET['day'], $_GET['entries']);
|
|
|
|
echo "Réussite";
|
|
|
|
} else {
|
|
|
|
show_error();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-05-19 20:04:02 +02:00
|
|
|
|
2019-05-18 14:55:49 +02:00
|
|
|
function show_error() {
|
|
|
|
echo "Échec : ";
|
|
|
|
var_dump($_GET);
|
|
|
|
}
|