Compare commits

..

No commits in common. "0a42f4b62506f0423c1a81a38758fbfc25b461e6" and "a213713eba7287086d167b78cdfe102b3cce0143" have entirely different histories.

20 changed files with 392 additions and 241 deletions

24
ajax/admin/admin/ajax.php Normal file
View file

@ -0,0 +1,24 @@
<?php
require_once '../../classes/dao.php';
if (isset($_GET['function'])) {
if ($_GET['function'] == "save_day_activities")
save_day_activities();
} 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();
}
}
function show_error() {
echo "Échec : ";
var_dump($_GET);
}

View file

@ -0,0 +1,59 @@
<?php
ob_start(); // Start reading html
$relativePath = "../../";
?>
<div class="inner">
<h1>ADMIN</h1>
<h2>Edition du planning</h2>
<select id="daySelect">
<option value="1">Lundi</option>
<option value="2">Mardi</option>
<option value="3">Mercredi</option>
<option value="4">Jeudi</option>
<option value="5">Vendredi</option>
<option value="6">Samedi</option>
<option value="7">Dimanche</option>
</select>
<br>
<div class="add-line">
<i class="fas fa-plus"></i>
</div>
<div class="edit-header">
<div class="planning-start">Début</div>
<div class="planning-length">Durée</div>
<div class="planning-name">Nom</div>
<div class="planning-trash"><i class='fas fa-trash'></i></div>
</div>
<table id="activityTable">
</table>
<div class="save">
<i class="fas fa-save"></i> Enregistrer
</div>
<br>
<div class="buttons-container">
<a href="../index.php" class="admin-back-button">
<i class="fas fa-chevron-left"></i>
Retour sur la page admin
</a>
<a href="<?= $relativePath ?>planning.php" class="website-back-button">
Voir sur le site
</a>
</div>
</div>
<link rel="stylesheet" type="text/css" media="screen" href="<?= $relativePath ?>assets/css/adminEdit.css"/>
<?php
$pageContent = ob_get_clean(); // Store html content in variable
$pageTitle = "Édition planning";
$pageScripts = "<script type=\"text/javascript\" src=\"".$relativePath."assets/js/admin/planningManager.js\"></script>";
include($relativePath . "includes/template.php"); // Display template with variable content
?>

24
ajax/admin/gda/ajax.php Normal file
View file

