Документация ComusThumbz
Вход для Администратора

Add/Edit Banner

Overview

The Add Banner page is a comprehensive form for creating and editing banner advertisements in ComusThumbz. It supports two banner types: Image banners (uploaded files or hotlinked URLs) and HTML banners (custom HTML/CSS content). The form includes sponsor/sub-sponsor selection, placement zone assignment, scheduling options, category targeting, and real-time preview functionality. The page also supports banner copying with pre-populated fields.

Location: Navigate to this page via Admin Panel → Advertising → Add Banner or access directly via ct/admin/addbanner.php

[Screenshot: add-banner-main-interface]


Getting to This Page

  1. Navigate to Admin Panel → Advertising
  2. Click Add Banner link
  3. Alternatively, click "Add New Banner" on the Banner Management page
  4. To edit, click "Edit" on an existing banner (loads with ?id=X)
  5. To copy, click "Copy" on an existing banner (loads with ?copy=1&...)

 

Note:
This page serves three purposes: creating new banners, editing existing banners, and copying banners. The interface adapts based on the mode.

 


System Requirements

 

Configuration Required:
This page requires sponsors, banner zones, and categories to be configured before creating banners. At least one active sponsor and one active zone must exist.

 

PHP Requirements

Requirement Minimum Recommended Notes
PHP Version 8.0 8.2+ Uses modern PHP syntax and randombytes()
memorylimit 64M 128M For image processing
maxexecutiontime 30 60 File upload processing
uploadmaxfilesize 5M 10M Banner image uploads
postmaxsize 8M 16M Must exceed uploadmaxfilesize

Required PHP Extensions

Extension Required Purpose
mysqli Yes Database connectivity
session Yes CSRF protection, authentication
json Yes AJAX response handling
gd Yes Image dimension detection (getimagesize)
fileinfo Recommended MIME type validation

Required PHP Functions

Function Required For Notes
mysqliprepare() SQL queries Prepared statements
mysqlistmtbindparam() Query parameters Core
mysqlistmtexecute() Query execution Core
mysqlibegintransaction() Transaction support Data integrity
mysqlicommit() Transaction commit Core
mysqlirollback() Transaction rollback Error handling
bin2hex() CSRF token generation Security
randombytes() CSRF token generation Security
moveuploadedfile() File upload Core
getimagesize() Image dimensions Core
isdir() Directory check Upload
mkdir() Directory creation Upload
pathinfo() File extension Upload
filtervar() URL validation Hotlinks
pregmatch() Regex matching HTML processing
pregreplace() Regex replace HTML processing
pregreplacecallback() Regex callback HTML processing
urlencode() URL encoding Click tracking
addslashes() String escaping JavaScript
unlink() File deletion Edit mode

Folder Permissions

Folder Permission Purpose
ct/admin/ 755 (read) Page access
images/banners/ 755 (write) Banner image storage

Network Requirements

Endpoint Protocol Purpose
Font Awesome CDN HTTPS Icons
External image URLs HTTP/HTTPS Hotlink dimension detection

Features & UI Elements

Page Header

[Screenshot: add-banner-header]

Element Description
Title "Add New Banner" / "Edit Banner" / "Copy Banner"
Breadcrumb Dashboard → Banners → Add/Edit/Copy
Subtitle "Create and manage banner advertisements with support for images and HTML content"

Copy Notice Banner

[Screenshot: add-banner-copy-notice]

Appears when copying a banner:

 

Note:
Copying Banner: You are creating a copy of an existing banner. The form has been pre-filled with the original banner's data. Make any desired changes and click "Create Banner" to save the copy.

 

Navigation Buttons

Same as Banner Management page - links to all banner-related pages.

Section 1: Basic Information

[Screenshot: add-banner-basic-info]

Field Type Required Description
Banner Title Text Yes Descriptive name for the banner
Sponsor Dropdown Yes Parent sponsor company
Sub-Sponsor Dropdown No Sub-sponsor (loads based on selected sponsor)
Banner Placement Dropdown Yes Target zone for the banner
Click URL URL Yes Destination when banner is clicked
Tip: The Click URL should be the final landing page. For affiliate links, include your tracking parameters. HTML banners use %referurlhere% as a placeholder for this URL.

Section 2: Banner Type

[Screenshot: add-banner-type-selection]

Two clickable options:

Type Description
Image Banner Upload an image file or use a hotlink URL
HTML Banner Create custom HTML/CSS banner content

Selection toggles which content section is visible.

Section 3a: Banner Image (for Image type)

[Screenshot: add-banner-image-upload]

Upload Methods:

Method Description
Upload File Upload image from computer (JPG, PNG, GIF, WebP, max 5MB)
Hotlink URL Link to externally hosted image

File Upload:

  • Drag and drop supported
  • File type validation
  • Size validation (5MB max)
  • Automatic dimension detection

Hotlink URL:

  • URL input field
  • "Check Dimensions" button to fetch image info
  • Automatic dimension detection

 

Preview Container:
Shows after file selection or hotlink check:

  • Image preview (max 300px height)
  • Width, Height, File Size information

 

Section 3b: HTML Banner Content (for HTML type)

