Update 34 files

- /nfc/README.md
- /nfc/clean_old_logs.sh
- /nfc/clockin.py
- /nfc/emptycards.py
- /nfc/sync_clocks.sh
- /piservices/Dockerfile
- /piservices/Portainer-lamp-stack.env
- /piservices/Portainer-lamp-stack.yaml
- /piservices/README.md
- /piservices/avahi-alias.service
- /piservices/clockpy.service
- /piservices/emptycards.service
- /piservices/nfc-sync.service
- /piservices/test.sh
- /www/404
- /www/get-table-data.php
- /www/habiwan copy.png
- /www/habiwan.png
- /www/index.php
- /www/log_swipe.php
- /www/manage_data.php
- /www/manifest.json
- /www/names.csv
- /www/network_audit.csv
- /www/network-tracker.html
- /www/nfc_debug.log
- /www/scanner.html
- /www/staff_names.php
- /www/times.csv
- /www/check_update.php
- /www/dev.php
- /www/favicon.png
- /www/JsBarcode.all.min.js
- /www/README.md
This commit is contained in:
jpd committed 2026-07-24 14:37:45 +01:00
1 parent 10824ab851
commit a201d5d7ac
34 files changed
+9453

No files matched your search

+7
View File
@@ -0,0 +1,7 @@
FROM php:8.2-apache
# Install the missing MySQL driver
RUN docker-php-ext-install pdo pdo_mysql
# Align www-data with your host's user ID to eliminate the permission ping-pong
RUN usermod -u 1000 www-data && groupmod -g 1000 www-data
+5
View File
@@ -0,0 +1,5 @@
LAMPAPP=lampapp
LAMPUSER=lampuser
LAMPPASSWORD=lamppassword
MYSQL_ROOT_HOST=%
MYSQL_ROOT_PASSWORD=rootpassword
+50
View File
@@ -0,0 +1,50 @@
services:
web:
image: custom-lamp-php
container_name: lamp-web
restart: unless-stopped
ports:
- 8080:80
volumes:
- /home/YOUR_USER/Code/lamp/www:/var/www/html
- /home/YOUR_USER/Code/lamp/apache/000-default.conf:/etc/apache2/sites-available/000-default.conf
environment:
MYSQL_HOST: db
MYSQL_DATABASE: ${LAMPAPP}
MYSQL_USER: ${LAMPUSER}
MYSQL_PASSWORD: ${LAMPPASSWORD}
depends_on:
- db
networks:
- lamp-net
db:
image: mysql:8.0
container_name: lamp-db
restart: unless-stopped
environment:
MYSQL_ROOT_PASSWORD: ${MYSQL_ROOT_PASSWORD}
MYSQL_ROOT_HOST: ${MYSQL_ROOT_HOST}
MYSQL_DATABASE: ${LAMPAPP}
MYSQL_USER: ${LAMPUSER}
MYSQL_PASSWORD: ${LAMPPASSWORD}
volumes:
- db_data:/var/lib/mysql
- mysql_init:/docker-entrypoint-initdb.d
networks:
- lamp-net
adminer:
image: adminer:latest
container_name: lamp-adminer
restart: unless-stopped
ports:
- 8081:8080
environment:
ADMINER_DEFAULT_SERVER: db
networks:
- lamp-net
volumes:
db_data:
mysql_init:
networks:
lamp-net:
driver: bridge
+31
View File
@@ -0,0 +1,31 @@
Use this folder as an example of what services you should install in your pi:
- Docker (install Portainer too)
- avahi-alias (optional - create a hostname alias for LAN testing)
- clockpy.service (this runs the nfc script in memory ready to be read)
- emptycards.service (used initially to write a csv file with all NFC codes in it)
- nfc-sync.service (when NFS card swiped on pi-NFC-reader it copies csv files across NAS and www machine - obsolete)
During prototyping I ran the services on this folder on the pi so they run in term the shell scripts
as you can see from the nfc folder... subject to your own opinion / implementation...
UPDATE: the latest version can be run on the same pi via docker Portainer lamp stack:
Optional services you could run on your machine that runs the webapp.
For me, this is was decomissioned "upcycled" consumer grade PC that I installed PVE on for prototyping. But now with the latest version you can simply run www and mysql on the arm64 portainer docker compose and env...
This was initially on an Ubuntu VM for me that runs docker-compose-lamp with phpmyadmin. Since phpmyadmin could not run on my pi I decided to use adminer instead.
This gives me the quick and easy way to run php, but it was "overkill" as I was planning to use mysql, and now that I do I migrated to docker on pi.
and now! everybody! no more clucky ugly unsatisfactory silly csv files... running on MySQL now!!!
The additional service that I ended up wanting on my setup was to use the avahi capabilities to give the www enpoint
a "nickname" like e.g. http://piclock.local or just simple http://piclock works for me too...
At the same time it keeps your original "uvm" or "rpi" hostname endpoint alive, up to you if you want this or not...
UPDATE: modified so it runs on a Pi itself too... if you can run docker on the pi you can install Portainer and use this new lamp stack that uses adminer instead of phpmyadmin... that was the big stopper I unlocked.
+14
View File
@@ -0,0 +1,14 @@
[Unit]
Description=Avahi mDNS Alias for piclock.local
After=avahi-daemon.service
Requires=avahi-daemon.service
[Service]
Type=simple
# This service is the only service that (if needed/wanted) has to run on the UbuntuVM or PC that has the php code...
# Adjust the IP !
ExecStart=/usr/bin/avahi-publish -a -R piclock.local 192.168.X.X
Restart=always
[Install]
WantedBy=multi-user.target
+12
View File
@@ -0,0 +1,12 @@
[Unit]
Description=PiClock System raw data writing service
After=multi-user.target
[Service]
Type=simple
# Remember to adjust the paths!
ExecStart=/usr/bin/python /home/YOURPIUSER/nfc/clockin.py
Restart=always
[Install]
WantedBy=multi-user.target
+12
View File
@@ -0,0 +1,12 @@
[Unit]
Description=PiClock Empty card assist tool
After=multi-user.target
[Service]
Type=simple
# Remember to adjust the path!
ExecStart=/usr/bin/python /home/YOURPIUSER/nfc/emptycards.py
Restart=always
[Install]
WantedBy=multi-user.target
+14
View File
@@ -0,0 +1,14 @@
[Unit]
Description=Sync NFC logs on times.csv modification
After=network.target
[Service]
Type=simple
# Remember to adjust the path and user!
User=YOURPIUSER
ExecStart=/home/YOURPIUSER/nfc/sync_clocks.sh
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
+58
View File
@@ -0,0 +1,58 @@
#!/bin/bash
# Configuration
CONTAINER_NAME="lamp-db"
DB_NAME="lampapp"
DB_USER="root"
DB_PASS="rootpassword"
# --- Debounce Logic ---
DEBOUNCE_FILE="/tmp/last_swipe_trigger"
DEBOUNCE_SECONDS=60
CURRENT_EPOCH=$(date +%s)
# Check if the debounce file exists
if [[ -f "$DEBOUNCE_FILE" ]]; then
LAST_EPOCH=$(cat "$DEBOUNCE_FILE")
TIME_DIFF=$((CURRENT_EPOCH - LAST_EPOCH))
# If less than 60 seconds have passed, exit silently without logging
if [[ "$TIME_DIFF" -lt "$DEBOUNCE_SECONDS" ]]; then
exit 0
fi
fi
# Update the debounce file with the new trigger time
echo "$CURRENT_EPOCH" > "$DEBOUNCE_FILE"
# ----------------------
# Get the current time from the Pi host (Europe/London)
CURRENT_TIME=$(date '+%Y-%m-%d %H:%M:%S')
# SQL Logic
QUERY="
CREATE TABLE IF NOT EXISTS names (
id INT AUTO_INCREMENT PRIMARY KEY,
CardID VARCHAR(12) NOT NULL UNIQUE,
name VARCHAR(100) DEFAULT NULL
);
CREATE TABLE IF NOT EXISTS times (
UID VARCHAR(12) NOT NULL,
temp FLOAT,
timestamp DATETIME
);
/* Insert the test into names ONLY if it doesn't already exist */
INSERT INTO names (CardID, name)
SELECT 'test001', 'zz_manual_test' FROM DUAL
WHERE NOT EXISTS (
SELECT 1 FROM names WHERE CardID = 'test001'
);
/* Always log the time entry */
INSERT INTO times (UID, temp, timestamp) VALUES ('test001', 56.0, '$CURRENT_TIME');
"
# Execute inside the container
docker exec "$CONTAINER_NAME" mysql -u"$DB_USER" -p"$DB_PASS" "$DB_NAME" -e "$QUERY"