forked from rebillar/site-accueil-insa
39 lines
797 B
PHP
39 lines
797 B
PHP
|
<?php
|
||
|
require_once '../classes/dao.php';
|
||
|
|
||
|
|
||
|
if (isset($_GET['function'])) {
|
||
|
if ($_GET['function'] == "save_scores") {
|
||
|
save_scores();
|
||
|
} elseif ($_GET['function'] == "get_scores") {
|
||
|
get_scores();
|
||
|
}
|
||
|
} 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();
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
function show_error() {
|
||
|
echo "Échec : ";
|
||
|
var_dump($_GET);
|
||
|
}
|