Repository navigation
Boutique Bytecrafter v0.1.2 is here
Release Notes — PhPstrap v0.1.2
TL;DR: This release makes the dashboard far more robust and “drop-in” friendly. The menu loader now works with any style of includes/admin-menu.php, auth and session handling are stricter, database detection is safer, and the UI shows clearer system/security metrics with better fallbacks.
Highlights
Universal menu loader
Works whether your includes/admin-menu.php defines a function, returns an array/string, or echoes HTML. The loader auto-detects and uses it—no more hard-coded fallback menu.
Stricter, safer auth flow
Honors requireAdminAuth() when present, supports AJAX detection (returns JSON instead of redirect), and preserves a ?redirect= back to the current page after login.
Hardened database connection
Uses getDbConnection() when available or falls back to PDO with sane defaults. Clearly marks Database Connected/Offline in the header and avoids hard crashes when DB is down.
Deeper, schema-aware stats
Expanded cards/totals for users, verification, 2FA, tokens, affiliate clicks/signups, invites, withdrawals, token purchases, revenue, API resellers, password resets, etc.
Clearer system & security overview
Pulls MySQL version, DB size/table count, PhPstrap version & install date (from settings), plus security signals like locked/unverified accounts and last admin activity.
UI/UX polish
Modern gradient sidebar, mobile sidebar toggle, stat cards, version badge, database status pill, and a lightweight “live time” update.
What Changed (Detailed)
Menu loading
Searches multiple paths for admin-menu.php.
Supports four patterns:
function renderAdminMenu($current) returning HTML
return [ ... ] (array of items)
return "
echo
Renders whichever is found first; otherwise uses a fallback.
Inserts an HTML comment noting the menu source & path used for easy debugging.
Auth & session
Consolidated checks for admin_id, admin_logged_in, or user_id + is_admin.
Honors requireAdminAuth() if available (with try/catch).
AJAX requests receive JSON { error, redirect } rather than a full redirect.
Error handling & resilience
safeInclude() and many code paths now catch Throwable (not just Exception).
Tolerant defaults if config/app/auth files are missing.
Will render the dashboard skeleton even with DB offline, plus a visible warning.
Database & metrics
PDO fallback uses strict options (exceptions, native prepares, associative fetch).
System info pulls:
SELECT VERSION() for MySQL
DB size & table count from information_schema
settings keys: PhPstrap_version, installation_date
Business & security metrics expanded with widely used tables:
affiliate_clicks, affiliate_signups, invites, withdrawals,
token_purchases, api_resellers, password_resets, user_tokens, admin_activity_log
User metrics include membership breakdown (free, premium, lifetime), recent logins, and growth windows (today/week/month).
UI
New stat cards (primary/success/warning/info variants).
Responsive sidebar with mobile toggle button injection.
Version badge + DB status pill in header.
“Recent Admin Activity” feed with icons and humanized timestamps.
Fixes
Eliminates 500s caused by menu includes that echo output or don’t define a function.
Avoids PHP notices for undefined constants (e.g., DB_PASS) in PDO DSN setup.
General hardening around includes, sessions, and DB absence.
Compatibility & Upgrade Notes
No breaking schema changes; queries assume the tables listed above exist. Missing tables simply result in zeroed metrics and log warnings.
Ensure your includes/admin-menu.php uses any of the supported patterns. The loader will pick it up automatically.
Optional: add PhPstrap_version and installation_date rows in your settings table if you want those shown.
Housekeeping
Code style unified, escaping via htmlspecialchars() where appropriate.
Lightweight client-side helpers (auto-refresh hook, live time update) included but non-intrusive.