mirror of
https://codeberg.org/PostERG/xamxam.git
synced 2026-05-06 19:19:19 +02:00
72daf46c466b6e3b656bd1ff889d6886abf3342b
Full analysis of PHP and SQLite layer covering: Performance: - WAL mode + cache_size pragma missing from Database constructor - Separate is_published/year indexes force temp B-tree sort on every public query - v_theses_full materialised as CTE on every query, indexes never used by view - getAllPublishedTheses() runs full 15-join view just for the author name index PHP / Database.php: - 5 dead CRUD helpers (getOrientationId etc.) never called anywhere - 13 alias methods doubling every lookup; pick canonical names and remove - getPDO()/getConnection() leaking to 8 call-sites with raw SQL that belongs in DB layer - Unparameterised query in edit.php line 155 (SQL injection, fix immediately) - sanitize_string() HTML-escapes at write time — stores & in DB, breaks search/export - Dead variable $problematique in formulaire.php (read from POST, never used) - setThesisJury() has no transaction guard of its own - DB config auto-detection silently uses test.db if file exists locally Maintainability: - edit.php (530 lines) mixes display + POST + file upload — extract action file - Banner upload logic copy-pasted between formulaire.php and edit.php - Junction-table loops open-coded in every action; add setThesisLanguages/Formats/Tags - RateLimit writes a JSON file on every public request - __wakeup() throws from public method (PHP 8 deprecation)
posterg
Répertoire des travaux de fin d'études de l'ERG (École de Recherche Graphique).
Requirements
- PHP 8.4
- SQLite3 (
php8.4-sqlite3) - nginx (production)
Project structure
posterg/
├── public/ # DocumentRoot — web-accessible only
│ ├── admin/ # Admin panel (session-authenticated)
│ ├── assets/ # CSS, fonts, icons
│ ├── media.php # Controlled file serving (covers, PDFs)
│ └── *.php # Public pages (index, search, tfe, apropos)
├── src/ # PHP classes (not web-accessible)
│ ├── AdminAuth.php
│ ├── Database.php
│ ├── RateLimit.php
│ └── config.php
├── templates/ # Shared PHP template partials
├── config/ # Bootstrap and credentials (not web-accessible)
├── storage/ # Database and uploaded files (not web-accessible)
│ ├── schema.sql
│ ├── test.db
│ └── fixtures/
├── tests/
├── scripts/ # Dev and server management scripts
│ ├── setup-dev.sh
│ ├── deploy-server.sh # Run on server with sudo to apply nginx config
│ └── manage-admin-users.sh # Run on server with sudo to manage htpasswd
└── nginx/ # nginx config and reference files
└── posterg.conf
Uploaded files (PDFs, covers) live in storage/ — outside the webroot — and are
served exclusively through public/media.php, which validates paths and MIME types.
Development
just setup # first-time: installs dev dependencies
just serve # http://localhost:8000 (public) and /admin/
just test # run test suite
Admin credentials in development are set via config/admin_credentials.php
(see config/admin_credentials.example.php).
Deployment
Files are pushed to the server with rsync — there is no repo on the remote.
just deploy # rsync app files → posterg:/var/www/posterg/
just deploy-db # push local test.db → remote (only if remote DB is absent)
deploy-db refuses to run if a database already exists on the server, to avoid
accidental overwrites of production data.
First-time server setup
ssh posterg
sudo mkdir -p /var/www/posterg
sudo chown www-data:posterg /var/www/posterg
sudo chmod 775 /var/www/posterg
exit
Then deploy once, copy nginx config, and apply:
just deploy
rsync -v nginx/posterg.conf posterg:/tmp/posterg.conf
ssh posterg "sudo bash /var/www/posterg/scripts/deploy-server.sh"
ssh posterg "sudo systemctl reload nginx"
Admin users (htpasswd)
ssh posterg "sudo bash /var/www/posterg/scripts/manage-admin-users.sh"
Security notes
- Admin panel protected by nginx
auth_basic+ PHP session (AdminAuth) - Uploads stored outside webroot, served via controlled
media.php - Rate limiting on public search (
src/RateLimit.php) - See
docs/TODO.SECURITY.mdfor outstanding items
Description
Languages
PHP
80.5%
CSS
14.9%
Shell
2.8%
JavaScript
1.3%
Just
0.5%