Implement new documentation system with categorized docs browser

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-11-07 10:52:35 +00:00
parent 0be96da2a0
commit b9d3d5a285
225 changed files with 837 additions and 0 deletions

346
modules/billing/docs.php Normal file
View file

@ -0,0 +1,346 @@
<?php
/**
* Documentation Browser
* Displays a list of documentation categories and allows viewing individual docs
*/
// Start session for navigation state
session_start();
// Include config
require_once(__DIR__ . '/includes/config.inc.php');
// Set the docs directory
$docsDir = __DIR__ . '/docs';
// Get action and doc parameters
$action = $_GET['action'] ?? 'list';
$doc = $_GET['doc'] ?? '';
/**
* Get all documentation folders with their metadata
*/
function getDocCategories($docsDir) {
$categories = [];
if (!is_dir($docsDir)) {
return $categories;
}
$folders = array_diff(scandir($docsDir), ['.', '..']);
foreach ($folders as $folder) {
$folderPath = $docsDir . '/' . $folder;
// Skip if not a directory
if (!is_dir($folderPath)) {
continue;
}
// Check for required files
$indexPath = $folderPath . '/index.php';
$metadataPath = $folderPath . '/metadata.json';
if (!file_exists($indexPath) || !file_exists($metadataPath)) {
continue;
}
// Read metadata
$metadata = json_decode(file_get_contents($metadataPath), true);
if (!$metadata) {
$metadata = [];
}
// Find icon file
$icon = '';
if (file_exists($folderPath . '/icon.png')) {
$icon = 'docs/' . $folder . '/icon.png';
} elseif (file_exists($folderPath . '/icon.jpg')) {
$icon = 'docs/' . $folder . '/icon.jpg';
}
$categories[] = [
'folder' => $folder,
'name' => $metadata['name'] ?? ucfirst($folder),
'description' => $metadata['description'] ?? '',
'category' => $metadata['category'] ?? 'other',
'order' => $metadata['order'] ?? 999,
'icon' => $icon
];
}
// Sort by category, then order, then name
usort($categories, function($a, $b) {
if ($a['category'] !== $b['category']) {
return strcmp($a['category'], $b['category']);
}
if ($a['order'] !== $b['order']) {
return $a['order'] - $b['order'];
}
return strcmp($a['name'], $b['name']);
});
return $categories;
}
// Get all categories
$categories = getDocCategories($docsDir);
// Group by category
$grouped = [];
foreach ($categories as $cat) {
$category = $cat['category'];
if (!isset($grouped[$category])) {
$grouped[$category] = [];
}
$grouped[$category][] = $cat;
}
// Category labels
$categoryLabels = [
'game' => 'Game Servers',
'panel' => 'Panel Documentation',
'mods' => 'Mods & Addons',
'troubleshooting' => 'Troubleshooting',
'other' => 'Other'
];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo $action === 'view' ? 'Documentation' : 'Documentation - GameServers.World'; ?></title>
<link rel="stylesheet" href="css/header.css">
<style>
:root {
--bg: #0f172a;
--card: #111827;
--text: #e5e7eb;
--muted: #94a3b8;
--accent: #38bdf8;
--border: #1f2937;
}
body {
background: var(--bg);
color: var(--text);
font: 16px/1.5 system-ui, -apple-system, Segoe UI, Roboto, Arial;
margin: 0;
}
.container {
max-width: 1200px;
margin: 0 auto;
padding: 40px 20px;
}
.header {
margin-bottom: 40px;
}
.header h1 {
font-size: 32px;
margin: 0 0 12px;
}
.header p {
color: var(--muted);
margin: 0;
}
.back-button {
display: inline-block;
padding: 10px 20px;
background: var(--card);
border: 1px solid var(--border);
border-radius: 8px;
color: var(--accent);
text-decoration: none;
margin-bottom: 20px;
transition: all 0.2s;
}
.back-button:hover {
background: #1f2937;
border-color: var(--accent);
}
.category-section {
margin-bottom: 40px;
}
.category-title {
font-size: 24px;
color: var(--accent);
margin: 0 0 20px;
padding-bottom: 10px;
border-bottom: 2px solid var(--border);
}
.docs-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
gap: 20px;
}
.doc-card {
background: var(--card);
border: 1px solid var(--border);
border-radius: 12px;
padding: 20px;
transition: all 0.2s;
text-decoration: none;
display: flex;
flex-direction: column;
}
.doc-card:hover {
border-color: var(--accent);
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(56, 189, 248, 0.1);
}
.doc-icon-wrapper {
width: 60px;
height: 60px;
background: #1f2937;
border-radius: 8px;
display: flex;
align-items: center;
justify-content: center;
margin-bottom: 15px;
}
.doc-icon {
max-width: 100%;
max-height: 100%;
border-radius: 6px;
}
.doc-icon-placeholder {
font-size: 28px;
color: var(--muted);
}
.doc-title {
font-size: 18px;
font-weight: 600;
color: var(--text);
margin: 0 0 8px;
}
.doc-description {
font-size: 14px;
color: var(--muted);
margin: 0;
flex-grow: 1;
}
.doc-view-container {
background: var(--card);
border: 1px solid var(--border);
border-radius: 12px;
padding: 30px;
min-height: 400px;
}
.doc-view-container h1,
.doc-view-container h2,
.doc-view-container h3,
.doc-view-container h4 {
color: var(--text);
}
.doc-view-container a {
color: var(--accent);
}
.doc-view-container code {
background: #1f2937;
padding: 2px 6px;
border-radius: 4px;
font-family: 'Courier New', monospace;
}
.doc-view-container pre {
background: #1f2937;
padding: 15px;
border-radius: 8px;
overflow-x: auto;
}
.doc-view-container pre code {
background: none;
padding: 0;
}
</style>
</head>
<body>
<?php include(__DIR__ . '/includes/menu.php'); ?>
<div class="container">
<?php if ($action === 'view' && !empty($doc)): ?>
<!-- View specific documentation -->
<a href="docs.php" class="back-button"> Back to Documentation List</a>
<div class="doc-view-container">
<?php
// Sanitize doc parameter to prevent directory traversal
$doc = basename($doc);
$docPath = $docsDir . '/' . $doc . '/index.php';
if (file_exists($docPath)) {
include($docPath);
} else {
echo '<p style="color: #ef4444;">Documentation not found.</p>';
}
?>
</div>
<?php else: ?>
<!-- List all documentation categories -->
<div class="header">
<h1>Documentation</h1>
<p>Browse our comprehensive documentation for game servers, panel features, and troubleshooting guides.</p>
</div>
<?php if (empty($grouped)): ?>
<div class="doc-view-container">
<p>No documentation available yet. Documentation folders should contain:</p>
<ul>
<li><code>index.php</code> - The documentation content</li>
<li><code>metadata.json</code> - Category and ordering information</li>
<li><code>icon.png</code> or <code>icon.jpg</code> - Category icon</li>
</ul>
</div>
<?php else: ?>
<?php foreach ($grouped as $category => $docs): ?>
<div class="category-section">
<h2 class="category-title"><?php echo htmlspecialchars($categoryLabels[$category] ?? ucfirst($category)); ?></h2>
<div class="docs-grid">
<?php foreach ($docs as $doc): ?>
<a href="docs.php?action=view&doc=<?php echo urlencode($doc['folder']); ?>" class="doc-card">
<div class="doc-icon-wrapper">
<?php if (!empty($doc['icon'])): ?>
<img src="<?php echo htmlspecialchars($doc['icon']); ?>" alt="" class="doc-icon">
<?php else: ?>
<span class="doc-icon-placeholder">📄</span>
<?php endif; ?>
</div>
<h3 class="doc-title"><?php echo htmlspecialchars($doc['name']); ?></h3>
<?php if (!empty($doc['description'])): ?>
<p class="doc-description"><?php echo htmlspecialchars($doc['description']); ?></p>
<?php endif; ?>
</a>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
<?php endif; ?>
</div>
</body>
</html>