@ -0,0 +1,24 @@
<?php
require_once '../../classes/dao.php';
if (isset($_GET['function'])) {
if ($_GET['function'] == "save_scores")
save_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 show_error() {
echo "Échec : ";
var_dump($_GET);
}

61
ajax/admin/gda/scores.php Normal file
View file

@ -0,0 +1,61 @@
<?php
ob_start(); // Start reading html
$relativePath = "../../";
?>
<div class="inner">
<h1>ADMIN</h1>
<h2>Edition des scores</h2>
<ul>
<strong style="color: #ee293d">Quelques règles pour les scores</strong>
<li>Pas de score total négatif pour une équipe</li>
<li>A priori les scores supérieurs à 1000 marchent, mais au cas restez à
moins de 1000 (comme l'année dernière quoi)</li>
</ul>
Si jamais y'a un quelconque problème, envoyez-moi un message.
<br>
<br>
<select id="teamSelect">
<option value="boo">Boomiflore</option>
<option value="pek">Peksureau</option>
</select>
<div class="add-line">
<i class="fas fa-plus"></i>
</div>
<div class="edit-header">
<div class="stat-log">Log</div>
<div class="stat-points">Points</div>
<div class="stat-trash"><i class='fas fa-trash'></i></div>
</div>
<table class="stats-table edit-stats">
</table>
<div class="save">
<i class="fas fa-save"></i> Enregistrer
</div>
<br>
<div class="buttons-container">
<a href="../index.php" class="admin-back-button">
<i class="fas fa-chevron-left"></i>
Retour sur la page admin
</a>
<a href="<?= $relativePath ?>stats.php" class="website-back-button">
Voir sur le site
</a>
</div>
</div>
<link rel="stylesheet" type="text/css" media="screen" href="<?= $relativePath ?>assets/css/adminEdit.css"/>
<?php
$pageContent = ob_get_clean(); // Store html content in variable
$pageTitle = "Édition scores";
$pageScripts = "<script type=\"text/javascript\" src=\"".$relativePath."assets/js/admin/statsManager.js\"></script>";
include($relativePath . "includes/template.php"); // Display template with variable content
?>

62
ajax/admin/index.php Normal file
View file

@ -0,0 +1,62 @@
<?php
ob_start(); // Start reading html
$relativePath = "../";
?>
<div class="inner">
<h1>ADMIN</h1>
<h2>Bienvenue sur la page d'administration</h2>
<p>
Sur cette page, tu vas pouvoir animer le site en changeant les scores, le planning ou les informations de la
carte.
<br/>
Attention, tu dois avoir le compte approprié pour pouvoir modifier ces informations.
<br/>
Les comptes sont les suivants (le numéro indique le niveau de privilèges) :
</p>
<ol>
<li>
GDA
</li>
<li>
Admin
</li>
<li>
Webmaster
</li>
</ol>
<p>
Un compte hérite des privilèges de tous ceux ayant un niveau inférieur.
<br/>
Donc ici, Webmaster les possède tous.
</p>
<div class="admin-container">
<h4>
Action des GDA
</h4>
<a href="gda/scores.php">Editer les scores</a>
</div>
<div class="admin-container">
<h4>
Action des admins
</h4>
<a href="admin/planning.php">Editer le planning</a>
</div>
<div class="admin-container">
<h4>
Action des webmasters
</h4>
<a href="webmaster/map.php">Editer le texte de la carte</a>
<br/>
<a href="webmaster/update.php">Mises à jour</a>
</div>
</div>
<link rel="stylesheet" type="text/css" media="screen" href="<?= $relativePath ?>assets/css/adminEdit.css"/>
<?php
$pageContent = ob_get_clean(); // Store html content in variable
$pageTitle = "ADMIN";
include($relativePath . "includes/template.php"); // Display template with variable content
?>

View file

@ -0,0 +1,47 @@
<?php
require_once '../../classes/dao.php';
$rest_json = file_get_contents("php://input");
$_POST = json_decode($rest_json, true);
//var_dump($_POST);
if (isset($_GET['function']) || isset($_POST['function'])) {
if ($_GET['function'] == "save_map_info")
save_map_info();
elseif ($_POST['function'] == "update_website")
update_website();
} else
show_error();
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();
}
}
function update_website() {
// if (isset($_POST['login']) && isset($_POST['password'])) {
// $login = $_POST['login'];
// $password = $_POST['password'];
// echo $login . ":" . $password."\n";
// // Cannot write because php cannot write as user www-data
// // be sure to escape characters
// // Do not remove the space before the command (prevent command from being saved in history)
//// system(" git pull https://".$login.":".$password."@git.srv-falcon.etud.insa-toulouse.fr/vergnet/site-accueil-insa.git");
// } else {
// show_error();
// }
}
function show_error() {
echo "Échec :\n";
echo "GET\n";
var_dump($_GET);
echo "POST\n";
var_dump($_POST);
}

View file

@ -0,0 +1,57 @@
<?php
ob_start(); // Start reading html
$relativePath = "../../";
require_once $relativePath . 'classes/dao.php';
?>
<div class="inner">
<h1>ADMIN</h1>
<h2>Edition de la carte</h2>
<select id="mapSelect">
<?php setup_map_dropdown() ?>
</select>
<br>
<label for="titleInput">Titre</label>
<input type="text" id="titleInput">
<label for="descriptionInput">Description</label>
<textarea rows="15" id="descriptionInput"></textarea>
<div class="save">
<i class="fas fa-save"></i> Enregistrer
</div>
<br>
<div class="buttons-container">
<a href="../index.php" class="admin-back-button">
<i class="fas fa-chevron-left"></i>
Retour sur la page admin
</a>
<a href="<?= $relativePath ?>map.php" class="website-back-button">
Voir sur le site
</a>
</div>
</div>
<link rel="stylesheet" type="text/css" media="screen" href="<?= $relativePath ?>assets/css/adminEdit.css"/>
<?php
$pageContent = ob_get_clean(); // Store html content in variable
$pageTitle = "Édition carte";
$pageScripts = "<script type=\"text/javascript\" src=\"".$relativePath."assets/js/admin/mapManager.js\"></script>";
include($relativePath . "includes/template.php"); // Display template with variable content
function setup_map_dropdown()
{
$dao = new Dao();
foreach ($dao->get_map_selectors() as $row) {
echo "<option value='" . $row['selector'] . "'>" . $row['selector'] . "</option>";
}
}
?>