[Screenshot: add-banner-html-editor]

Element Description
HTML Content Textarea for HTML/CSS code
Preview HTML Button to render preview
Guidelines Box Instructions for HTML banners

HTML Guidelines:

  • Use %referurlhere% as placeholder for click URL
  • Include inline CSS (external stylesheets may not work)
  • Keep JavaScript minimal and inline
  • Test in different browsers

Example Code:

<div style="width:300px;height:250px;background:#f0f0f0;border:1px solid #ccc;text-align:center;padding:20px;">

    <h3>Your Ad Title</h3>

    <p>Compelling ad text here</p>

    <a href="%referurlhere%" style="background:#007cba;color:white;padding:10px 20px;text-decoration:none;border-radius:5px;">Click Here</a>

</div>

 

HTML Preview Container:
Shows rendered HTML preview when "Preview HTML" button clicked.

Section 4: Banner Settings

[Screenshot: add-banner-settings]

Field Type Default Description
Width Number (px) Auto-detected Banner width in pixels
Height Number (px) Auto-detected Banner height in pixels
Weight Number 100 Rotation weight (higher = more impressions)
Start Date Date Empty When banner becomes active
End Date Date Empty When banner expires
Status Dropdown Active active, inactive, scheduled, paused
Note: Width and Height are auto-filled when you upload an image or check a hotlink URL. For HTML banners, set these manually based on your design.

Section 5: Categories

[Screenshot: add-banner-categories]

Element Description
Category Grid Scrollable checkbox grid (200px max height)
Limit Warning Shows when trying to select > 10 categories
  • Up to 10 categories can be selected
  • Categories are ordered by selection order (priority)
  • Used for targeted banner display on category pages

Form Actions

[Screenshot: add-banner-form-actions]

Button Action
Cancel Return to bannermanagement.php
Create Banner / Update Banner / Create Copy Save the banner

Loading Overlay

Shows during form submission with spinner and "Processing banner..." message.


HTML Banner Processing

When saving HTML banners, the system automatically processes the content:

Wildcard Replacement

%referurlhere% is replaced with a click tracking URL:

{baseurl}/bannerclick.php?url={encodedclickurl}

Processing Rules

  1. Iframe src attributes - URL-encoded for embed parameters
  2. Anchor href attributes - Direct replacement
  3. onclick handlers - JavaScript-escaped
  4. Remaining occurrences - Simple replacement

iframe Wrapping

If an iframe doesn't contain %referurlhere%, it's wrapped in a clickable div with transparent overlay for click tracking.


Step-by-Step Usage

Creating a New Image Banner

  1. Navigate to Admin Panel → Advertising → Add Banner
  2. Enter a descriptive Banner Title
  3. Select the Sponsor from dropdown
  4. Optionally select a Sub-Sponsor
  5. Select the Banner Placement (zone)
  6. Enter the destination Click URL
  7. Ensure "Image Banner" is selected
  8. Choose upload method:
  • File Upload: Click "Choose File" or drag/drop an image
  • Hotlink: Enter URL and click "Check Dimensions"
  1. Review auto-detected dimensions
  2. Optionally set Weight, Start/End Dates, and Status
  3. Select up to 10 Categories
  4. Click Create Banner

Creating an HTML Banner

Navigate to Admin Panel → Advertising → Add BannerFill in basic information (title, sponsor, placement, click URL)Click "HTML Banner" type optionPaste or type your HTML code in the editor

  1. Use %referurlhere% for click tracking links
  2. Click Preview HTML to verify rendering
  3. Set dimensions manually
  4. Configure settings and categories
  5. Click Create Banner

Editing an Existing Banner

  1. From Banner Management, click Edit on a banner
  2. Page loads with all fields pre-populated
  3. Make desired changes
  4. For image banners, upload new file to replace existing
  5. Click Update Banner

Copying a Banner

  1. From Banner Management, click Copy on a banner
  2. Page loads with copy data (title has " (Copy)" appended)
  3. Status is set to "inactive" by default
  4. Modify any fields as needed
  5. Click Create Copy

AJAX Actions

Action Parameters Description
savebanner All form fields Create or update banner
getbanner id Load banner for editing
getsponsors - Load active sponsors
getsubsponsors sponsorid Load sub-sponsors for sponsor
getplacements - Load active zones
getcategories - Load visible categories
gethotlinkdimensions url Fetch remote image dimensions

File Upload Validation

Check Requirement Error Message
File Type image/jpeg, image/png, image/gif, image/webp "Invalid file type. Only JPG, PNG, GIF, and WebP are allowed."
File Size Max 5MB (5 1024 1024 bytes) "File size too large. Maximum 5MB allowed."
Upload Success moveuploadedfile() returns true "Failed to upload file"

File Naming Convention:

banner{sponsorid}{timestamp}.{extension}

Example: banner51704067200.jpg


Troubleshooting

Common Errors

 

Error:
"Title, sponsor, placement, and click URL are required"


Cause: Required fields not filled
Solution: Ensure all required fields have values

 

 

Error:
"Either upload a file or provide a hotlink URL"


