Frontend Themes
Overview
The ComusThumbz frontend theme is a vanilla PHP/CSS/JS application with no framework dependencies (no Bootstrap, Tailwind, React, or Vue). All public-facing pages live at the project root, above the ct/ admin directory.
Key characteristics:
- Pure vanilla CSS with CSS custom properties (variables)
- Vanilla JavaScript with a custom
ApiClientclass - API-first architecture: frontend never queries the database directly
- 25-language translation system via JSON files
- Feature toggle system controlling 35+ features
- Mandatory click tracking via
click.phpfor all outbound links - SEO-optimized with server-side meta tag generation
- Dark mode support (feature-gated)
- Cookie consent system (GDPR compliant)
Directory Structure
Architecture Principles
1. API-First
The frontend never accesses the database directly. All data comes from the REST API at /ct/api/v1/.
2. No Framework CSS/JS
No Bootstrap, Tailwind, React, or Vue. The entire frontend is vanilla:
- CSS in
assets/css/style.csswith CSS custom properties - JavaScript using native
fetch,class, andasync/await
3. Feature-Gated Rendering
Every page checks feature toggles before rendering. Features can be enabled/disabled from the admin panel without code changes:
4. Mandatory Click Tracking
Every outbound link must route through click.php. Direct external links bypass traffic tracking and incur a 100% skim penalty.
5. Translation Everywhere
No hardcoded user-facing text. All strings use the translation system:
Design System (CSS)
The entire theme is defined in assets/css/style.css (~15,000 lines).
Color Palette
Page-Specific Accent Colors:
CSS Variables Reference
Grid System
Responsive CSS Grid with predefined column classes:
Container classes:
Flexbox utilities:
Component Classes
Cards:
Buttons:
Forms:
Page Headers:
Tabs:
Loading States:
Pagination:
Modals:
Dark Mode
Dark mode is feature-gated via featuredarkmode and persisted in localStorage.
Activation:
// Toggle
document.body.classList.toggle('dark-mode');
localStorage.setItem('comusdarkmode',
document.body.classList.contains('dark-mode') ? 'true' : 'false');
CSS overrides: All body.dark-mode selectors redefine colors using the same CSS variable names with dark values. The header gradient shifts from #274510/#597F20 to #1a2f0a/#2d4a14.
JavaScript Layer
ApiClient (api-client.js)
The central JavaScript class for all REST API communication (~1,400 lines).
class ApiError extends Error {
constructor(message, status, data)
}
Authentication: Bearer token stored in localStorage.getItem('authtoken'), automatically added to all requests.
Usage:
// Authenticated request
api.setToken(result.data.token);
const profile = await api.get('/users/me');
Request features:
- JSON request/response formatting
- Query string serialization
- FormData support for file uploads
- Error parsing with status codes
- Network error detection
- Session cookie inclusion (
credentials: 'include')
Tracking Scripts
Feature-Specific Scripts
Layout System (includes/)
header.php
The master header template included on every frontend page.
Initialization sequence:
- Start session (if not active)
- Detect and set language from URL param, session, cookie, or browser
- Load database connection from config
- Load feature toggles (cached for 5 minutes)
- Load style overrides (Style Manager)
- Load banner helper and SEO helper
- Check maintenance mode (admin bypass allowed)
- Render HTML
<head>with SEO meta tags - Render navigation bar
Navigation elements:
- Logo / home link
- Main nav: Videos, Galleries, Models, Live Cams, Categories, Users (each feature-gated)
- Search bar
- Language selector
- User menu: Login/Register or Profile dropdown
- Creator admin link (if user is a creator)
- Token balance display (if applicable)
- Dark mode toggle (if
featuredarkmodeenabled)
Header gradient: linear-gradient(135deg, #274510 0%, #597F20 100%)
footer.php
The master footer template.
Contents:
- Banner zone (FOOTER ad placement)
- Footer navigation links (all routed through
click.php): - Terms, Privacy, DMCA, 2257, Cookie Notice, Accessibility
- Content Removal, Support, FAQ, Trust & Safety, Parental Controls
- Dark mode toggle button
- Cookie consent banner and settings modal
- Essential Cookies (always active)
- Functional Cookies (toggleable)
- Analytics Cookies (toggleable)
- Targeting/Advertising Cookies (toggleable)
featurehelper.php
Controls which features are visible on the frontend.
Constants:
FEATURECACHETTL = 300(5-minute cache)
Key functions:
Feature categories (35+ features):
InternalApiHelper.php
Server-side HTTP client for calling the REST API from PHP (used for SEO pre-loading).
Timeout: 5 seconds for internal calls.
Transport: cURL (not filegetcontents).
SeoHelper.php
Generates SEO meta tags using templates from ct/dat/seosettings.json.
Supported page types: video, gallery, model, creator, category, user, generic
Generated tags:
<title>with keyword-optimized template (50-60 chars)<meta name="description">(150-160 chars)- Open Graph tags (
og:title,og:description,og:image,og:type,og:url) - Twitter Card tags (
twitter:card,twitter:title,twitter:description,twitter:image) - Schema.org JSON-LD structured data
- Canonical URL
- Robots meta tag
UrlHelper.php
Generates SEO-friendly URLs and wraps external URLs with click tracking.
Slug generation: Removes stopwords, lowercases, replaces spaces with hyphens, max 100 characters.
styleloader.php
Loads custom CSS overrides created via the admin Style Manager (Phase 12). Injects <style> tags after the main stylesheet for theme customization.
bannerhelper.php
Displays ad banners in predefined zones.
Supports banner rotation when multiple banners are assigned to one zone.
Multi-Language System (lang/)
Class: Language.php (Singleton pattern)
Language detection priority:
- URL parameter (
?lang=es) - Session variable
- Cookie
- Browser
Accept-Languageheader - Default:
en
25 supported languages:
Arabic, Bengali, Chinese, Danish, English, French, German, Hausa, Hindi, Indonesian, Italian, Japanese, Korean, Marathi, Dutch, Polish, Portuguese, Russian, Spanish, Swahili, Swedish, Telugu, Turkish, Urdu, Vietnamese, Yoruba
Helper functions:
en.json structure (500+ keys):
Root Pages Reference
index.php - Homepage
Purpose: Featured content showcase with statistics dashboard.
Features:
- Dynamic stat cards (total videos, galleries, models, live performers)
- Grid auto-sizes based on enabled features (2 to 4 columns)
- Color-coded cards: green (videos), purple (galleries), pink (models), teal (cams)
- Featured content sections for each enabled content type
API Endpoints:
GET /videos/featured- Trending videosGET /galleries/recent- Recent galleriesGET /models/top- Top modelsGET /cams/online- Live performers
videos.php - Video Browsing
Purpose: Video browsing with search, sorting, and pagination.
Feature guard: featurevideos
Features:
- Search bar with live filtering
- Sort: Newest, Most Viewed, Top Rated, Title A-Z
- Per-page: 52, 104, 156 videos
- 4-column responsive grid
- Subscription content showcase section
- Ad banner zone (CONTENTMIDDLE)
API Endpoints:
GET /videos?page={page}&limit={limit}&sort={sort}&search={search}GET /videos/subscription
videoplayer.php - Video Playback
Purpose: Secure video playback with access control, analytics, and SEO.
Features:
- Server-side SEO data loading (BEFORE header.php for meta tags)
- Access control: free, premium, VIP levels
- Tokenized video/thumbnail URLs
- HLS and MP4 format support
- Related videos playlist
- Player overlays, watermarks, ad overlays
- Star rating system (1-5)
- All external links through
click.php
API Endpoints:
GET /videos/{id}- Video metadataGET /videos/{id}/stats- StatisticsGET /videos/{id}/related- Related videosGET /videos/{id}/access-control- Access check
galleries.php - Gallery Browsing
Purpose: Photo gallery browsing with filters and search.
Feature guard: featuregalleries
Features:
- Search and sort (by ID, clicks, rating, title)
- Per-page: 52, 104, 156
- 4-column grid layout
- Favorites support (logged-in users)
API Endpoints:
GET /galleries?page={page}&limit={limit}&sort={sort}&search={search}
models.php - Model Directory
Purpose: Performer/model directory with type filtering.
Feature guard: featuremodels
Features:
- Model type filter: all, regular, cammodel
- Sort: by ID, popularity, name, video count
- Per-page: 50, 100, 150
- 5-column grid layout (wider cards)
- Search by name
API Endpoints:
GET /models?type={type}&sort={sort}&limit={limit}&search={search}
modeldetails.php - Model Profile
Purpose: Individual model/performer profile with content listings.
camperformers.php - Live Cams Browse
Purpose: Live webcam performer browsing with performance debug tools.
Feature guard: featurelivecams
Features:
- Advanced filters: gender, race, hair, bust, figure, site, HD, age
- Sort: viewers, followers, newest, new models, favorited, experienced, age, HD first, alphabetical
- Per-page: 24, 48
- LIVE badge indicators
- Performance debug panel (
?debug=1) showing: API URL, TTFB, download time, JSON parse time, DOM render time - Favorites support
API Endpoints:
GET /cams/online?page={page}&perpage={perpage}&gender={gender}&sortby={sort}&fast=1GET /cams/sites- Populate site filter
camperformer.php - Cam Detail
Purpose: Individual cam performer profile.
URL: ?id={performerid}
Features:
- Server-side SEO pre-loading
- Online/offline status badge
- Viewer count, HD badge
- External chat link (through
click.php) - Related performers
- Schedule/heatmap
camfilter.php - Cam Filters
Purpose: Filter results page for cam performers.
URL: ?type={filtertype}&value={filtervalue}
Supported types: tag, gender, race, hair, bust, figure, language, site, country, location, pubicarea, isnew, hd, model
categories.php - Category Browsing
Purpose: Browse content categories.
Feature guard: featurecategories
Features:
- Category cards with image/placeholder
- Green gradient placeholders
- Load-more pagination
- Click tracking on category links
users.php - Community Directory
Purpose: Browse community members.
Feature guard: featureprofiles
Features:
- Filters: search, account type (free/premium/vip/moderator/admin), status
- Sort: newest, oldest, most active, alphabetical
- User cards with stats
userprofile.php - User Profile
Purpose: View user profile with content and social features.
URL: ?id={userid}
Features:
- Block checking (redirects if blocked)
- Gradient profile header
- User's videos, playlists, comments
- Video.js integration for embedded player
creator.php - Creator Profile
Purpose: Public creator profile with monetization features.
Feature guard: featurecreatorprofiles
URL: ?username={creatorusername}
Features:
- Creator wall posts (text, image, video, audio, mixed)
- Subscriber count, verification badge
- Follow/Subscribe buttons
- Post interactions (like, comment, unlock)
browsecreators.php - Creator Discovery
Purpose: Creator discovery with filtering and featured section.
Feature guard: featurecreatorprofiles
Features:
- Filters: search, verified status, price range
- Featured creators section
- Creator cards with: avatar, stats, verification badge, pricing
videoplaylist.php - Playlists
Purpose: Video playlist viewer with sequential playback.
livestreams.php - Live Streaming
Purpose: Live stream directory and discovery.
watchstream.php - Stream Viewer
Purpose: Live stream viewer with WebRTC and chat.
Features:
- LiveKit WebRTC connection
- Real-time chat via WebSocket
- Guest user support
- Language detection for chat
click.php - Click Tracking Gateway
Purpose: Universal click tracking and skim enforcement. This is the single most critical file for revenue tracking.
URL format:
Supported types: video, gallery, model, camperformer, banner, sponsor, internal
What it does:
- Logs click to
tblClickTracking - Sends categories to license server for skim calculation
- Redirects user to destination URL (or skim URL based on license)
- Tracks referrer and content performance
securemedia.php - Tokenized Media
Purpose: Serves media files with tokenized URLs for access control. Prevents hotlinking and unauthorized access.
Filter Endpoints
AJAX endpoints for server-side filtering (used by search/filter components):
Authentication Pages (auth/)
login.php
Features:
- Username/password form
- Password visibility toggle
- 2FA code input (hidden until requested)
- Remember me checkbox
- Forgot password link
- Dark mode support (checks
localStorageimmediately) - Language switcher (English/Spanish)
API: POST /auth/login
register.php
Feature guard: featureregistration
Features:
- Username (3-50 characters)
- Password with strength indicator
- Confirm password
- Terms acceptance checkbox
- Age verification (18+)
- Email verification required after registration
API: POST /auth/register
logout.php
Clears session and redirects to homepage.
setsession.php
Sets PHP session data after successful API login. Called after POST /auth/login returns a JWT token.
User Settings (settings/)
All settings pages require authentication and redirect to /auth/login.php if not logged in.
Core Settings
Creator Settings
profile.php Tab System
The main profile page uses a tabbed interface:
Information Pages (information/)
Static/legal pages following a consistent layout using .info-page, .info-container, .info-section classes. All links routed through click.php.
Installation Wizard (install/)
A 7-stage installation wizard at /install/index.php:
Session-based progress tracking with stage-by-stage validation.
Mandatory Patterns
Click Tracking (click.php)
Every outbound link MUST use click.php. No exceptions.
Translation System
Never hardcode user-facing text.
// Wrong
<h1>Videos</h1>
<p>Browse our collection</p>
Variable substitution:
Feature Guards
Check feature toggles at the top of every page:
API-First Data Access
Frontend pages never query the database. All data comes from the REST API.
SEO Pre-Loading
Pages that need SEO meta tags (videoplayer, camperformer, modeldetails) load data BEFORE including header.php:
// 2. Fetch data for SEO
$api = InternalApiHelper::getInstance();
$videoData = $api->getVideoForSeo($videoId);
// 3. NOW include header (which generates meta tags from loaded data)
requireonce DIR . '/includes/header.php';
Troubleshooting
Blank page / 500 error
declare(stricttypes=1) must be the FIRST line after <?php in any file that uses it. Check that no BOM or whitespace precedes it.
Features not showing / all disabled
- Check that the API is reachable:
curl https://domain/ct/api/v1/features - Verify feature cache hasn't stale-locked: clear APCu cache
- Check
featurehelper.phpdefault values (all default to enabled) - Verify feature settings in admin panel
Translations not loading / showing keys instead of text
Verify
lang/en.json exists and is valid JSONCheck file permissions (readable by web server)Verify the translation key exists in the JSON file
- Check for typos in nested keys (e.g.,
videos.sortby.videoidrequires all parent keys to exist)
Dark mode not working
- Check
featuredarkmodeis enabled in feature toggles - Verify
localStorageis available (not blocked by browser) - Confirm
body.dark-modeCSS rules exist in style.css
CSS styles not applying
- Only use
assets/css/style.css- no external CSS frameworks allowed - Check specificity conflicts with Style Manager overrides
- Verify the stylesheet is loaded in header.php
- Check browser cache (append
?v=timestampto stylesheet URL)
API calls failing from JavaScript
Check
ApiClient base URL detection: open browser console and run new ApiClient().baseUrlVerify CORS headers are set if API is on different domain
- Check JWT token in
localStorage.getItem('authtoken') - Verify the endpoint exists in
ct/api/v1/index.phprouter
Video player not loading
- Verify video data loads: check browser Network tab for
/ct/api/v1/videos/{id} - Check access control: user may not have permission
- Verify HLS.js or native HLS support for
.m3u8files - Check
secure_media.phptoken generation