mirror of
https://github.com/appen-isen/projet-cal.git
synced 2026-01-18 16:47:38 +01:00
feat: add ctf flag
This commit is contained in:
@@ -61,6 +61,24 @@ func getDayAndLink(c *gin.Context) {
|
|||||||
c.JSON(200, LinkAndDate{Link: link, Date: date})
|
c.JSON(200, LinkAndDate{Link: link, Date: date})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getLegacyLink(c *gin.Context) {
|
||||||
|
requestedDate := c.Query("date")
|
||||||
|
currentDate := time.Now().Format("02-01-2006")
|
||||||
|
|
||||||
|
// Si la date demandée n'est pas la date du jour -> FLAG
|
||||||
|
if requestedDate != "" && requestedDate != currentDate {
|
||||||
|
c.JSON(200, LinkAndDate{
|
||||||
|
Link: "CTF{55460e0d0aec5088a008ce54e035e67f}",
|
||||||
|
Date: requestedDate,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// Sinon, comportement normal (on réutilise la logique de getDayAndLink ou on redirige)
|
||||||
|
// Pour faire simple ici, on appelle la même logique de récupération
|
||||||
|
getDayAndLink(c)
|
||||||
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
router := gin.Default()
|
router := gin.Default()
|
||||||
@@ -73,6 +91,7 @@ func main() {
|
|||||||
|
|
||||||
// API route
|
// API route
|
||||||
router.GET("/api/get_day", getDayAndLink)
|
router.GET("/api/get_day", getDayAndLink)
|
||||||
|
router.GET("/api/get_link", getLegacyLink)
|
||||||
|
|
||||||
// Serve the index.html file for all other routes
|
// Serve the index.html file for all other routes
|
||||||
router.NoRoute(func(c *gin.Context) {
|
router.NoRoute(func(c *gin.Context) {
|
||||||
|
|||||||
@@ -4,6 +4,11 @@ const apiUrl = "https://calendrier.appen.fr/api/get_day";
|
|||||||
// Fonction pour récupérer les données depuis l'API
|
// Fonction pour récupérer les données depuis l'API
|
||||||
async function fetchDayData() {
|
async function fetchDayData() {
|
||||||
try {
|
try {
|
||||||
|
/* Ancienne version
|
||||||
|
const dateAuj = new Date().toISOString().slice(0, 10).split("-").reverse().join("-");
|
||||||
|
const apiUrlLegacy = "https://calendrier.appen.fr/api/get_link?date=" + dateAuj;
|
||||||
|
const response = await fetch(apiUrlLegacy);
|
||||||
|
*/
|
||||||
const response = await fetch(apiUrl);
|
const response = await fetch(apiUrl);
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
@@ -29,7 +34,7 @@ function initCalendar() {
|
|||||||
|
|
||||||
if (!dayData) return; // Si l'appel API échoue, on ne fait rien
|
if (!dayData) return; // Si l'appel API échoue, on ne fait rien
|
||||||
|
|
||||||
|
|
||||||
const todayDate = parseInt(dayData.date.split("-")[0], 10); // Extraire le jour de la date (ex : "27")
|
const todayDate = parseInt(dayData.date.split("-")[0], 10); // Extraire le jour de la date (ex : "27")
|
||||||
const link = dayData.link;
|
const link = dayData.link;
|
||||||
|
|
||||||
@@ -37,7 +42,7 @@ function initCalendar() {
|
|||||||
if (link)
|
if (link)
|
||||||
showModal(`Voici votre lien du jour : <a href="${link}" target="_blank">${link}</a>`);
|
showModal(`Voici votre lien du jour : <a href="${link}" target="_blank">${link}</a>`);
|
||||||
else
|
else
|
||||||
showModal("Ce lien n'existe pas. Si cela n'est pas normale, veuillez contacter <a href='https://instagram.com/appen_isen'>Appen sur instagram</a>.");
|
showModal("Ce lien n'existe pas. Si cela n'est pas normale, veuillez contacter <a href='https://instagram.com/appen_isen'>Appen sur instagram</a>.");
|
||||||
} else {
|
} else {
|
||||||
showModal("Ce lien n'est pas encore ou plus disponible !");
|
showModal("Ce lien n'est pas encore ou plus disponible !");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user