View file

@ -0,0 +1,57 @@
<?php
ob_start(); // Start reading html
$relativePath = "../../";
require_once $relativePath . 'classes/dao.php';
$log = shell_exec("git log | head -50"); // Show the first few commits
?>
<div class="inner">
<h1>ADMIN</h1>
<h2>Mise a jour du site</h2>
<!-- <label for="usernameInput">Login</label>-->
<!-- <input type="text" id="usernameInput">-->
<!---->
<!-- <label for="passwordInput">Password</label>-->
<!-- <input type="password" id="passwordInput">-->
<!---->
<!-- <div class="save">-->
<!-- <i class="fas fa-save"></i> Mettre à Jour-->
<!-- </div>-->
<div id="gitButton">
<a href="https://git.srv-falcon.etud.insa-toulouse.fr/vergnet/site-accueil-insa" target="_blank">
Voir sur Gitea
</a>
</div>
<h3>Log</h3>
<p>
<?php
echo nl2br($log)
?>
</p>
<div class="buttons-container">
<a href="../index.php" class="admin-back-button">
<i class="fas fa-chevron-left"></i>
Retour sur la page admin
</a>
<a href="<?= $relativePath ?>index.php" class="website-back-button">
Voir sur le site
</a>
</div>
</div>
<link rel="stylesheet" type="text/css" media="screen" href="<?= $relativePath ?>assets/css/adminEdit.css"/>
<?php
$pageContent = ob_get_clean(); // Store html content in variable
$pageTitle = "Mise à jour";
$pageScripts = "<script type=\"text/javascript\" src=\"".$relativePath."assets/js/admin/updateManager.js\"></script>";
include($relativePath . "includes/template.php"); // Display template with variable content
?>

View file

