FILE 5: /home/breaking-news-generator.digitalprank.com/public_html/help.md
code
Markdown
# Breaking News Generator Help
Generate hilarious custom news headlines and images with realistic news templates. Perfect for pranks, memes, and viral content.
### Quick Start Guide
Follow these simple steps to create your custom breaking news image:
1. **Step 1:** Type your custom headline.
2. **Step 2:** Pick a template style.
3. **Step 3:** Customize with logo and subheadline (Pro).
4. **Step 4:** Click 'Generate'.
5. **Step 5:** Download and share!
### Features
* **Custom Headline:** The main text for your breaking news. Must be between 10 and 200 characters. (Available to all users)
* **Subheadline (optional):** Add a smaller line of text for more detail and realism. (Pro feature)
* **Template Style:** Choose the visual look of your news graphic. We offer styles mimicking popular news outlets. Some advanced styles like Twitter/X posts and TV tickers are for Pro users.
* **Upload Custom Logo (optional):** Replace the default template logo with your own. We recommend a transparent PNG. (Pro feature)
* **Export Format:** Download your creation as a PNG or JPG image. Pro users can also export as a high-quality PDF or an animated MP4 video.
### Frequently Asked Questions (FAQ)
**Q: Is this tool meant to spread misinformation?**
> A: Absolutely not. This tool is for comedy, entertainment, and parody only. It should never be used to deceive or manipulate others. All generated images are for personal, non-commercial use.
**Q: Can I upload my own news channel logo?**
> A: Yes, Pro users can upload a custom logo to personalize the output.
**Q: Can I generate videos instead of images?**
> A: Yes, animated breaking news MP4 exports are available to Pro users.
### Usage Examples
Here are a couple of ideas to get you started:
**1. Local Hero Rescues Cat with Drone**
* **Description:** A silly headline for a CNN-style custom news image.
* **Input:**
* **Headline:** `Drone Pilot Saves Cat from Tree, Demands Superhero Status`
* **Template Style:** `CNN Style`
**2. Aliens Demand WiFi Password**
* **Description:** Great for a tweet-style breaking news screenshot.
* **Input:**
* **Headline:** `UFOs Land in Texas, Request WiFi and Snacks`
* **Template Style:** `Twitter/X Breaking Post (Pro)`
FILE 6: /home/digitalprank.com/public_html/blog/data/tools/breaking-news-generator.json
code
JSON
{
"slug": "breaking-news-generator",
"name": "Breaking News Generator",
"meta_title": "Breaking News Generator | Create Funny Headlines | DigitalPrank.com",
"meta_description": "Generate hilarious custom news headlines and images with realistic news templates. Perfect for pranks, memes, and viral content. Try free!",
"canonical_url": "https://digitalprank.com/tools/breaking-news-generator",
"datePublished": "2025-09-26",
"dateModified": "2025-09-26",
"author": {
"@type": "Organization",
"name": "DigitalPrank"
},
"keywords": ["custom news", "prank", "breaking news", "headline generator", "news meme", "digital prank", "funny news", "parody news"],
"long_description": "Unleash your creativity and humor with the Breaking News Generator. This tool allows you to craft your own hilarious and absurd news headlines and instantly turn them into realistic-looking news graphics. Perfect for creating memes to share on social media, making jokes with friends, or adding a funny touch to a presentation. Choose from various templates inspired by major news networks, add your own text, and even upload a custom logo for the ultimate personalized prank.",
"features_list": [
{
"name": "Custom Headlines & Subheadlines",
"description": "Write any outrageous headline you can think of. Pro users can add a subheadline for extra detail.",
"is_pro": false
},
{
"name": "Multiple News Templates",
"description": "Select from a variety of styles including CNN, BBC, and Fox News look-alikes.",
"is_pro": false
},
{
"name": "Pro Template Pack",
"description": "Pro users get access to exclusive templates like Twitter/X posts, TV news tickers, and YouTube stream screenshots.",
"is_pro": true
},
{
"name": "Custom Logo Upload",
"description": "Brand your custom news with your own logo. A powerful feature for Pro users.",
"is_pro": true
},
{
"name": "Multiple Export Formats",
"description": "Download your final image as a PNG or JPG. Pro users can also export as a PDF or an animated MP4 video.",
"is_pro": true
}
],
"how_to_guide": {
"title": "How to Create Your Custom News Graphic",
"steps": [
"Enter your main headline in the 'Custom Headline' text box.",
"Optionally, add a subheadline if you are a Pro user.",
"Select your desired visual style from the 'Template Style' dropdown.",
"Choose your export format (PNG, JPG, or PDF/MP4 for Pro users).",
"Click 'Generate' and wait for your masterpiece to appear.",
"Click the 'Download' button to save and share your creation."
]
},
"use_cases": [
"Creating viral memes for social media platforms like Instagram, Twitter, and Facebook.",
"Making personalized jokes for friends' birthdays or special occasions.",
"Adding a humorous visual element to presentations or creative projects.",
"Generating funny, shareable content for your blog or website."
],
"disclaimer": "This tool is for entertainment and parody purposes only. DigitalPrank does not condone the creation or dissemination of misinformation. Please use responsibly.",
"structured_data": {
"@context": "https://schema.org",
"@type": "WebApplication",
"name": "Breaking News Generator",
"description": "Generate hilarious custom news headlines and images with realistic news templates. Perfect for pranks, memes, and viral content.",
"applicationCategory": "EntertainmentApplication",
"operatingSystem": "Any (Web-based)",
"url": "https://digitalprank.com/tools/breaking-news-generator",
"offers": {
"@type": "Offer",
"price": "0.00",
"priceCurrency": "USD"
}
}
}
FILE 7: /home/breaking-news-generator.digitalprank.com/public_html/deploy.sh
code
Bash
#!/bin/bash
set -e
TOOL_SLUG="breaking-news-generator"
TOOL_DIR="/home/${TOOL_SLUG}.digitalprank.com/public_html"
VHOST_DIR="/usr/local/lsws/conf/vhosts"
VHOST_CONF="${VHOST_DIR}/${TOOL_SLUG}/vhost.conf"
DB_NAME="digitalprank_db"
DB_USER="dp_user"
DB_PASS="#$Dealer2355"
WEB_USER="www-data"
echo "--- Starting deployment for ${TOOL_SLUG} ---"
# 1. Install System and PHP Dependencies
echo "--> Installing system packages..."
sudo apt-get update
sudo apt-get install -y imagemagick ffmpeg python3-venv php8.1-gd php8.1-mbstring
# 2. Create Directories
echo "--> Setting up directories..."
sudo mkdir -p ${TOOL_DIR}/{output,uploads,assets/templates,assets/fonts}
sudo chown -R ${WEB_USER}:${WEB_USER} ${TOOL_DIR}
sudo chmod -R 755 ${TOOL_DIR}
sudo chmod -R 775 ${TOOL_DIR}/{output,uploads}
# 3. Create Python Virtual Environment
echo "--> Setting up Python venv..."
sudo python3 -m venv ${TOOL_DIR}/venv
source ${TOOL_DIR}/venv/bin/activate
pip install pillow moviepy
deactivate
sudo chown -R ${WEB_USER}:${WEB_USER} ${TOOL_DIR}/venv
# 4. Create Tool-Specific Database Table
echo "--> Creating database table 'custom_news_history'..."
SQL="CREATE TABLE IF NOT EXISTS \`custom_news_history\` (
\`id\` BIGINT PRIMARY KEY AUTO_INCREMENT,
\`user_id\` BIGINT NULL,
\`headline\` TEXT NOT NULL,
\`subheadline\` TEXT NULL,
\`template\` VARCHAR(100) NOT NULL,
\`output_file\` VARCHAR(255) NOT NULL,
\`created_at\` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
\`deleted_at\` TIMESTAMP NULL,
INDEX \`user_id_idx\` (\`user_id\`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;"
mysql -h localhost -u "${DB_USER}" -p"${DB_PASS}" "${DB_NAME}" -e "${SQL}"
# 5. Configure OpenLiteSpeed Virtual Host
echo "--> Configuring OpenLiteSpeed vhost..."
sudo mkdir -p ${VHOST_DIR}/${TOOL_SLUG}
sudo cat << EOF > ${VHOST_CONF}
docRoot \$VH_ROOT/public_html
vhDomain ${TOOL_SLUG}.digitalprank.com
vhAliases www.${TOOL_SLUG}.digitalprank.com
errorlog \$VH_ROOT/logs/error.log {
useServer 0
logLevel ERROR
rollingSize 10M
}
accesslog \$VH_ROOT/logs/access.log {
useServer 0
rollingSize 10M
keepDays 10
}
scripthandler {
add lsapi:php81 php
}
extprocessor php81 {
type lsapi
address uds://tmp/lshttpd/php81.sock
maxConns 35
env LSAPI_AVOID_FORK=200M
initTimeout 60
retryTimeout 0
persistConn 1
respBuffer 0
autoStart 1
path /usr/local/lsws/lsphp81/bin/lsphp
}
context / {
allowBrowse 1
location \$DOC_ROOT/
rewrite {
enable 1
rules """
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php [L]
"""
}
}
EOF
# 6. Configure Log Rotation
echo "--> Configuring log rotation..."
sudo cat << EOF > /etc/logrotate.d/${TOOL_SLUG}
/home/${TOOL_SLUG}.digitalprank.com/public_html/logs/*.log {
daily
missingok
rotate 14
compress
delaycompress
notifempty
create 640 ${WEB_USER} ${WEB_USER}
sharedscripts
postrotate
if [ -f /var/run/openlitespeed.pid ]; then
kill -USR1 \`cat /var/run/openlitespeed.pid\`
fi
endscript
}
EOF
# 7. Restart OpenLiteSpeed
echo "--> Restarting OpenLiteSpeed server..."
sudo systemctl restart lsws
echo "--- Deployment for ${TOOL_SLUG} complete! ---"
echo "Ensure DNS for ${TOOL_SLUG}.digitalprank.com points to this server."
FILE 8: /home/breaking-news-generator.digitalprank.com/public_html/generate_video.py
code
Python
import argparse
from moviepy.editor import ImageClip, CompositeVideoClip
from PIL import Image
def create_animated_video(image_path, output_path, duration=5):
"""
Creates a short video from a static image with a subtle zoom-in (Ken Burns) effect.
"""
try:
# Get image dimensions
with Image.open(image_path) as img:
img_width, img_height = img.size
# Create an ImageClip
clip = ImageClip(image_path)
# Define the zoom-in effect
def resize_func(t):
# Zoom from 1.0x to 1.1x over the duration
scale = 1.0 + (t / duration) * 0.1
return scale
# Apply the effect
zoomed_clip = clip.resize(resize_func)
# Create a composite clip to crop the zoomed image to original dimensions
final_clip = CompositeVideoClip(
[zoomed_clip.set_position(('center', 'center'))],
size=(img_width, img_height)
)
# Set the duration and write the final video file
final_clip.set_duration(duration).write_videofile(
output_path,
codec='libx264',
fps=24,
audio=False,
threads=2,
logger=None
)
print(f"Video created successfully at {output_path}")
except Exception as e:
print(f"Error creating video: {e}")
exit(1)
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Generate an animated MP4 from an image.")
parser.add_argument("--input", required=True, help="Path to the input image file.")
parser.add_argument("--output", required=True, help="Path for the output MP4 file.")
parser.add_argument("--duration", type=int, default=5, help="Duration of the video in seconds.")
args = parser.parse_args()
create_animated_video(args.input, args.output, args.duration)
Model
ThinkingThoughts
(experimental)
Auto
Expand to view model thoughts
chevron_right
FILE 9: /home/cdn.digitalprank.com/public_html/php/universal_functions.php
code
PHP
'free',
'has_pro_access' => false,
'has_ultimate_access' => false,
'entitlements' => []
];
if (!$user_id) {
return $access;
}
// Check subscription status
$stmt = $pdo->prepare(
"SELECT subscription_plan_id, status FROM wp_pms_member_subscriptions WHERE user_id = ? ORDER BY id DESC LIMIT 1"
);
$stmt->execute([$user_id]);
$subscription = $stmt->fetch(PDO::FETCH_ASSOC);
if ($subscription && in_array($subscription['status'], ['active', 'trialing'])) {
$plan_id = (int)$subscription['subscription_plan_id'];
if (in_array($plan_id, [176, 186])) {
$access['tier'] = 'ultimate';
$access['has_pro_access'] = true;
$access['has_ultimate_access'] = true;
} elseif (in_array($plan_id, [175, 185])) {
$access['tier'] = 'gold';
$access['has_pro_access'] = true;
} elseif (in_array($plan_id, [174, 184])) {
$access['tier'] = 'basic';
$access['has_pro_access'] = true;
}
}
// Check for specific tool entitlements (one-off purchases)
$stmt = $pdo->prepare(
"SELECT t.tool_id FROM wp_digitalprank_entitlements e
JOIN wp_digitalprank_tools t ON e.tool_id = t.tool_id
WHERE e.user_id = ? AND t.slug = ? AND e.is_active = 1 AND (e.expires_at IS NULL OR e.expires_at > NOW())"
);
$stmt->execute([$user_id, $tool_slug]);
if ($stmt->fetch()) {
$access['entitlements'][] = $tool_slug;
$access['has_pro_access'] = true; // A specific entitlement grants pro access for that tool.
}
return $access;
}
/**
* Checks if the user or IP has exceeded the daily usage limit for their tier.
*
* @param PDO $pdo The database connection object.
* @param string $tool_slug The slug of the tool.
* @param string $user_ip The user's IP address.
* @param int|null $user_id The user's ID.
* @param int $limit The daily usage limit for the user's tier (-1 for unlimited).
* @throws Exception if the usage limit is exceeded.
*/
function checkDailyUsage(PDO $pdo, $tool_slug, $user_ip, $user_id, $limit) {
if ($limit === -1) {
return; // Unlimited usage
}
if ($user_id) {
$sql = "SELECT COUNT(*) FROM wp_digitalprank_usage_log WHERE user_id = ? AND tool_slug = ? AND status = 'success' AND timestamp >= DATE_SUB(NOW(), INTERVAL 24 HOUR)";
$stmt = $pdo->prepare($sql);
$stmt->execute([$user_id, $tool_slug]);
} else {
$sql = "SELECT COUNT(*) FROM wp_digitalprank_usage_log WHERE user_id IS NULL AND ip_address = ? AND tool_slug = ? AND status = 'success' AND timestamp >= DATE_SUB(NOW(), INTERVAL 24 HOUR)";
$stmt = $pdo->prepare($sql);
$stmt->execute([$user_ip, $tool_slug]);
}
$count = $stmt->fetchColumn();
if ($count >= $limit) {
throw new Exception('You have exceeded your daily usage limit for this tool. Please upgrade or try again tomorrow.');
}
}
/**
* Gets the current daily usage count for a user/IP.
*
* @param PDO $pdo The database connection object.
* @param string $tool_slug The slug of the tool.
* @param string $user_ip The user's IP address.
* @param int|null $user_id The user's ID.
* @return int The number of uses in the last 24 hours.
*/
function getDailyUsage(PDO $pdo, $tool_slug, $user_ip, $user_id) {
if ($user_id) {
$sql = "SELECT COUNT(*) FROM wp_digitalprank_usage_log WHERE user_id = ? AND tool_slug = ? AND status = 'success' AND timestamp >= DATE_SUB(NOW(), INTERVAL 24 HOUR)";
$stmt = $pdo->prepare($sql);
$stmt->execute([$user_id, $tool_slug]);
} else {
$sql = "SELECT COUNT(*) FROM wp_digitalprank_usage_log WHERE user_id IS NULL AND ip_address = ? AND tool_slug = ? AND status = 'success' AND timestamp >= DATE_SUB(NOW(), INTERVAL 24 HOUR)";
$stmt = $pdo->prepare($sql);
$stmt->execute([$user_ip, $tool_slug]);
}
return (int)$stmt->fetchColumn();
}
/**
* Logs a tool usage event to the database.
*
* @param PDO $pdo The database connection object.
* @param string $tool_slug The slug of the tool.
* @param string $user_ip The user's IP address.
* @param int|null $user_id The user's ID.
* @param string $action_type The type of action (e.g., 'generate', 'failed').
* @param array $input_data The user's input.
* @param array $output_data The result of the action.
* @param float $processing_time The time taken in seconds.
* @param string $status The final status ('success', 'failed', 'partial').
*/
function logUsage(PDO $pdo, $tool_slug, $user_ip, $user_id, $action_type, $input_data, $output_data, $processing_time, $status) {
// General usage log for analytics
$sql_usage = "INSERT INTO wp_digitalprank_usage (user_id, tool_slug, action, credits_used, processing_time, ip_address, session_id, user_agent) VALUES (?, ?, ?, ?, ?, ?, ?, ?)";
$stmt_usage = $pdo->prepare($sql_usage);
$stmt_usage->execute([
$user_id,
$tool_slug,
$action_type,
($status === 'success' ? 1 : 0),
$processing_time,
$user_ip,
session_id(),
$_SERVER['HTTP_USER_AGENT'] ?? 'Unknown'
]);
// Detailed log for history and debugging
$sql_log = "INSERT INTO wp_digitalprank_usage_log (user_id, tool_slug, action_type, ip_address, session_id, user_agent, input_data, output_data, processing_time, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$stmt_log = $pdo->prepare($sql_log);
$stmt_log->execute([
$user_id,
$tool_slug,
$action_type,
$user_ip,
session_id(),
$_SERVER['HTTP_USER_AGENT'] ?? 'Unknown',
json_encode($input_data),
json_encode($output_data),
$processing_time,
$status
]);
}
/**
* Fetches all active field overrides for a specific tool.
*
* @param PDO $pdo The database connection object.
* @param string $tool_slug The slug of the tool.
* @return array An associative array of overrides.
*/
function getToolOverrides(PDO $pdo, $tool_slug) {
$sql = "SELECT o.field_id, o.tier_required, o.override_type
FROM wp_digitalprank_tool_overrides o
JOIN wp_digitalprank_tools t ON o.tool_id = t.tool_id
WHERE t.slug = ? AND o.is_active = 1";
$stmt = $pdo->prepare($sql);
$stmt->execute([$tool_slug]);
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
/**
* Applies database overrides to the default JSON field configuration.
*
* @param array $fields The fields array from tool_config.json.
* @param array $overrides The overrides from the getToolOverrides function.
* @param string $user_tier The user's current tier ('free', 'basic', 'gold', 'ultimate').
* @return array The final, filtered list of fields the user can access.
*/
function applyOverrides(array $fields, array $overrides, string $user_tier): array {
$final_fields = [];
$tier_levels = ['free' => 0, 'basic' => 1, 'gold' => 2, 'ultimate' => 3];
$user_level = $tier_levels[$user_tier];
$override_map = [];
foreach($overrides as $o) {
$override_map[$o['field_id']] = $o;
}
foreach ($fields as $field) {
$field_id = $field['id'];
$is_accessible = true;
if (isset($override_map[$field_id])) {
$override = $override_map[$field_id];
if ($override['override_type'] === 'disabled') {
$is_accessible = false;
} elseif ($override['override_type'] === 'tier') {
$required_level = $tier_levels[$override['tier_required']];
if ($user_level < $required_level) {
$is_accessible = false;
}
}
} else {
// Default pro_only check from JSON if no override exists
if ($field['pro_only'] && $user_level < $tier_levels['basic']) {
$is_accessible = false;
}
}
$field['is_accessible'] = $is_accessible;
$final_fields[] = $field;
}
return $final_fields;
}
Model
ThinkingThoughts
(experimental)
Auto
Expand to view model thoughts
chevron_right
FILE 10: /home/breaking-news-generator.digitalprank.com/public_html/setup_assets.sh
code
Bash
#!/bin/bash
set -e
TOOL_SLUG="breaking-news-generator"
TOOL_DIR="/home/${TOOL_SLUG}.digitalprank.com/public_html"
ASSETS_DIR="${TOOL_DIR}/assets"
TPL_DIR="${ASSETS_DIR}/templates"
FONT_DIR="${ASSETS_DIR}/fonts"
WEB_USER="www-data"
echo "--- Setting up required assets for ${TOOL_SLUG} ---"
# 1. Ensure directories exist
echo "--> Verifying directories..."
sudo mkdir -p ${TPL_DIR} ${FONT_DIR}
# 2. Install font package and copy font
# We'll use the DejaVu font which is widely available and has good coverage.
echo "--> Installing fonts and copying to assets..."
sudo apt-get update
sudo apt-get install -y fonts-dejavu-core
if [ -f "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf" ]; then
sudo cp /usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf "${FONT_DIR}/Helvetica-Bold.ttf"
echo "Font successfully copied."
else
echo "ERROR: Font file not found. Please install 'fonts-dejavu-core' manually and copy the font."
exit 1
fi
# 3. Generate placeholder template images
echo "--> Generating placeholder news templates..."
# CNN Style (Red)
sudo convert -size 1280x720 xc:"#CC0000" \
-fill white -gravity South -pointsize 30 -annotate +0+50 "CNN STYLE TEMPLATE" \
-gravity NorthEast -pointsize 20 -annotate +20+20 "LOGO" \
"${TPL_DIR}/cnn_style.png"
# BBC Style (White with Red Bar)
sudo convert -size 1280x720 xc:white \
-fill red -draw "rectangle 0,620 1280,720" \
-fill black -gravity center -pointsize 30 -annotate +0+0 "BBC STYLE TEMPLATE" \
"${TPL_DIR}/bbc_style.png"
# Fox News Style (Blue with Lower Third)
sudo convert -size 1280x720 xc:"#003366" \
-fill "#00000080" -draw "rectangle 0,550 1280,720" \
-fill white -gravity South -pointsize 30 -annotate +0+50 "FOX NEWS STYLE TEMPLATE" \
"${TPL_DIR}/fox_style.png"
# Twitter/X Post (Light Gray BG)
sudo convert -size 800x600 xc:"#E1E8ED" \
-fill black -gravity center -pointsize 30 -annotate +0+0 "TWITTER/X STYLE TEMPLATE" \
-bordercolor "#CCD6DD" -border 1 \
"${TPL_DIR}/mobile_tweet.png"
# TV News Ticker (Placeholder Image with transparent bar area)
sudo convert -size 1280x720 canvas:lightblue \
-fill black -gravity center -pointsize 30 -annotate +0+-50 "TV TICKER BACKGROUND" \
-fill "#00000000" -draw "rectangle 0,600 1280,720" \
"${TPL_DIR}/tv_ticker.png"
# YouTube Stream Screenshot (Video placeholder)
sudo convert -size 1280x720 xc:black \
-fill white -gravity center -pointsize 30 -annotate +0+0 "YOUTUBE STREAM TEMPLATE" \
-fill red -draw "rectangle 50,650 150,690" \
-fill white -gravity SouthWest -pointsize 20 -annotate +60+45 "LIVE" \
"${TPL_DIR}/youtube_breaking.png"
echo "All placeholder templates created."
# 4. Set Ownership
echo "--> Setting ownership for assets directory..."
sudo chown -R ${WEB_USER}:${WEB_USER} ${ASSETS_DIR}
sudo chmod -R 755 ${ASSETS_DIR}
echo "--- Asset setup complete! ---"
FILE 11: /home/breaking-news-generator.digitalprank.com/public_html/.gitignore
code
Code
# Generated content and user uploads
/output/
/uploads/
# Python virtual environment
/venv/
# Log files
*.log
logs/*.log
# System files
.DS_Store
Thumbs.db
# Editor backup files
*~
*.swp
*.swo
Model
ThinkingThoughts
(experimental)
Auto
Expand to view model thoughts
chevron_right
FILE 12: /home/breaking-news-generator.digitalprank.com/public_html/history.php
code
PHP
setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$stmt = $pdo->prepare(
"SELECT headline, subheadline, template, output_file, created_at
FROM {$db_table}
WHERE user_id = ? AND deleted_at IS NULL
ORDER BY created_at DESC
LIMIT 50"
);
$stmt->execute([$user_id]);
$history_items = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (PDOException $e) {
$error_message = 'Database error: Could not retrieve history.';
}
?>
My History -
FILE 16: /home/breaking-news-generator.digitalprank.com/public_html/README.md
code
Markdown
# README: Breaking News Generator
This document provides a technical overview for developers working on the Breaking News Generator tool.
## Tool Overview
- **Name:** Breaking News Generator
- **Slug:** `breaking-news-generator`
- **Purpose:** Allows users to create prank breaking news images and short videos from custom text inputs and predefined templates.
## File Structure
/home/breaking-news-generator.digitalprank.com/public_html/
|
├── assets/
| ├── css/
| | └── style.css # Main stylesheet for front-end pages
| ├── js/
| | └── main.js # Main JavaScript for form handling and AJAX
| ├── fonts/
| | └── Helvetica-Bold.ttf # Font used for text rendering
| └── templates/
| ├── cnn_style.png # Image templates for generation
| └── ...
|
├── output/ # Dynamically generated user content (images, videos)
├── uploads/ # User-uploaded custom logos
├── venv/ # Python virtual environment for video processing
|
├── tool_config.json # Core JSON configuration for the tool
├── processor.php # Back-end processing logic (validation, image generation)
├── tool_form.php # Main user-facing HTML form
├── history.php # Page to display user's generation history
├── diagnostic.php # System health and dependency check script
├── generate_video.py # Python script for creating MP4 animations
├── help.md # Raw markdown for the help/documentation page
├── api_docs.md # Documentation for the public API
├── deploy.sh # Deployment script for server setup
├── setup_assets.sh # Script to generate placeholder templates and fonts
└── README.md # This file
code
Code
## Core Technologies
- **Back-end:** PHP 8.1+
- **Image Processing:** ImageMagick (via `convert` command-line tool)
- **Video Processing:** FFmpeg (via Python `moviepy` wrapper)
- **Front-end:** HTML, CSS, vanilla JavaScript (with AJAX)
- **Database:** MySQL (MariaDB)
## Setup & Deployment
1. **Prerequisites:** Ensure the server has PHP 8.1+, ImageMagick, FFmpeg, Python3, and `python3-venv` installed.
2. **Clone Repository:** Place the files in the target directory `/home/breaking-news-generator.digitalprank.com/`.
3. **Run Deployment Script:** Execute `bash deploy.sh`. This script will:
- Install required APT packages and PHP extensions.
- Set up the Python virtual environment and install dependencies (`pillow`, `moviepy`).
- Create the necessary database table (`custom_news_history`).
- Configure the OpenLiteSpeed virtual host.
- Set up log rotation.
4. **Generate Assets:** Run `bash setup_assets.sh` to create the placeholder template images and copy the required font file.
5. **Set Permissions:** The deployment script handles most permissions, but ensure `output/` and `uploads/` are writable by the web server user (`www-data`).
6. **DNS:** Point the subdomain `breaking-news-generator.digitalprank.com` to the server's IP address.
## How It Works
1. **`tool_form.php`**: The user interacts with a dynamic form generated based on `tool_config.json`.
2. **`main.js`**: On submission, an AJAX `POST` request containing form data is sent to `processor.php`.
3. **`processor.php`**:
- Authenticates the user and checks usage limits/permissions via `universal_functions.php`.
- Validates and sanitizes all inputs based on rules in `tool_config.json`.
- Constructs an ImageMagick `convert` command to overlay text (and custom logos) onto a base template image.
- Executes the command using `shell_exec()`, creating a PNG file in `/output`.
- If MP4 output is requested, it calls `generate_video.py` to animate the generated image.
- If PDF output is requested, it uses ImageMagick again to convert the PNG to PDF.
- Logs the transaction to the platform's usage tables.
- Stores a reference in `custom_news_history` if enabled.
- Returns a JSON response with the URL to the final generated file.
4. **`main.js`**: Receives the JSON response and displays the generated image/video or an error message to the user.