「🏗️」 wip: work in progress, not done yet.
This commit is contained in:
10
Makefile
Normal file
10
Makefile
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
all:
|
||||||
|
docker compose up --build
|
||||||
|
|
||||||
|
re: clean all
|
||||||
|
|
||||||
|
clean:
|
||||||
|
docker system prune -af
|
||||||
|
docker volume prune -af
|
||||||
|
|
||||||
|
.PHONY: clean re all
|
51
docker-compose.yml
Normal file
51
docker-compose.yml
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
services:
|
||||||
|
web-server:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: ./docker/web/Dockerfile
|
||||||
|
container_name: pressf-web
|
||||||
|
volumes:
|
||||||
|
- site:/var/www/html
|
||||||
|
ports:
|
||||||
|
- 9001:80
|
||||||
|
|
||||||
|
networks:
|
||||||
|
#- traefik-back
|
||||||
|
- pressf
|
||||||
|
depends_on:
|
||||||
|
- php
|
||||||
|
labels:
|
||||||
|
- traefik.enable=true
|
||||||
|
- traefik.docker.network=traefik-back
|
||||||
|
|
||||||
|
- traefik.http.routers.pressf.rule=Host(`trans.kanel.ovh` ,`pressf.kanel.ovh`)
|
||||||
|
- traefik.http.routers.pressf.entrypoints=websecure
|
||||||
|
- traefik.http.routers.pressf.tls=true
|
||||||
|
- traefik.http.routers.pressf.tls.certresolver=letsencrypt
|
||||||
|
- traefik.http.routers.pressf.service=pressf
|
||||||
|
- traefik.http.services.pressf.loadbalancer.server.port=80
|
||||||
|
|
||||||
|
php:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: docker/php/Dockerfile
|
||||||
|
container_name: pressf-php
|
||||||
|
volumes:
|
||||||
|
- site:/var/www/html
|
||||||
|
- db:/var/www/db
|
||||||
|
networks:
|
||||||
|
- pressf
|
||||||
|
|
||||||
|
networks:
|
||||||
|
#traefik-back:
|
||||||
|
#external: true
|
||||||
|
pressf:
|
||||||
|
name: pressf
|
||||||
|
external: false
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
db:
|
||||||
|
name: pressf-db
|
||||||
|
site:
|
||||||
|
name: pressf-site
|
||||||
|
|
8
docker/php/Dockerfile
Normal file
8
docker/php/Dockerfile
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
FROM php:8.4-fpm-alpine
|
||||||
|
|
||||||
|
# Installez les dépendances nécessaires pour la compilation d'extensions PHP
|
||||||
|
RUN apk --no-cache add \
|
||||||
|
sqlite \
|
||||||
|
sqlite-dev
|
||||||
|
|
||||||
|
RUN mkdir -p /var/www/db && chown -R www-data:www-data /var/www/db
|
23
docker/web/Dockerfile
Normal file
23
docker/web/Dockerfile
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
FROM nginx:alpine
|
||||||
|
|
||||||
|
RUN apk update && apk add --no-cache \
|
||||||
|
php84 \
|
||||||
|
php84-fpm \
|
||||||
|
php84-opcache \
|
||||||
|
php84-mysqli \
|
||||||
|
php84-pdo \
|
||||||
|
php84-pdo_mysql \
|
||||||
|
php84-json \
|
||||||
|
php84-cli \
|
||||||
|
php84-common \
|
||||||
|
php84-mbstring \
|
||||||
|
php84-xml \
|
||||||
|
php84-curl
|
||||||
|
|
||||||
|
COPY ./site /var/www/html
|
||||||
|
COPY ./docker/web/http-conf/pressf.conf /etc/nginx/conf.d/default.conf
|
||||||
|
|
||||||
|
RUN mkdir -p /var/www/db
|
||||||
|
RUN chown -R nginx:nginx /var/www/db
|
||||||
|
|
||||||
|
VOLUME ["/var/www/html", "/var/db"]
|
36
docker/web/http-conf/pressf.conf
Normal file
36
docker/web/http-conf/pressf.conf
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
server {
|
||||||
|
listen 0.0.0.0:80; # Écouter sur toutes les interfaces réseau (IPv4)
|
||||||
|
|
||||||
|
# Répertoire de travail de Nginx
|
||||||
|
root /var/www/html;
|
||||||
|
index index.php index.html;
|
||||||
|
|
||||||
|
# Gestion des fichiers PHP avec le socket Unix
|
||||||
|
location ~ \.php$ {
|
||||||
|
fastcgi_pass php:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
|
||||||
|
# Paramètre de chemin de fichier pour le traitement PHP
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
fastcgi_param DOCUMENT_ROOT $document_root;
|
||||||
|
|
||||||
|
# Inclure les paramètres FastCGI standard
|
||||||
|
include fastcgi_params;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Serveur de fichiers statiques (images, CSS, JS, etc.)
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Gestion du favicon
|
||||||
|
location = /favicon.ico {
|
||||||
|
root /var/www/html;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Gestion des erreurs 404
|
||||||
|
error_page 404 /404.html;
|
||||||
|
location = /404.html {
|
||||||
|
root /usr/share/nginx/html;
|
||||||
|
}
|
||||||
|
}
|
BIN
site/favicon.ico
Normal file
BIN
site/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
15
site/fetchf.php
Normal file
15
site/fetchf.php
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
<?php
|
||||||
|
// Créer une connexion à la base de données SQLite
|
||||||
|
$db = new SQLite3('/var/www/db/pressf.db');
|
||||||
|
|
||||||
|
// Ouvrir une nouvelle connexion pour récupérer le compteur actuel
|
||||||
|
$result = $db->query('SELECT count FROM respect_count WHERE id = 1');
|
||||||
|
$row = $result->fetchArray(SQLITE3_ASSOC);
|
||||||
|
$current_count = $row['count'];
|
||||||
|
|
||||||
|
// Fermer la connexion
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
// Afficher la valeur actuelle du compteur
|
||||||
|
echo $current_count;
|
||||||
|
?>
|
108
site/index.html
Normal file
108
site/index.html
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="fr">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Press F to Pay Respect</title>
|
||||||
|
<link rel="icon" href="favicon.ico" type="image/x-icon">
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
text-align: center;
|
||||||
|
background-color: #f4f4f4;
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
h1 {
|
||||||
|
color: #555;
|
||||||
|
}
|
||||||
|
.image-container {
|
||||||
|
margin: 20px;
|
||||||
|
}
|
||||||
|
.kanel {
|
||||||
|
display: block;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
width: 20%;
|
||||||
|
}
|
||||||
|
.button {
|
||||||
|
font-size: 20px;
|
||||||
|
padding: 10px 20px;
|
||||||
|
background-color: #333;
|
||||||
|
color: white;
|
||||||
|
border: none;
|
||||||
|
cursor: pointer;
|
||||||
|
margin-top: 30px;
|
||||||
|
}
|
||||||
|
.button:focus {
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
.disabled {
|
||||||
|
background-color: #777;
|
||||||
|
cursor: not-allowed;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<h1>Press F to Pay Respect</h1>
|
||||||
|
|
||||||
|
<div class="image-container">
|
||||||
|
<img src="kanel.jpg" alt="Kanel" class="kanel">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p>Current count: <span id="countDisplay"></span></p>
|
||||||
|
|
||||||
|
<button class="button" id="payRespectButton">Press F</button>
|
||||||
|
<div id="error-message" style="color: red; margin-top: 20px;"></div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// Fonction pour envoyer à la base de données
|
||||||
|
function sendToDatabase() {
|
||||||
|
fetch('pressf.php')
|
||||||
|
.then(response => response.text())
|
||||||
|
.then(data => {
|
||||||
|
updateCount(data); // Mettre à jour le compteur affiché
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fonction pour mettre à jour le compteur affiché
|
||||||
|
function updateCount(newCount) {
|
||||||
|
document.getElementById('countDisplay').innerText = newCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fonction pour désactiver le bouton et empêcher le spam
|
||||||
|
function disableButton() {
|
||||||
|
const button = document.getElementById("payRespectButton");
|
||||||
|
button.disabled = true;
|
||||||
|
button.classList.add("disabled");
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
button.disabled = false;
|
||||||
|
button.classList.remove("disabled");
|
||||||
|
}, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gestion du clic sur le bouton
|
||||||
|
document.getElementById("payRespectButton").addEventListener("click", function() {
|
||||||
|
sendToDatabase();
|
||||||
|
disableButton(); // Désactiver le bouton après un clic
|
||||||
|
});
|
||||||
|
|
||||||
|
// Gestion de la touche "F"
|
||||||
|
document.addEventListener("keydown", function(event) {
|
||||||
|
if ((event.key === "f" || event.key === "F") && !document.getElementById("payRespectButton").disabled) {
|
||||||
|
sendToDatabase();
|
||||||
|
disableButton(); // Désactiver le bouton après un clic
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Initialisation de la page : récupérer et afficher le compteur
|
||||||
|
window.onload = function() {
|
||||||
|
fetch('fetchf.php')
|
||||||
|
.then(response => response.text())
|
||||||
|
.then(data => updateCount(data));
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
BIN
site/kanel.jpg
Normal file
BIN
site/kanel.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 244 KiB |
51
site/pressf.php
Normal file
51
site/pressf.php
Normal file
@ -0,0 +1,51 @@
|
|||||||
|
<?php
|
||||||
|
session_start(); // Start the session
|
||||||
|
|
||||||
|
$timeout_duration = 10; // Timeout period in seconds (adjustable)
|
||||||
|
|
||||||
|
if (isset($_SESSION['last_click_time'])) {
|
||||||
|
$time_diff = time() - $_SESSION['last_click_time']; // Time difference since last click
|
||||||
|
|
||||||
|
if ($time_diff < $timeout_duration) {
|
||||||
|
// If the time difference is less than the cooldown period, deny the action
|
||||||
|
die("Please wait a moment before clicking again.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Créer une connexion à la base de données SQLite
|
||||||
|
$db = new SQLite3('/var/www/db/pressf.db');
|
||||||
|
|
||||||
|
// Créer la table si elle n'existe pas
|
||||||
|
$db->exec('CREATE TABLE IF NOT EXISTS respect_count (
|
||||||
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
|
count INTEGER NOT NULL DEFAULT 0
|
||||||
|
)');
|
||||||
|
|
||||||
|
// Vérifier si le premier enregistrement existe, sinon l'insérer
|
||||||
|
$result = $db->query('SELECT * FROM respect_count WHERE id = 1');
|
||||||
|
if (!$result->fetchArray(SQLITE3_ASSOC)) {
|
||||||
|
// Si le record avec id = 1 n'existe pas, on l'insère
|
||||||
|
$db->exec('INSERT INTO respect_count (id, count) VALUES (1, 0)');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mettre à jour le nombre dans la base de données
|
||||||
|
$db->exec('UPDATE respect_count SET count = count + 1 WHERE id = 1');
|
||||||
|
|
||||||
|
// Fermer la connexion
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
// Ouvrir une nouvelle connexion pour afficher le compteur
|
||||||
|
$db = new SQLite3('/var/www/db/pressf.db');
|
||||||
|
$result = $db->query('SELECT count FROM respect_count WHERE id = 1');
|
||||||
|
$row = $result->fetchArray(SQLITE3_ASSOC);
|
||||||
|
$current_count = $row['count'];
|
||||||
|
$db->close();
|
||||||
|
|
||||||
|
|
||||||
|
// Store the current time in the session after the action is completed
|
||||||
|
|
||||||
|
$_SESSION['last_click_time'] = time();
|
||||||
|
|
||||||
|
// Afficher la valeur actuelle du compteur
|
||||||
|
echo $current_count;
|
||||||
|
?>
|
Reference in New Issue
Block a user