fixed cart.php issue

This commit is contained in:
Frank Harris 2025-11-10 18:03:04 -05:00
parent be1e5e7826
commit 01d56a897d
4 changed files with 359 additions and 33 deletions

View file

@ -0,0 +1,266 @@
# Recent Fixes & Enhancements Summary
**Date:** November 10, 2025
## Critical Fixes Completed ✅
### 1. PayPal Payment Capture Session Issue (FIXED)
**Problem:** Payment capture was failing with `NO_USER_SESSION` error even though user was logged in.
**Root Cause:** The `api/capture_order.php` file was calling `session_start()` without setting the session name first, so it couldn't access the `gameservers_website` session where the user_id is stored.
**Solution:** Added `session_name("gameservers_website")` before `session_start()` in `capture_order.php`.
**File Modified:** `modules/billing/api/capture_order.php` (line ~148)
**Test Steps:**
1. Log into the billing site
2. Add a server to cart
3. Click PayPal checkout button
4. Complete payment in PayPal sandbox
5. Verify payment completes successfully and redirects to success page
6. Check `modules/billing/logs/payment_capture.log` - should no longer show `NO_USER_SESSION` error
---
### 2. Cart Page Debug Logging Removed (COMPLETED)
**What Was Removed:**
- Shutdown function that logged to `data/debug_cart.log`
- `?debug_cart=1` parameter handling
- Debug error display code
**File Modified:** `modules/billing/cart.php` (lines 1-30)
**Result:** Cart page now runs in production mode without debug overhead.
---
### 3. Cart Page Header/Footer Consistency (FIXED)
**Problem:** Cart page had different fonts and styling than other billing pages; missing footer entirely.
**Solutions Applied:**
1. Added `include(__DIR__ . '/includes/top.php');` before menu
2. Added `include(__DIR__ . '/includes/footer.php');` at page end
3. Removed global `font-family` and `background` override from inline CSS
4. Added favicon links to match other pages
**Files Modified:**
- `modules/billing/cart.php` (head section and body closing)
**Result:** Cart page now has consistent header/menu/footer with rest of billing module.
---
## Documentation Enhancements Started 📚
### 4. Minecraft Documentation Updated (TEMPLATE CREATED)
**What Was Added:**
- Comprehensive **Ports section** with table showing all ports (TCP 25565, UDP 25565, TCP 25575, UDP 19132)
- Port purposes clearly explained
- Firewall configuration examples for multiple platforms
- Security notes for RCON and port protection
- Enhanced navigation with icons (🔌 Ports, ⚙️ Startup Parameters, 🔧 Troubleshooting)
**File Modified:** `modules/billing/docs/minecraft/index.php`
**Template Pattern Established:**
- ✅ Quick Info section (at top)
- ✅ Ports section with complete table
- ✅ Installation steps
- ✅ Configuration examples
- ✅ Startup Parameters section (already excellent)
- ✅ Troubleshooting section (already comprehensive)
- ✅ Performance optimization
- ✅ Security best practices
---
## Remaining Documentation Work 📋
### Games Needing Full Port/Parameter/Troubleshooting Docs
The following games need their `docs/{game}/index.php` files updated with the Minecraft template pattern:
#### High Priority Games (Popular):
1. **Counter-Strike: Global Offensive** (`csgo/`)
2. **Team Fortress 2** (`tf2/`)
3. **Garry's Mod** (`garrysmod/`)
4. **Rust** (`rust/`)
5. **ARK: Survival Evolved** (`arkse/`)
6. **Terraria** (`terraria/`)
7. **Valheim** (`valheim/`)
8. **7 Days to Die** (`7daystodie/`)
9. **DayZ** (`dayz/`)
10. **Left 4 Dead 2** (`left4dead2/`)
#### Medium Priority:
11. Counter-Strike Source (`css/`)
12. Arma 3 (`arma3/`)
13. Squad (`squad/`)
14. Insurgency Sandstorm (`insurgencysandstorm/`)
15. Space Engineers (`space_engineers/`)
16. Conan Exiles (`conanexiles/`)
17. The Forest (`theforest/`)
18. Don't Starve Together (`dontstarvetogether/`)
19. Factorio (`factorio/`)
20. TeamSpeak 3 (`teamspeak3/`)
#### Lower Priority (Legacy/Niche):
21. All remaining games in `modules/billing/docs/`
---
### Research Needed Per Game
For each game, research and document:
1. **All Network Ports:**
- Game port (TCP/UDP)
- Query port
- RCON/Admin port
- Voice chat ports (if applicable)
- Steam port (if Steam-based)
- Additional service ports (web interfaces, etc.)
2. **Startup Parameters:**
- Command-line flags
- Memory allocation
- Server configuration switches
- Performance optimization flags
3. **Common Issues (from internet research):**
- "Server won't start" specific to that game
- Connection problems
- Performance/lag issues specific to game engine
- Mod/plugin conflicts
- Save corruption issues
- Update/patch problems
4. **Game-Specific Configuration:**
- Main config file locations
- Critical settings
- Player limits
- World/map settings
---
### Documentation Template Structure
Each game's `index.php` should follow this structure:
```php
<?php
/**
* {Game Name} Server Documentation
*/
?>
<!-- Navigation with icons -->
<div style="background: #1e3a5f...">
<h3>📚 Quick Navigation</h3>
<div>
<a href="#quick-info">Quick Info</a>
<a href="#ports">🔌 Ports</a>
<a href="#installation">Installation</a>
<a href="#configuration">Configuration</a>
<a href="#parameters">⚙️ Startup Parameters</a>
<a href="#troubleshooting">🔧 Troubleshooting</a>
<a href="#performance">Performance</a>
</div>
</div>
<h1>{Game Name} Server Hosting Guide</h1>
<h2 id="quick-info">Quick Info</h2>
<!-- Key stats in styled box -->
<h2 id="ports">🔌 Network Ports Used</h2>
<!-- Table with all ports, protocols, purposes, required/optional -->
<!-- Firewall examples -->
<!-- Port security notes -->
<h2 id="installation">Installation & Setup</h2>
<!-- Step-by-step installation -->
<h2 id="configuration">Server Configuration</h2>
<!-- Config file examples -->
<h2 id="parameters">⚙️ Startup Parameters</h2>
<!-- Command-line flags -->
<!-- Parameter explanations -->
<h2 id="troubleshooting">🔧 Troubleshooting</h2>
<!-- Common Issues section -->
<!-- Server Won't Start -->
<!-- Connection Problems -->
<!-- Performance Issues -->
<!-- Game-specific problems -->
<h2 id="performance">Performance Optimization</h2>
<!-- Optimization tips -->
<!-- Additional Resources -->
<!-- Important Notes -->
```
---
## Testing Checklist
### PayPal Payment Flow:
- [ ] Log into billing site
- [ ] Add server to cart
- [ ] Apply coupon (optional)
- [ ] Click PayPal button
- [ ] Complete sandbox payment
- [ ] Verify success page loads
- [ ] Check invoice marked as paid in database
- [ ] Verify no `NO_USER_SESSION` in `logs/payment_capture.log`
### Cart Page:
- [ ] Cart page loads with correct header/menu (same font as index.php)
- [ ] Footer appears with timestamp
- [ ] Favicon displays in browser tab
- [ ] Remove item (trash icon) works via AJAX
- [ ] Cart refreshes without full page reload after removal
- [ ] Database row hard-deleted (invoice removed from table)
### Documentation:
- [ ] Navigate to `/docs.php` (or docs index)
- [ ] Click on Minecraft documentation
- [ ] Verify new Ports section displays correctly
- [ ] Verify navigation links jump to correct sections
- [ ] Test on mobile/tablet for responsive layout
---
## Next Steps (Priority Order)
1. **Test PayPal payment flow end-to-end** (sandbox environment)
2. **Verify cart removal functionality** (AJAX + database deletion)
3. **Begin documentation expansion:**
- Start with top 10 popular games
- Research ports/parameters/issues for each
- Update docs using Minecraft template
- Test navigation and layout
4. **Consider automation:**
- Script to validate all game docs have required sections
- Port information database/reference
- Common troubleshooting template generator
---
## Files Modified in This Session
1. `modules/billing/api/capture_order.php` - Fixed session name issue
2. `modules/billing/cart.php` - Removed debug logging, fixed header/footer
3. `modules/billing/docs/minecraft/index.php` - Added ports section, enhanced navigation
## Files to Review
- `modules/billing/logs/payment_capture.log` - Check for successful captures
- `modules/billing/data/debug_cart.log` - Should no longer be written to
- Database table `{$table_prefix}billing_invoices` - Verify removals are hard-deleted
---
**End of Summary**