View file

@ -0,0 +1,160 @@
# Documentation System
## Overview
The billing module now includes a flexible documentation browser that organizes documentation into categories with an easy-to-navigate interface.
## Structure
Documentation is organized in the `/modules/billing/docs/` folder with the following structure:
```
docs/
├── category-name-1/
│ ├── index.php (Required: Documentation content)
│ ├── metadata.json (Required: Category and ordering info)
│ └── icon.png or icon.jpg (Required: Category icon)
├── category-name-2/
│ ├── index.php
│ ├── metadata.json
│ └── icon.png
└── ...
```
## Creating New Documentation
### 1. Create a Folder
Create a new folder in `/modules/billing/docs/` with a descriptive name (lowercase, hyphens for spaces):
```bash
mkdir /modules/billing/docs/my-new-doc
```
### 2. Create metadata.json
This file defines how the documentation appears in the list:
```json
{
"name": "My Documentation Title",
"description": "A brief description of this documentation",
"category": "game",
"order": 10
}
```
**Fields:**
- `name`: Display name shown in the documentation list
- `description`: Brief description shown on the card
- `category`: One of: `game`, `panel`, `mods`, `troubleshooting`, `other`
- `order`: Sort order within the category (lower numbers appear first)
### 3. Create index.php
This file contains the actual documentation content. Use PHP and HTML:
```php
<?php
/**
* My Documentation
*/
?>
<h1>My Documentation Title</h1>
<h2>Section 1</h2>
<p>Your content here...</p>
<h3>Subsection</h3>
<ul>
<li>Item 1</li>
<li>Item 2</li>
</ul>
<h2>Code Examples</h2>
<pre><code>
# Your code here
command --option value
</code></pre>
```
The documentation system automatically styles:
- Headings (h1-h4)
- Links (styled with accent color)
- Code blocks (with dark background)
- Lists and other HTML elements
### 4. Add an Icon
Add either `icon.png` or `icon.jpg` to the folder. Recommended size: 60x60 pixels or larger (will be scaled down).
If no icon is provided, a default document emoji (📄) will be shown.
## Categories
Documentation is organized into these categories:
- **game** - Game-specific server guides
- **panel** - Panel usage and features
- **mods** - Mods and addon documentation
- **troubleshooting** - Problem-solving guides
- **other** - Miscellaneous documentation
Categories are sorted and labeled automatically on the documentation page.
## Example Documentation
See the included examples:
1. **minecraft** - Game server documentation example
2. **getting-started** - Panel documentation example
3. **common-issues** - Troubleshooting documentation example
## Accessing Documentation
Users can access documentation at:
- `/modules/billing/docs.php` - Main documentation list
- `/modules/billing/docs.php?action=view&doc=folder-name` - Specific doc
A "Documentation" link is added to the main navigation menu.
## Best Practices
1. **Keep it Organized**: Use clear, descriptive folder names
2. **Consistent Naming**: Use lowercase and hyphens (e.g., `my-game-guide`)
3. **Good Descriptions**: Write helpful metadata descriptions
4. **Visual Icons**: Use recognizable icons for each category
5. **Test Content**: Preview documentation after creating it
6. **Regular Updates**: Keep documentation current with panel changes
## Migration from Old System
The old docs folder with game markdown files has been moved to `/modules/billing/docs_old/` for reference. The new system provides:
- Better organization by category
- Consistent styling
- Easier navigation
- Extensible structure for any type of documentation
To migrate old documentation:
1. Create a new folder for each document
2. Convert markdown to HTML in index.php
3. Add appropriate metadata.json
4. Add an icon image
## Troubleshooting
### Documentation not appearing
- Check that folder has all three required files (index.php, metadata.json, icon)
- Verify metadata.json is valid JSON
- Ensure file permissions allow reading
### Styling issues
- The system uses inline styles from docs.php
- Custom styles in index.php may conflict
- Keep content semantic (use proper HTML tags)
### Icons not showing
- Check file exists and is named exactly `icon.png` or `icon.jpg`
- Verify image file is not corrupted
- Try a smaller image size if very large

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 B

