*/
require_once 'resources/config.php';
require_once 'resources/database.php';
require_once LIBRARY_PATH . '/redirect.php';
require_once LIBRARY_PATH . '/exceptions.php';
$db = new Database();
$sports = $db->getSports();
// redirect to the login page if the user is not logged in
if (isset($_COOKIE[ACCESS_TOKEN_NAME])) {
$access_token = $_COOKIE[ACCESS_TOKEN_NAME];
$success = $db->verifyUserAccessToken($access_token);
if (!$success) {
redirect('login.php');
}
} else {
redirect('login.php');
}
if (isset($_POST['add_team'])) {
$name = $_POST['name'];
if (strlen($name) > 0) {
$db->createTeam($name);
}
}
if (isset($_POST['add_match'])) {
$team1 = $_POST['team1'];
$team2 = $_POST['team2'];
$sport_id = $_POST['sport'];
$type = $_POST['type'];
$date = $_POST['datetime'];
if (strlen($date) > 0) {
$db->createMatch($team1, $team2, $sport_id, $type, $date);
}
}
if (isset($_POST['edit_match'])) {
$match_id = $_POST['match_id'];
$team1_id = $_POST['team1_id'];
$team2_id = $_POST['team2_id'];
$team1_score = $_POST['team1_score'];
$team2_score = $_POST['team2_score'];
$db->modifyScore($team1_score, $team1_id, $match_id);
$db->modifyScore($team2_score, $team2_id, $match_id);
}
if (isset($_POST['delete_match'])) {
$match_id = $_POST['match_id'];
$db->deleteMatch($match_id);
}
if (isset($_POST['delete_team'])) {
$team_id = $_POST['team_id'];
$db->deleteTeam($team_id);
}
$match_types = array(
"0" => "Poule",
"1" => "Finale",
"2" => "Demi-finale",
"3" => "Quart de finale",
"4" => "Petite finale",
"5" => "Huitième de finale",
"6" => "Seizième de finale",
"7" => "Poules 2",
);
?>
Interpromos - Administration
Administration
Se déconnecter
| Id |
Nom |
|
getTeams() as $team) { ?>
|
|
|
| Id |
Type |
Sport |
Team A |
Team B |
Score A |
Score B |
Date |
|
|
getMatches() as $match) {
$teams = json_decode($match['teams_id']);
$scores = json_decode($match['scores']);
?>
|
|