View file

@ -136,8 +136,11 @@ log_payment('PAYMENT_CAPTURED', [
'payer_name' => trim($payer_name)
]);
// Start session to get user_id
session_start();
// Start session to get user_id (use billing website session name)
if (session_status() === PHP_SESSION_NONE) {
session_name("gameservers_website");
session_start();
}
$user_id = isset($_SESSION['website_user_id']) ? intval($_SESSION['website_user_id']) :
(isset($_SESSION['user_id']) ? intval($_SESSION['user_id']) : 0);

View file

@ -1,32 +1,4 @@
<?php
// Debugging helper: enable when visiting with ?debug_cart=1
$debug_cart = isset($_GET['debug_cart']) && $_GET['debug_cart'] === '1';
if ($debug_cart) {
// Show all errors for immediate feedback
@ini_set('display_errors', '1');
@ini_set('display_startup_errors', '1');
@error_reporting(E_ALL);
}
// Register a shutdown function to capture fatal errors and write diagnostics to a debug log
register_shutdown_function(function() use ($debug_cart) {
$err = error_get_last();
$logPath = __DIR__ . '/data';
if (!is_dir($logPath)) @mkdir($logPath, 0755, true);
$logFile = $logPath . '/debug_cart.log';
$out = "[" . date('Y-m-d H:i:s') . "] SHUTDOWN: ";
if ($err) {
$out .= json_encode($err) . "\n";
} else {
$out .= "no error\n";
}
@file_put_contents($logFile, $out, FILE_APPEND | LOCK_EX);
if ($debug_cart && $err) {
echo '<pre style="background:#fff7e6;border:1px solid #e6b800;padding:10px;">';
echo "Shutdown error:\n" . htmlspecialchars(print_r($err, true));
echo '</pre>';
}
});
/**
* Shopping Cart - Rebuilt from scratch for reliability
* Displays unpaid invoices and provides PayPal checkout

View file

@ -5,14 +5,15 @@
*/
?>
<div style="background: #1e3a5f; padding: 20px; border-left: 4px solid #3b82f6; margin: 20px 0; border-radius: 4px;">
<h3 style="color: #ffffff; margin-top: 0;">Navigation</h3>
<h3 style="color: #ffffff; margin-top: 0;">📚 Quick Navigation</h3>
<div style="display: flex; flex-wrap: wrap; gap: 10px;">
<a href="#quick-info" style="background: #0f172a; padding: 8px 16px; border-radius: 4px; color: #a5b4fc; text-decoration: none;">Quick Info</a>
<a href="#ports" style="background: #0f172a; padding: 8px 16px; border-radius: 4px; color: #a5b4fc; text-decoration: none;">🔌 Ports</a>
<a href="#installation" style="background: #0f172a; padding: 8px 16px; border-radius: 4px; color: #a5b4fc; text-decoration: none;">Installation</a>
<a href="#configuration" style="background: #0f172a; padding: 8px 16px; border-radius: 4px; color: #a5b4fc; text-decoration: none;">Configuration</a>
<a href="#parameters" style="background: #0f172a; padding: 8px 16px; border-radius: 4px; color: #a5b4fc; text-decoration: none;">Parameters</a>
<a href="#parameters" style="background: #0f172a; padding: 8px 16px; border-radius: 4px; color: #a5b4fc; text-decoration: none;">⚙️ Startup Parameters</a>
<a href="#plugins-mods" style="background: #0f172a; padding: 8px 16px; border-radius: 4px; color: #a5b4fc; text-decoration: none;">Plugins & Mods</a>
<a href="#troubleshooting" style="background: #0f172a; padding: 8px 16px; border-radius: 4px; color: #a5b4fc; text-decoration: none;">Troubleshooting</a>
<a href="#troubleshooting" style="background: #0f172a; padding: 8px 16px; border-radius: 4px; color: #a5b4fc; text-decoration: none;">🔧 Troubleshooting</a>
<a href="#performance" style="background: #0f172a; padding: 8px 16px; border-radius: 4px; color: #a5b4fc; text-decoration: none;">Performance</a>
<a href="#security" style="background: #0f172a; padding: 8px 16px; border-radius: 4px; color: #a5b4fc; text-decoration: none;">Security</a>
</div>
@ -38,6 +39,90 @@
</ul>
</div>
<h2 id="ports">🔌 Network Ports Used</h2>
<div style="background: #1e3a5f; padding: 20px; border-left: 4px solid #3b82f6; margin: 20px 0; border-radius: 4px;">
<h3 style="color: #ffffff; margin-top: 0;">Required Ports</h3>
<table style="width: 100%; color: #e5e7eb; border-collapse: collapse;">
<thead>
<tr style="background: #0f172a;">
<th style="padding: 10px; text-align: left; color: #ffffff;">Port</th>
<th style="padding: 10px; text-align: left; color: #ffffff;">Protocol</th>
<th style="padding: 10px; text-align: left; color: #ffffff;">Purpose</th>
<th style="padding: 10px; text-align: left; color: #ffffff;">Required?</th>
</tr>
</thead>
<tbody>
<tr style="border-bottom: 1px solid #374151;">
<td style="padding: 10px;"><code style="background: #0f172a; padding: 2px 6px; border-radius: 3px;">25565</code></td>
<td style="padding: 10px;">TCP</td>
<td style="padding: 10px;">Main game connection (players connect here)</td>
<td style="padding: 10px;"><span style="color: #10b981;"> Yes</span></td>
</tr>
<tr style="border-bottom: 1px solid #374151;">
<td style="padding: 10px;"><code style="background: #0f172a; padding: 2px 6px; border-radius: 3px;">25565</code></td>
<td style="padding: 10px;">UDP</td>
<td style="padding: 10px;">Server query protocol (for server lists)</td>
<td style="padding: 10px;"><span style="color: #f59e0b;"> Optional</span></td>
</tr>
<tr style="border-bottom: 1px solid #374151;">
<td style="padding: 10px;"><code style="background: #0f172a; padding: 2px 6px; border-radius: 3px;">25575</code></td>
<td style="padding: 10px;">TCP</td>
<td style="padding: 10px;">RCON (remote console administration)</td>
<td style="padding: 10px;"><span style="color: #f59e0b;"> Optional</span></td>
</tr>
<tr>
<td style="padding: 10px;"><code style="background: #0f172a; padding: 2px 6px; border-radius: 3px;">19132</code></td>
<td style="padding: 10px;">UDP</td>
<td style="padding: 10px;">Bedrock Edition (if running Geyser plugin)</td>
<td style="padding: 10px;"><span style="color: #f59e0b;"> Optional</span></td>
</tr>
</tbody>
</table>
<h3 style="color: #ffffff; margin-top: 20px;">Firewall Configuration Examples</h3>
<p style="color: #e5e7eb;">Allow Minecraft server through your firewall:</p>
<pre><code style="color: #a5b4fc;"># UFW (Ubuntu/Debian)
sudo ufw allow 25565/tcp comment 'Minecraft Server'
sudo ufw allow 25565/udp comment 'Minecraft Query'
# FirewallD (CentOS/RHEL)
sudo firewall-cmd --permanent --add-port=25565/tcp
sudo firewall-cmd --permanent --add-port=25565/udp
sudo firewall-cmd --reload
# iptables
sudo iptables -A INPUT -p tcp --dport 25565 -j ACCEPT
sudo iptables -A INPUT -p udp --dport 25565 -j ACCEPT
sudo iptables-save > /etc/iptables/rules.v4
# Windows Firewall
netsh advfirewall firewall add rule name="Minecraft Server" dir=in action=allow protocol=TCP localport=25565
netsh advfirewall firewall add rule name="Minecraft Query" dir=in action=allow protocol=UDP localport=25565
</code></pre>
<h3 style="color: #ffffff; margin-top: 20px;">Port Configuration in server.properties</h3>
<pre><code style="color: #a5b4fc;"># Main server port (TCP)
server-port=25565
# Query port (UDP) - usually same as server-port
query.port=25565
enable-query=true
# RCON port (TCP) - remote administration
rcon.port=25575
enable-rcon=false
rcon.password=changeme_use_strong_password
</code></pre>
<h3 style="color: #ffffff; margin-top: 20px;">⚠️ Port Security Notes</h3>
<ul style="color: #fef3c7; line-height: 1.8;">
<li>Never expose RCON port to the internet without strong authentication</li>
<li>Consider using a non-standard port to reduce automated attacks</li>
<li>If using cloud hosting, configure security groups to allow only required ports</li>
<li>Monitor connection attempts in server logs regularly</li>
</ul>
</div>
<h2 id="installation">Installation & Setup</h2>
<h3>System Requirements</h3>