How connect2sazad/url_shortener works
Purpose and entry points
This is a PHP URL-shortening and QR-code management application with public short-link handling and an authenticated administration area. Public-facing entry points are index.php, new_shortlink.php, and suspended.php; Apache routing is likely mediated by .htaccess. The internal application begins at in/index.php, with dedicated login, registration, and logout endpoints.
Runtime and persistence boundary
The application runs as server-rendered PHP behind Apache (.htaccess, in/.htaccess). Shared runtime configuration, constants, database access, and common behavior are centralized in config.php, constants.php, db.php, and functions.php. Database schema/bootstrap material is supplied as url_shortener.sql; all durable URL, QR, user, profile, and status state is expected to cross the db.php boundary.
Authentication and account lifecycle
Authentication is separated into page rendering and form processing: in/login/index.php presents login while in/login/auth.php handles authentication. Registration follows the same shape in in/register/index.php and in/register/signup.php; the README indicates an email-to-OTP verification step is intended. Session termination is handled by in/logout/index.php. Account/profile mutation is exposed through in/actions/update_profile.php.
Internal portal and role-oriented views
in/index.php is the authenticated portal shell, routing users to dashboard and management screens. Dashboard and account views include in/pages/dashboard.php and in/pages/my-account.php. The page set distinguishes user-facing records from administrative records—for example, in/pages/users.php, in/pages/users-su.php, in/pages/admin-su.php, in/pages/users-qrs.php, and in/pages/admin-qrs.php—suggesting separate user/admin scopes rather than a standalone API.
Short-link lifecycle
Short URLs are created through in/pages/create-short-url.php and processed by in/actions/shorten.php. Existing records are listed in in/pages/shortened-urls.php and controlled through focused mutation actions: in/actions/url_enable.php, in/actions/url_disable.php, in/actions/url_delete.php, and in/actions/url_change_validity.php. Public requests reaching root-level handlers (index.php, potentially new_shortlink.php) resolve a short code, enforce enabled/validity state, and redirect or surface suspension behavior through suspended.php.
QR-code lifecycle
QR creation and display are centered on in/pages/create-qr.php and in/pages/created-qrs.php, with persistence performed by in/actions/qrsaver.php. QR records have independent status/deletion operations in in/actions/qr_enable.php, in/actions/qr_disable.php, and in/actions/qr_delete.php. Client-side QR rendering support is bundled at in/assets/extensions/qrcode/qrcode.js, so QR generation may span browser rendering plus PHP-side record management.
Front-end assets and dependencies
The portal uses bundled static assets under in/assets/, notably application scripts in/assets/js/app.js and styles in/assets/css/main/app.css. It includes packaged UI/data-table dependencies such as DataTables (in/assets/extensions/datatables.net-bs5/) and notification support (in/assets/extensions/notify/notify.js). These are local assets, not evidence of a build-time Node service or external SaaS dependency.
Main entry points: in/index.php Portal shell · db.php Database adapter · index.php Public link handlers · auth.php Login and registration
Components 16
Public Link Handling
- Apache routing · Routes public and internal PHP requests.
.htaccess - Public link handlers · Resolve short codes, redirect targets, or show suspension.
index.php - Suspension page
suspended.php
PHP Runtime
- Runtime bootstrap · Provides configuration, constants, shared behavior, and database access.
config.php - Database adapter · Durable state crosses this database boundary.
db.php
Authenticated Portal
- Portal shell · Entry point for dashboard and management screens.
in/index.php - Login and registration · Renders credentials forms and processes authentication and signup.
in/login/auth.php - Logout
in/logout/index.php - Dashboard and account · Shows dashboard/account views and profile updates.
in/pages/dashboard.php - Profile update
in/actions/update_profile.php - Short-link management · Creates and lists user or administrative short-link records.
in/pages/create-short-url.php - Short-link actions · Creates links and changes enabled, validity, or deletion state.
in/actions/shorten.php - QR management · Creates and lists QR records across user and admin scopes.
in/pages/create-qr.php - QR actions · Persists QR records and changes enabled or deletion state.
in/actions/qrsaver.php - Portal assets · Provides application UI, data tables, notifications, and QR rendering.
in/assets/js/app.js
Persistence
- Application database · Stores URLs, QR codes, users, profiles, and status.
url_shortener.sql
Connections 20
- Apache routing → Public link handlers: routes public requests
- Apache routing → Portal shell: routes internal requests
- Public link handlers → Runtime bootstrap: boots shared runtime
- Public link handlers → Suspension page: shows when unavailable
- Portal shell → Runtime bootstrap: boots shared runtime
- Portal shell → Login and registration: requires session
- Login and registration → Logout: establishes session
- Portal shell → Dashboard and account: renders
- Dashboard and account → Profile update: submits changes
- Portal shell → Short-link management: renders
- Short-link management → Short-link actions: submits mutations
- Portal shell → QR management: renders
- QR management → QR actions: submits mutations
- Portal shell → Portal assets: serves UI assets
- Runtime bootstrap → Database adapter: uses
- Database adapter → Application database: reads and writes
- Short-link actions → Database adapter: persists link state
- QR actions → Database adapter: persists QR state
- Profile update → Database adapter: persists profile
- Login and registration → Database adapter: validates accounts