Documentation ComusThumbz
Connexion Admin

Storage Groups

Overview

The Storage Server Groups page allows administrators to manage logical groupings of storage servers for distributing and load-balancing video content. Groups provide a way to organize multiple storage servers by content type, geographic region, or performance tier.

Key capabilities include:

  • Create and manage storage server groups
  • Configure load balancing strategies
  • Set content type restrictions (videos, images, thumbnails)
  • Enable automatic content synchronization
  • View group statistics (servers, storage, video counts)
  • Set group priority for content distribution

 


System Requirements

PHP Requirements

Requirement Minimum Recommended
PHP Version 7.4+ 8.0+
Memory Limit 64M 128M

PHP Extensions Required

  • mysqli - Database connectivity
  • json - JSON encoding/decoding for geo rules
  • session - Session management for CSRF protection

PHP Settings

session.autostart = Off
date.timezone = Your/Timezone

Installation Requirements

Database Tables

-- Storage Server Groups Table
CREATE TABLE IF NOT EXISTS tblStorageServerGroups (
    groupid INT(11) NOT NULL AUTOINCREMENT,
    groupname VARCHAR(100) NOT NULL,
    groupdescription TEXT DEFAULT NULL,
    contenttype ENUM('videos', 'images', 'both', 'thumbnails') DEFAULT 'both',
    loadbalancingtype ENUM('roundrobin', 'leastspace', 'weighted', 'geobased') DEFAULT 'leastspace',
    georules JSON DEFAULT NULL COMMENT 'Geography-based distribution rules',
    isactive TINYINT(1) DEFAULT 1,
    autosyncnewcontent TINYINT(1) DEFAULT 1,
    priority INT(11) DEFAULT 5 COMMENT '1-10, higher = preferred',
    createdat DATETIME DEFAULT CURRENTTIMESTAMP,
    updatedat DATETIME DEFAULT CURRENTTIMESTAMP ON UPDATE CURRENTTIMESTAMP,
    PRIMARY KEY (groupid),
    KEY idxcontenttype (contenttype),
    KEY idxisactive (isactive),
    KEY idxpriority (priority)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4unicodeci;

-- Storage Servers Table (referenced)
CREATE TABLE IF NOT EXISTS tblStorageServers (
serverid INT(11) NOT NULL AUTOINCREMENT,
groupid INT(11) NOT NULL,
server
name VARCHAR(100) NOT NULL,
servertype ENUM('local', 'ftp', 'sftp', 'bunnycdn', 'vultr', 'digitaloceanspaces', 'cloudflarer2', 'keycdn', 'cdn77') NOT NULL,
connectionconfig JSON DEFAULT NULL,
base
url VARCHAR(255) DEFAULT NULL,
maxstoragegb DECIMAL(10,2) DEFAULT 0,
currentusagegb DECIMAL(10,2) DEFAULT 0,
status ENUM('enabled', 'disabled') DEFAULT 'enabled',
isactive TINYINT(1) DEFAULT 1,
health
status ENUM('healthy', 'warning', 'critical', 'unknown') DEFAULT 'unknown',
lasthealthcheck DATETIME DEFAULT NULL,
controlscriptenabled TINYINT(1) DEFAULT 0,
controlscripturl VARCHAR(500) DEFAULT NULL,
nginxsecretkey VARCHAR(255) DEFAULT NULL,
createdat DATETIME DEFAULT CURRENTTIMESTAMP,
updatedat DATETIME DEFAULT CURRENTTIMESTAMP ON UPDATE CURRENTTIMESTAMP,
PRIMARY KEY (server
id),
KEY idxgroupid (groupid),
KEY idx
status (status),
CONSTRAINT fkservergroup FOREIGN KEY (groupid)
REFERENCES tblStorageServerGroups (group
id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4unicodeci;

 

Content Type Reference

Type Description
videos Processed videos (MP4, HLS)
images Gallery images, photos
both Videos and images combined
thumbnails Video thumbnails and previews

Load Balancing Types

Type Description
leastspace Prioritize servers with most free space
roundrobin Distribute evenly across all servers
weighted Use server weight for distribution
geobased Route based on geographic location

Config Variables

From ct/dat/config.inc.php:

  • $dbhost, $dbuser, $dbpasswd, $db - Database connection

 

File Dependencies

  • ct/admin/adminauth.php - Admin authentication
  • ct/dat/config.inc.php - Configuration
  • ct/includes/header.php - Admin header
  • ct/includes/annotateftr.php - Admin footer
  • Font Awesome 6+ - Icon library

Features & UI Elements

Page Header

[Screenshot: storage-groups-header]

The page header displays:

  • Title: "Storage Server Groups"
  • Icon: fa-layer-group
  • Breadcrumb: Dashboard / Storage / Groups
  • Subtitle: "Manage storage server groups for distributing and load-balancing video content"

 

Alert Messages

[Screenshot: storage-groups-alerts]

Success and error alerts for:

  • Group created successfully
  • Group updated successfully
  • Group deleted successfully
  • Deletion blocked (has servers)
  • Database errors

 

Action Card

[Screenshot: storage-groups-action-card]

A card containing the primary action:

  • Create New Storage Group button (green)

 

Groups Table

[Screenshot: storage-groups-table]

The main data table displaying all groups:

Column Description
Group Name Name and description
Content Type Badge showing videos/images/both/thumbnails
Load Balancing Distribution strategy
Servers Number of active servers in group
Storage Used/Total GB with percentage
Videos Count of videos assigned to group
Status Active/Inactive with indicator dot
Actions Edit, Servers, Delete buttons

Status Indicators:

Indicator Color Meaning
Green dot Active Group is enabled
Red dot Inactive Group is disabled

Action Buttons:

Button Color Action
Edit Gray Open edit modal
Servers Green Navigate to storageservers.php with groupid
Delete Red Delete group (only if no servers)
Warning: Groups with existing servers cannot be deleted. Remove all servers from the group first.

Create/Edit Modal

[Screenshot: storage-groups-modal]

A modal form for creating or editing groups:

Form Fields:

Field Type Required Description
Group Name Text Yes Unique name for the group
Description Textarea No Optional description
Content Type Select Yes Type of content to store
Load Balancing Type Select Yes Distribution strategy
Geography Rules Textarea No JSON rules for geobased (required if geobased selected)
Priority Number No 1-10, higher is preferred
Active Checkbox No Enable/disable group
Auto-sync New Content Checkbox No Automatically sync new uploads

Content Type Options:

  • Videos & Images (both)
  • Videos Only
  • Images Only
  • Thumbnails Only

Load Balancing Options:

  • Least Space Used
  • Round Robin
  • Weighted
  • Geography Based

 

 

Tip: Use "Least Space Used" for general purposes. It ensures even distribution across servers based on available space.

 

Geography Rules JSON

When "Geography Based" is selected, a JSON configuration field appears:

{"US": 80, "EU": 20}

This example routes 80% of traffic to US servers and 20% to EU servers.

Supported Region Codes:

  • US - United States
  • EU - Europe
  • AS - Asia
  • SA - South America
  • AF - Africa
  • OC - Oceania

 


Step-by-Step Usage

Creating a Storage Group

  1. Navigate to Admin Panel → Storage → Groups
  2. Click Create New Storage Group button
  3. Fill in the form:
  • Group Name: Enter a descriptive name (e.g., "Primary Videos CDN")
  • Description: Optional description of the group's purpose
  • Content Type: Select what content this group will store
  • Load Balancing Type: Choose distribution strategy
  • Priority: Set 1-10 (higher = more preferred)
  1. Configure options:
  • Check Active to enable immediately
  • Check Auto-sync New Content for automatic uploads
  1. Click Save Group

 

Note: After creating a group, you'll need to add storage servers to it before it can be used.

 

Editing a Storage Group

  1. Find the group in the table
  2. Click the Edit button (pencil icon)
  3. Modify the desired fields
  4. Click Save Group

 

Warning: Changing the content type on a group with existing content is not recommended. Create a new group instead.

 

Deleting a Storage Group

  1. Ensure the group has 0 servers (check "Servers" column)
  2. If servers exist, click "Servers" and delete them first
  3. Click the Delete button (trash icon)
  4. Confirm the deletion

 

Error: You cannot delete a group that has servers. Remove all servers first to enable deletion.

 

Viewing Group Servers

Find the group in the tableClick the Servers button (server icon)

  1. You'll be redirected to storageservers.php filtered by group

Setting Up Geography-Based Load Balancing

  1. Create or edit a storage group
  2. Set Load Balancing Type to "Geography Based"
  3. Enter Geography Rules in JSON format:
{
    "US": 60,
    "EU": 30,
    "AS": 10
}
  1. Ensure percentages add up to 100
  2. Click Save Group

 

Tip: Geography-based routing is ideal for sites with global audiences. Place servers in regions matching your traffic patterns.

 


Best Practices

Group Organization Strategies

By Content Type:

Group Name Content Type Use Case
Video Storage videos Main video files
Thumbnail CDN thumbnails Video thumbnails
Gallery Images images Photo galleries


By Performance Tier:

Group Name Priority Use Case
Premium CDN 10 Popular content, paid content
Standard CDN 5 Regular content
Archive Storage 1 Old, rarely accessed content


By Geographic Region:

Group Name Load Balancing Use Case
North America geobased US/Canada users
Europe geobased EU users
Asia Pacific geobased Asian users

Priority Settings

 

 

Configuration Required: Priority determines which group is selected when multiple groups can handle the content:

 

Priority Usage
10 Critical content, highest performance CDN
7-9 Premium content, fast CDN
4-6 Standard content, balanced
1-3 Archive content, cost-optimized

Load Balancing Selection

Scenario Recommended Type
Equal servers, steady traffic Round Robin
Varying server sizes Least Space
Server quality differences Weighted
Global audience Geography Based

Troubleshooting

Common Issues

Tables Not Found Error

Cause: Storage tables haven't been created

Solutions:

  1. Run the SQL schema file:

 

mysql -u youruser -p yourdatabase < storageserverschema.sql

 

  1. Execute CREATE TABLE statements via phpMyAdmin
  2. Check database connection credentials

 

Cannot Delete Group

Cause: Group has servers assigned

Solutions:

  1. Check the "Servers" column for count > 0
  2. Click "Servers" button to view assigned servers
  3. Delete each server from the group
  4. Return and delete the group

 

Query Error on Page Load

Cause: Database connection or schema issue

Solutions:

  1. Verify database connection in config.inc.php
  2. Check if all required columns exist
  3. Verify foreign key constraints
  4. Check MySQL error logs

 

Geography Rules Not Working

Cause: Invalid JSON or misconfigured servers

Solutions:

  1. Validate JSON syntax:

 

{"US": 80, "EU": 20}

 

  1. Ensure percentages total 100
  2. Verify servers are tagged with regions
  3. Check server health status

 

Database Issues

Group Statistics Incorrect

Cause: Aggregation query issues

Solution:

-- Recalculate group statistics

SELECT

    g.groupid,

    g.groupname,

    COUNT(DISTINCT s.serverid) as servercount,

    SUM(s.maxstoragegb) as totalstorage,

    SUM(s.currentusagegb) as usedstorage,

    COUNT(DISTINCT v.videoid) as videocount

FROM tblStorageServerGroups g

LEFT JOIN tblStorageServers s ON g.groupid = s.groupid AND s.isactive = 1

LEFT JOIN tblVideos v ON g.groupid = v.storagegroupid

GROUP BY g.groupid;

 

Foreign Key Constraint Errors

Cause: Attempting to delete group with servers

Solution:

-- Check for dependent servers

SELECT serverid, servername

FROM tblStorageServers

WHERE groupid = {groupid};

 


-- Delete servers first (if intended)
DELETE FROM tblStorageServers WHERE groupid = {groupid};


-- Then delete group
DELETE FROM tblStorageServerGroups WHERE groupid = {groupid};

 


Security Considerations

Access Control

  • Only administrators can access this page
  • Admin authentication required via adminauth.php
  • Session validation on every request

Input Validation

  • All inputs sanitized with mysqlirealescapestring
  • Prepared statements used for database operations
  • Integer values validated with intval()

JSON Validation

 

Warning: Geography rules JSON should be validated before use. Invalid JSON may cause routing failures.

 

Recommended validation:

$georules = jsondecode($POST['georules'], true);

if (jsonlasterror() !== JSONERRORNONE) {

    $error = "Invalid JSON in geography rules";

}

 


Translatable Strings

{
    "storagegroupstitle": "Storage Server Groups",
    "storagegroupsbreadcrumb": "Dashboard / Storage / Groups",
    "storagegroupssubtitle": "Manage storage server groups for distributing and load-balancing video content",
    "storagegroupscreatebtn": "Create New Storage Group",
    "storagegroupstablename": "Group Name",
    "storagegroupstablecontenttype": "Content Type",
    "storagegroupstableloadbalancing": "Load Balancing",
    "storagegroupstableservers": "Servers",
    "storagegroupstablestorage": "Storage",
    "storagegroupstablevideos": "Videos",
    "storagegroupstablestatus": "Status",
    "storagegroupstableactions": "Actions",
    "storagegroupsmodalcreatetitle": "Create Storage Group",
    "storagegroupsmodaledittitle": "Edit Storage Group",
    "storagegroupsformname": "Group Name",
    "storagegroupsformdescription": "Description",
    "storagegroupsformcontenttype": "Content Type",
    "storagegroupsformloadbalancing": "Load Balancing Type",
    "storagegroupsformgeorules": "Geography Rules (JSON)",
    "storagegroupsformpriority": "Priority (1-10)",
    "storagegroupsformactive": "Active",
    "storagegroupsformautosync": "Auto-sync New Content",
    "storagegroupscontentboth": "Videos & Images",
    "storagegroupscontentvideos": "Videos Only",
    "storagegroupscontentimages": "Images Only",
    "storagegroupscontentthumbnails": "Thumbnails Only",
    "storagegroupslbleastspace": "Least Space Used",
    "storagegroupslbroundrobin": "Round Robin",
    "storagegroupslbweighted": "Weighted",
    "storagegroupslbgeobased": "Geography Based",
    "storagegroupsgeoruleshint": "Example: {\"US\": 80, \"EU\": 20}",
    "storagegroupsbtncancel": "Cancel",
    "storagegroupsbtnsave": "Save Group",
    "storagegroupsbtnedit": "Edit",
    "storagegroupsbtnservers": "Servers",
    "storagegroupsbtndelete": "Delete",
    "storagegroupsstatusactive": "Active",
    "storagegroupsstatusinactive": "Inactive",
    "storagegroupsserverscount": "{count} server(s)",
    "storagegroupsstorageused": "{used} / {total} GB ({percent}% used)",
    "storagegroupssuccesscreated": "Storage group created successfully!",
    "storagegroupssuccessupdated": "Storage group updated successfully!",
    "storagegroupssuccessdeleted": "Storage group deleted successfully!",
    "storagegroupserrorhasservers": "Cannot delete group with existing servers. Remove servers first.",
    "storagegroupsconfirmdelete": "Are you sure you want to delete this storage group?"
}


Version History

Version Date Changes
1.0.0 2025-10-20 Initial storage groups management
1.1.0 2025-11-01 Added load balancing types
1.2.0 2025-11-15 Added geography-based routing
1.3.0 2025-12-01 Added auto-sync option
1.4.0 2025-12-15 Modern UI with green theme
1.5.0 2025-01-02 Added group statistics display