Minimal voucher-based hotspot system with user registration, balance, voucher generation, activation, and basic Mikrotik integration (address-list via SSH).
- PHP 8.2 with extensions:
pdo_mysql,openssl - MySQL 5.7+ (4.1+ in theory, but recommend 5.7+)
- Web server: Apache or Nginx
- (Optional)
sshpass+ SSH access to Mikrotik (for automatic allow/deny)
-
Create DB & tables:
CREATE DATABASE hotspot_mvp CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci; CREATE USER 'hotspot_user'@'localhost' IDENTIFIED BY 'change_me'; GRANT ALL PRIVILEGES ON hotspot_mvp.* TO 'hotspot_user'@'localhost'; FLUSH PRIVILEGES;
Then import
database.sql. -
Copy
src/config/config.phpand set DB + Mikrotik settings. -
Serve the app (Apache DocumentRoot to
src/public/or Nginx root there). -
Create an admin user manually:
INSERT INTO users (username, email, password_hash, role, balance) VALUES ('admin', 'admin@example.com', PASSWORD('not_used'), 'admin', 0); -- Update password_hash using PHP: -- php -r "echo password_hash('admin123', PASSWORD_DEFAULT), PHP_EOL;" -- then: UPDATE users SET password_hash = '<paste_hash_here>' WHERE username='admin';
-
(Optional) Mikrotik firewall setup example:
/ip firewall address-list add list=hotspot-allow address=192.0.2.0/24 comment="Allowed voucher users" /ip firewall filter add chain=forward src-address-list=hotspot-allow action=accept comment="Allow voucher users" /ip firewall filter add chain=forward action=drop comment="Default drop (adjust for your network)" -
Set
mikrotik.enabled=truein config to auto-allow user IPs on activation.
- This is an MVP: no CSRF tokens, minimal validation, and simple auth. Use HTTPS in production.
- For bandwidth limits, apply queues in Mikrotik per IP or per address-list as a next step.
- Deactivation/expiry cleanup (cron) is not included; add a cron to remove expired IPs from address-list.
# Example cron (runs every 5 minutes) to output expired IPs:
# php /var/www/hotspot-mvp/tools/expire_cleanup.php