View file

@ -0,0 +1,128 @@
<?php
/**
* Common Issues & Troubleshooting Documentation
*/
?>
<h1>Common Issues & Solutions</h1>
<h2>Server Won't Start</h2>
<h3>Symptoms</h3>
<ul>
<li>Server status shows "Stopped" even after clicking Start</li>
<li>Server starts but immediately crashes</li>
<li>Error messages in the console</li>
</ul>
<h3>Solutions</h3>
<ol>
<li><strong>Check Server Logs:</strong> Review the console output for error messages</li>
<li><strong>Verify Configuration:</strong> Ensure config files have correct syntax</li>
<li><strong>Check Port Conflicts:</strong> Make sure the port isn't already in use</li>
<li><strong>Memory Issues:</strong> Verify you have enough RAM allocated</li>
<li><strong>File Permissions:</strong> Ensure server files have correct permissions</li>
</ol>
<h2>Can't Connect to Server</h2>
<h3>Symptoms</h3>
<ul>
<li>Connection timeout when trying to join</li>
<li>"Server not responding" errors</li>
<li>Can't find server in server list</li>
</ul>
<h3>Solutions</h3>
<ol>
<li><strong>Verify Server is Running:</strong> Check control panel status</li>
<li><strong>Check IP and Port:</strong> Ensure you're using the correct address</li>
<li><strong>Firewall Settings:</strong> Make sure firewall allows the server port</li>
<li><strong>Server Whitelist:</strong> Check if server has whitelist enabled</li>
<li><strong>Game Version:</strong> Ensure your game version matches the server</li>
</ol>
<h2>Server Lag</h2>
<h3>Symptoms</h3>
<ul>
<li>Delayed responses to player actions</li>
<li>Rubber-banding or teleporting players</li>
<li>High ping times</li>
</ul>
<h3>Solutions</h3>
<ol>
<li><strong>Check Server Resources:</strong> Monitor CPU and RAM usage in control panel</li>
<li><strong>Reduce View Distance:</strong> Lower render distance in server config</li>
<li><strong>Limit Entities:</strong> Use plugins to limit mob spawning</li>
<li><strong>Optimize Plugins/Mods:</strong> Remove or update poorly performing addons</li>
<li><strong>Upgrade Plan:</strong> Consider upgrading to a higher-tier server</li>
</ol>
<h2>File Upload Issues</h2>
<h3>Symptoms</h3>
<ul>
<li>FTP connection refused</li>
<li>Can't upload files</li>
<li>Files upload but don't appear on server</li>
</ul>
<h3>Solutions</h3>
<ol>
<li><strong>Check FTP Credentials:</strong> Verify username and password are correct</li>
<li><strong>FTP Mode:</strong> Try switching between active and passive FTP mode</li>
<li><strong>File Size Limits:</strong> Check if file exceeds maximum upload size</li>
<li><strong>Directory Permissions:</strong> Ensure you have write permissions</li>
<li><strong>Stop Server First:</strong> Some files can't be modified while server runs</li>
</ol>
<h2>Mods/Plugins Not Working</h2>
<h3>Symptoms</h3>
<ul>
<li>Mods don't load</li>
<li>Plugin commands don't work</li>
<li>Server crashes when loading mods</li>
</ul>
<h3>Solutions</h3>
<ol>
<li><strong>Check Compatibility:</strong> Ensure mod/plugin matches server version</li>
<li><strong>Verify Dependencies:</strong> Install required dependency mods</li>
<li><strong>Check Installation Path:</strong> Files must be in correct folder</li>
<li><strong>Review Logs:</strong> Check for mod/plugin loading errors</li>
<li><strong>Update Software:</strong> Make sure mods and server are up to date</li>
</ol>
<h2>World Data Loss</h2>
<h3>Prevention</h3>
<ul>
<li>Make regular backups via FTP or control panel</li>
<li>Always stop server properly before shutting down</li>
<li>Don't force-stop unless absolutely necessary</li>
<li>Test configuration changes on backup worlds first</li>
</ul>
<h3>Recovery</h3>
<ol>
<li>Check if control panel has automatic backups</li>
<li>Restore from your most recent manual backup</li>
<li>Contact support if no backups are available</li>
</ol>
<h2>Getting Further Help</h2>
<p>If these solutions don't resolve your issue:</p>
<ul>
<li>Check the specific documentation for your game server type</li>
<li>Review server logs for detailed error messages</li>
<li>Contact support with:
<ul>
<li>Detailed description of the problem</li>
<li>Steps to reproduce the issue</li>
<li>Recent changes made to the server</li>
<li>Relevant error messages or screenshots</li>
</ul>
</li>
</ul>