Cause: Image banner without image source
Solution: Upload a file or enter a valid hotlink URL

 

 

Error:
"HTML content is required for HTML banners"


Cause: HTML banner type selected but no content
Solution: Enter HTML code in the editor

 

 

Error:
"Invalid hotlink URL"


Cause: URL doesn't pass filtervar() validation
Solution: Use a complete URL starting with http:// or https://

 

 

Error:
"Could not get image dimensions"


Cause: Remote image not accessible or invalid
Solution:

  1. Verify URL is correct
  2. Check if image is publicly accessible
  3. Try accessing URL directly in browser

 

 

Error:
"Failed to upload file"


Cause: Server permission or disk space issue
Solution:

  1. Verify images/banners/ folder exists with write permissions
  2. Check available disk space
  3. Review PHP upload settings

 

 

Warning:
Preview not showing for HTML banner


Cause: JavaScript error in HTML content
Solution:

  1. Check browser console for errors
  2. Simplify HTML content
  3. Remove external scripts that may be blocked

 

Dimension Detection Issues

 

Tip:
If hotlink dimension detection fails:
  1. Some servers block remote requests
  2. URL may require authentication
  3. Image may be served dynamically
  4. Manually enter width and height instead

 


Translatable Strings

The following strings should be added to backendtranslations.md:

addbannertitleadd = "Add New Banner"
addbannertitleedit = "Edit Banner"
addbannertitlecopy = "Copy Banner"
addbannerbreadcrumbadd = "Add"
addbannerbreadcrumbedit = "Edit"
addbannerbreadcrumbcopy = "Copy"
addbannersubtitle = "Create and manage banner advertisements with support for images and HTML content"
addbannercopynotice = "Copying Banner: You are creating a copy of an existing banner. The form has been pre-filled with the original banner's data. Make any desired changes and click \"Create Banner\" to save the copy."
addbannersectionbasic = "Basic Information"
addbannersectiontype = "Banner Type"
addbannersectionimage = "Banner Image"
addbannersectionhtml = "HTML Banner Content"
addbannersectionsettings = "Banner Settings"
addbannersectioncategories = "Categories"
addbannerfieldtitle = "Banner Title"
addbannerfieldsponsor = "Sponsor"
addbannerfieldsubsponsor = "Sub-Sponsor"
addbannerfieldplacement = "Banner Placement"
addbannerfieldclickurl = "Click URL"
addbannerfieldwidth = "Width (px)"
addbannerfieldheight = "Height (px)"
addbannerfieldweight = "Weight"
addbannerfieldstartdate = "Start Date"
addbannerfieldenddate = "End Date"
addbannerfieldstatus = "Status"
addbannerfieldhtmlcontent = "HTML Content"
addbannerselectsponsor = "Select Sponsor"
addbannerselectsubsponsor = "Select Sub-Sponsor (Optional)"
addbannerselectplacement = "Select Placement"
addbannertypeimage = "Image Banner"
addbannertypeimagedesc = "Upload an image file or use a hotlink URL"
addbannertypehtml = "HTML Banner"
addbannertypehtmldesc = "Create custom HTML/CSS banner content"
addbanneruploadfile = "Upload File"
addbanneruploadfiledesc = "Upload an image file from your computer"
addbannerhotlink = "Hotlink URL"
addbannerhotlinkdesc = "Link to an image hosted elsewhere"
addbannerchoosefile = "Choose File"
addbannersupportedformats = "Supported formats: JPG, PNG, GIF, WebP (Max 5MB)"
addbannercheckdimensions = "Check Dimensions"
addbannerpreviewhtml = "Preview HTML"
addbannerhtmlguidelines = "HTML Banner Guidelines"
addbannerhtmlplaceholdertip = "Use %referurlhere% as a placeholder for the click URL"
addbannerhtmlinlinecss = "Include inline CSS for styling (external stylesheets may not work)"
addbannerhtmlminimaljs = "Keep JavaScript minimal and inline if needed"
addbannerhtmltestbrowsers = "Test your banner in different browsers"
addbannerhtmlexample = "Example"
addbannercategorieslimit = "Select Categories (Up to 10)"
addbannercategorieswarning = "Maximum 10 categories allowed"
addbannerbtncancel = "Cancel"
addbannerbtncreate = "Create Banner"
addbannerbtnupdate = "Update Banner"
addbannerbtncopy = "Create Copy"
addbannerprocessing = "Processing banner..."
addbannersuccess = "Banner saved successfully"
addbannererrorrequired = "Please fill in all required fields"
addbannererrorimagerequired = "Please upload a file or provide a hotlink URL for image banners"
addbannererrorhtmlrequired = "Please provide HTML content for HTML banners"
addbannerpreviewwidth = "Width"
addbannerpreviewheight = "Height"
addbannerpreviewsize = "File Size"
addbannerpreviewexternal = "External"

Version History

Version Date Changes
1.0 2024-10 Initial release with image upload
1.1 2024-11 Added HTML banner support
1.2 2024-11 Added hotlink URL support with dimension detection
1.3 2024-12 Added copy functionality with pre-population
1.4 2025-01 Improved HTML processing with automatic click tracking