@ -75,34 +75,7 @@ function isFirstTeamToSolve($score_data) {
return true;
}
function isAlreadySolved($team, $enigme) {
$dao = new Dao();
$score = $dao->get_score_team($team);
foreach($score as $value) {
if ($value['text'] == $enigme)
return false;
}
return true;
}
function isLastEnigmaSolved($enigme) {
$dao = new Dao();
$scorePek = $dao->get_score_team('pek');
$scoreBoo = $dao->get_score_team('boo');
$score = array_merge($scorePek, $scoreBoo);
foreach($score as $value) {
if ($value['text'] == $enigme)
return true;
}
return false;
}
// TODO : passer ça sous DB
function get_enigma_code() {
if (isset($_GET['code'])) {
$data = array(
@ -310,36 +283,10 @@ function get_enigma_code() {
<p>Bien joué ! Attendez demain pour la suite !</p>";
} else {
$data["info"] = "<h2>Énigme 00 Intermédiaire</h2>
<p>En résolvant cette énigme, vous avez reçu un petit parachute avec à lintérieur cette mystérieuse <a href=\"assets/enigmes/Liberation/Carte-odRS.jpg\">carte</a>.</p>
</p> Les participants sont autorisés à quitter larène le temps de retrouver leurs compagnons. Evidemment, ils seront accompagnés par un bataillon de pacificateurs et des caméras pour suivre chacun de leurs mouvements. Mais attention, ils ne pourront choisir quune seule destination, bon courage, et puisse le sort vous être favorable.
</p>
<p>Bien joué ! Attendez demain pour la suite !</p>
";
}
if(isFirstTeamToSolve($score_data)) {
$dao = new Dao();
$dao->add_score($score_data);
}
echo json_encode($data, JSON_FORCE_OBJECT);
break;
case 'Venise' :
$data["name"] = "enigme-liberation-1";
$score_data["text"] = 'Énigme Libération 1';
$score_data["points"] = 100;
if($date< 1628613000 ) {
$data["info"] = "<h2>Énigme Libération 1</h2>
<p>Bien joué ! Attendez un peu pour la suite !</p>";
} else {
$data["info"] = "<h2>Énigme Libération 1</h2>
<p>Inversez les couleurs et videz leau, à quoi cela vous fait penser ?</p>
";
}
if(isFirstTeamToSolve($score_data)) {
$dao = new Dao();
$dao->add_score($score_data);
@ -347,193 +294,6 @@ function get_enigma_code() {
echo json_encode($data, JSON_FORCE_OBJECT);
break;
case 'Jean Jaurès' :
$data["name"] = "enigme-liberation-2";
$score_data["text"] = 'Énigme Libération 2';
$score_data["points"] = 100;
if(isLastEnigmaSolved('Énigme Libération 1')) {
if($date < 1628613000) {
$data["info"] = "<h2>Énigme Libération 2</h2>
<p>Vous avez compris le message des informateurs, aller dans le centre de la capitale de Panem vous parait évident maintenant. </p>
<p>Mais un virus tourne, il ne faudrait pas faire retentir le canon et perdre des tributs, alors ne passez pas trop de temps dans la ville !
</p>";
} else {
$data["info"] = "<h2>Énigme Libération 2</h2>
<p>Vous avez compris le message des informateurs, aller dans le centre de la capitale de Panem vous parait évident maintenant. </p>
<p>Mais un virus tourne, il ne faudrait pas faire retentir le canon et perdre des tributs, alors ne passez pas trop de temps dans la ville !
</p>";
}
if(isFirstTeamToSolve($score_data)) {
$dao = new Dao();
$dao->add_score($score_data);
}
echo json_encode($data, JSON_FORCE_OBJECT);
}
break;
case 'Café Pop' :
$data["name"] = "enigme-liberation-3-1";
$score_data["text"] = 'Énigme Libération 3-1';
$score_data["points"] = 50;
if(isLastEnigmaSolved('Énigme Libération 2')) {
if($date < 1628613000) {
$data["info"] = "<h2>Énigme Libération 3-1</h2>
<p>Aucune perte du côté de votre district, tout va bien, vous avancez prudemment dans la ville…</p>
<img src=\"assets/enigmes/Liberation/03-06.jpg\"></img>
<img src=\"assets/enigmes/Liberation/07-12.jpg\"></img>";
} else {
$data["info"] = "<h2>Énigme Libération 3-1</h2>
<p>Aucune perte du côté de votre district, tout va bien, vous avancez prudemment dans la ville…</p>
<img src=\"assets/enigmes/Liberation/03-06.jpg\"></img>
<img src=\"assets/enigmes/Liberation/07-12.jpg\"></img>";
}
if(isFirstTeamToSolve($score_data)) {
$dao = new Dao();
$dao->add_score($score_data);
}
echo json_encode($data, JSON_FORCE_OBJECT);
}
break;
case 'Snapper' :
$data["name"] = "enigme-liberation-3-2";
$score_data["text"] = 'Énigme Libération 3-2';
$score_data["points"] = 50;
if(isLastEnigmaSolved('Énigme Libération 2')) {
if($date < 1628613000) {
$data["info"] = "<h2>Énigme Libération 3-2</h2>
<p>Aucune perte du côté de votre district, tout va bien, vous avancez prudemment dans la ville…</p>
<img src=\"assets/enigmes/Liberation/11-08.jpg\"></img>
<img src=\"assets/enigmes/Liberation/19-05.jpg\"></img>
<img src=\"assets/enigmes/Liberation/06-03.jpg\"></img>";
} else {
$data["info"] = "<h2>Énigme Libération 3-2</h2>
<p>Aucune perte du côté de votre district, tout va bien, vous avancez prudemment dans la ville…</p>
<img src=\"assets/enigmes/Liberation/11-08.jpg\"></img>
<img src=\"assets/enigmes/Liberation/19-05.jpg\"></img>
<img src=\"assets/enigmes/Liberation/06-03.jpg\"></img>";
}
if(isFirstTeamToSolve($score_data)) {
$dao = new Dao();
$dao->add_score($score_data);
}
echo json_encode($data, JSON_FORCE_OBJECT);
}
break;
case 'needhelp' :
$data["name"] = "enigme-liberation-3-3";
$score_data["text"] = 'Énigme Libération 3-3';
$score_data["points"] = 0;
if(isLastEnigmaSolved('Énigme Libération 3')) {
if($date < 1628613000) {
$data["info"] = "<h2>Énigme Libération 3-3</h2>
<a href=\"\">Je t'embarque au poste.</a>";
} else {
$data["info"] = "<h2>Énigme Libération 3-3</h2>
<p>Les arènes de tous les INSA Games étaient jusquà présent truffées de pièges mortels. Cette ville est votre nouvelle arène, et évidemment elle ny fait pas exception.
Mais cette année, les hauts juges ont créé ce <a href=\"assets/enigmes/Liberation/pieges.pdf\">document</a> afin de vous aider à les localiser.</p>
";
}
echo json_encode($data, JSON_FORCE_OBJECT);
}
break;
case 'Saint des seins' :
$score_data["text"] = 'Malus Énigme Libération 1';
$score_data["points"] = -25;
if(isAlreadySolved($team, $score_data["text"])) {
$dao = new Dao();
$dao->add_score($score_data);
}
break;
case 'La Couleur de la Culotte' :
$score_data["text"] = 'Malus Énigme Libération 2';
$score_data["points"] = -25;
if(isAlreadySolved($team, $score_data["text"])) {
$dao = new Dao();
$dao->add_score($score_data);
}
break;
case '0712' :
$score_data["text"] = 'Malus Énigme Libération 3';
$score_data["points"] = -25;
if(isAlreadySolved($team, $score_data["text"])) {
$dao = new Dao();
$dao->add_score($score_data);
}
break;
case '1108' :
$score_data["text"] = 'Malus Énigme Libération 4';
$score_data["points"] = -25;
if(isAlreadySolved($team, $score_data["text"])) {
$dao = new Dao();
$dao->add_score($score_data);
}
break;
case 'rose' :
$data["name"] = "enigme-liberation-4";
$score_data["text"] = 'Énigme Libération 4';
$score_data["points"] = 100;
if(isLastEnigmaSolved('Énigme Libération 3-1') && isLastEnigmaSolved('Énigme Libération 3-2')) {
if($date < 1628613000) {
$data["info"] = "<h2>Énigme Libération 4</h2>
<p><a href=\"assets/enigmes/Liberation/FinE.png\">On vous demande un mot de passe pour rentrer</a></p>";
} else {
$data["info"] = "<h2>Énigme Libération 4</h2>
<p><a href=\"assets/enigmes/Liberation/FinE.png\">On vous demande un mot de passe pour rentrer</a></p>";
}
if(isFirstTeamToSolve($score_data)) {
$dao = new Dao();
$dao->add_score($score_data);
}
echo json_encode($data, JSON_FORCE_OBJECT);
}
break;
case 'Presque' :
$data["name"] = "enigme-liberation-5";
$score_data["text"] = 'Énigme Libération 5';
$score_data["points"] = 50;
if(isLastEnigmaSolved('Énigme Libération 4')) {
if($date < 1628613000) {
$data["info"] = "<h2>Énigme Libération 5</h2>
<p>Bien joué ! Attendez demain pour la suite !</p>";
} else {
$data["info"] = "<h2>Énigme Libération 5</h2>
<p>Bien joué ! Attendez demain pour la suite !</p>";
}
if(isFirstTeamToSolve($score_data)) {
$dao = new Dao();
$dao->add_score($score_data);
}
echo json_encode($data, JSON_FORCE_OBJECT);
}
break;
default:
$data["name"] = null;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 305 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 73 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 395 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 281 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 193 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 395 KiB

Binary file not shown.