View file

@ -0,0 +1,6 @@
{
"name": "Common Issues & Solutions",
"description": "Troubleshooting guide for common server problems",
"category": "troubleshooting",
"order": 1
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 B

View file

@ -0,0 +1,93 @@
<?php
/**
* Getting Started Documentation
*/
?>
<h1>Getting Started with GameServers.World</h1>
<h2>Welcome!</h2>
<p>Thank you for choosing GameServers.World for your game server hosting needs. This guide will help you get started with your new server.</p>
<h2>After Purchase</h2>
<p>Once your payment is processed, you'll receive:</p>
<ul>
<li>A confirmation email with your server details</li>
<li>Access to the control panel at <a href="http://panel.iaregamer.com" target="_blank">panel.iaregamer.com</a></li>
<li>FTP credentials for file management</li>
<li>Server IP address and port</li>
</ul>
<h2>Accessing Your Server</h2>
<h3>Control Panel</h3>
<ol>
<li>Visit <a href="http://panel.iaregamer.com" target="_blank">panel.iaregamer.com</a></li>
<li>Log in with your account credentials</li>
<li>Select your server from "My Servers"</li>
<li>Use the control panel to start, stop, restart, and configure your server</li>
</ol>
<h3>FTP Access</h3>
<p>To upload files, mods, or plugins to your server:</p>
<ol>
<li>Download an FTP client like <a href="https://filezilla-project.org/" target="_blank">FileZilla</a></li>
<li>Use the FTP credentials from your account dashboard</li>
<li>Connect to your server</li>
<li>Upload your files to the appropriate directories</li>
</ol>
<h2>Server Management</h2>
<h3>Starting Your Server</h3>
<ol>
<li>Log into the control panel</li>
<li>Select your server</li>
<li>Click the "Start" button</li>
<li>Wait for the server to initialize (usually 30-60 seconds)</li>
</ol>
<h3>Stopping Your Server</h3>
<ol>
<li>Click the "Stop" button in the control panel</li>
<li>Wait for the server to shut down gracefully</li>
<li>Never force-stop unless absolutely necessary</li>
</ol>
<h3>Restarting Your Server</h3>
<ol>
<li>Use the "Restart" button to stop and start in one action</li>
<li>Useful after configuration changes or mod installations</li>
</ol>
<h2>Configuration</h2>
<p>Each game server has its own configuration files. Common locations include:</p>
<ul>
<li><strong>Config files:</strong> Usually in the server root or a <code>config/</code> folder</li>
<li><strong>Mods/Plugins:</strong> In <code>mods/</code> or <code>plugins/</code> folders</li>
<li><strong>World data:</strong> In <code>world/</code> or game-specific folders</li>
</ul>
<h2>Backups</h2>
<p>Always make regular backups of your server data:</p>
<ul>
<li>Use the control panel's backup feature if available</li>
<li>Download important files via FTP regularly</li>
<li>Keep backups before making major changes</li>
</ul>
<h2>Getting Help</h2>
<p>If you need assistance:</p>
<ul>
<li>Check the game-specific documentation for your server type</li>
<li>Review the troubleshooting guides</li>
<li>Contact support through your account dashboard</li>
<li>Check our community forums for tips and solutions</li>
</ul>
<h2>Next Steps</h2>
<ul>
<li>Explore the control panel features</li>
<li>Read the documentation for your specific game</li>
<li>Customize your server settings</li>
<li>Invite players and start gaming!</li>
</ul>

View file

@ -0,0 +1,6 @@
{
"name": "Getting Started",
"description": "Learn how to use the game server panel and manage your servers",
"category": "panel",
"order": 1
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 B

View file

@ -0,0 +1,91 @@
<?php
/**
* Minecraft Server Documentation
*/
?>
<h1>Minecraft Server Guide</h1>
<h2>Overview</h2>
<p>Minecraft is one of the most popular sandbox games in the world. This guide will help you set up and manage your Minecraft Java Edition server.</p>
<h2>Getting Started</h2>
<p>Once your Minecraft server is provisioned, you can connect to it using the server IP and port provided in your account dashboard.</p>
<h3>Server Details</h3>
<ul>
<li><strong>Default Port:</strong> 25565</li>
<li><strong>Protocol:</strong> TCP/UDP</li>
<li><strong>Supported Versions:</strong> 1.8 - Latest</li>
</ul>
<h2>Configuration</h2>
<p>You can customize your server using the <code>server.properties</code> file. Common settings include:</p>
<h3>Server Properties</h3>
<pre><code># Server name
motd=Welcome to My Minecraft Server
# Game mode (survival, creative, adventure, spectator)
gamemode=survival
# Difficulty (peaceful, easy, normal, hard)
difficulty=normal
# Maximum players
max-players=20
# Enable PvP
pvp=true
# View distance (in chunks)
view-distance=10
</code></pre>
<h2>Installing Plugins</h2>
<p>To add plugins to your server, you'll need to use a modified server like Spigot or Paper:</p>
<ol>
<li>Download plugins from <a href="https://www.spigotmc.org/resources/" target="_blank">SpigotMC</a> or <a href="https://hangar.papermc.io/" target="_blank">Hangar</a></li>
<li>Upload the <code>.jar</code> files to your server's <code>plugins</code> folder via FTP</li>
<li>Restart your server</li>
<li>Configure plugins in their respective config files in <code>plugins/[PluginName]/</code></li>
</ol>
<h2>Common Issues</h2>
<h3>Players Can't Connect</h3>
<ul>
<li>Verify the server is running in your control panel</li>
<li>Check that you're using the correct IP address and port</li>
<li>Ensure your firewall allows Minecraft traffic on port 25565</li>
</ul>
<h3>Server Lag</h3>
<ul>
<li>Reduce view distance in <code>server.properties</code></li>
<li>Limit entity spawning with plugins like ClearLagg</li>
<li>Upgrade to a server with more RAM if needed</li>
<li>Use performance-optimized server software like Paper</li>
</ul>
<h3>World Corruption</h3>
<ul>
<li>Always make regular backups of your world folder</li>
<li>Stop the server properly before making changes</li>
<li>Use world management plugins to prevent corruption</li>
</ul>
<h2>Recommended Plugins</h2>
<ul>
<li><strong>EssentialsX</strong> - Core commands and features</li>
<li><strong>WorldEdit</strong> - In-game world editing</li>
<li><strong>LuckPerms</strong> - Advanced permission management</li>
<li><strong>Vault</strong> - Economy and permissions API</li>
<li><strong>WorldGuard</strong> - Region protection</li>
</ul>
<h2>Further Resources</h2>
<ul>
<li><a href="https://minecraft.fandom.com/wiki/Server.properties" target="_blank">Minecraft Wiki - Server Properties</a></li>
<li><a href="https://www.spigotmc.org/" target="_blank">SpigotMC Community</a></li>
<li><a href="https://papermc.io/" target="_blank">PaperMC Official Site</a></li>
</ul>

View file

@ -0,0 +1,6 @@
{
"name": "Minecraft Server",
"description": "Complete guide for hosting and managing Minecraft Java Edition servers",
"category": "game",
"order": 1
}

Some files were not shown because too many files have changed in this diff Show more