Skip to content

rikialamputra/mangpay

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 

Repository files navigation

Hotspot Billing MVP (PHP 8.2 + MySQL)

Minimal voucher-based hotspot system with user registration, balance, voucher generation, activation, and basic Mikrotik integration (address-list via SSH).

Requirements

  • 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)

Quickstart

  1. 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.

  2. Copy src/config/config.php and set DB + Mikrotik settings.

  3. Serve the app (Apache DocumentRoot to src/public/ or Nginx root there).

  4. 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';
  5. (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)"
    
  6. Set mikrotik.enabled=true in config to auto-allow user IPs on activation.

Notes

  • 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

About

Billing by Alamhost

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors