![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/soundstudiopro.com/private_html/admin_includes/ |
<?php
// Testing and Diagnostic Tools Tab
// This file provides access to all testing and diagnostic tools
// Get system information
$system_info = [
'php_version' => PHP_VERSION,
'server_software' => $_SERVER['SERVER_SOFTWARE'] ?? 'Unknown',
'database_connected' => $pdo ? 'Yes' : 'No',
'session_active' => isset($_SESSION['user_id']) ? 'Yes' : 'No',
'current_user' => $_SESSION['user_name'] ?? 'Unknown',
'is_admin' => $_SESSION['is_admin'] ?? false ? 'Yes' : 'No',
'cache_disabled' => 'Yes (Development Mode)',
'timestamp' => date('Y-m-d H:i:s')
];
// Get basic statistics for quick overview
$quick_stats = $pdo->query("
SELECT
COUNT(*) as total_tracks,
COUNT(CASE WHEN status = 'complete' THEN 1 END) as completed_tracks,
COUNT(CASE WHEN status = 'processing' THEN 1 END) as processing_tracks,
COUNT(CASE WHEN status = 'failed' THEN 1 END) as failed_tracks,
COUNT(CASE WHEN user_id IS NULL OR user_id = 0 THEN 1 END) as orphaned_tracks,
COUNT(DISTINCT user_id) as users_with_tracks
FROM music_tracks
")->fetch();
$user_stats = $pdo->query("
SELECT
COUNT(*) as total_users,
COUNT(CASE WHEN is_admin = 1 THEN 1 END) as admin_users,
SUM(credits) as total_credits
FROM users
")->fetch();
?>
<!-- Testing and Diagnostic Tools -->
<div class="section-header">
<h2><i class="fas fa-tools"></i> Testing & Diagnostic Tools</h2>
<p>Comprehensive testing and diagnostic tools for system troubleshooting and development</p>
</div>
<!-- System Overview -->
<div class="settings-grid" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 2rem; margin-bottom: 3rem;">
<!-- System Information -->
<div class="settings-card" style="background: rgba(255, 255, 255, 0.05); border-radius: 16px; padding: 2rem;">
<h3 style="margin-top: 0; color: white; font-size: 1.8rem;">
<i class="fas fa-info-circle"></i> System Information
</h3>
<div style="color: #a0aec0; font-family: monospace; font-size: 0.9rem;">
<div style="margin-bottom: 0.5rem;"><strong>PHP Version:</strong> <?= $system_info['php_version'] ?></div>
<div style="margin-bottom: 0.5rem;"><strong>Server:</strong> <?= htmlspecialchars($system_info['server_software']) ?></div>
<div style="margin-bottom: 0.5rem;"><strong>Database:</strong> <?= $system_info['database_connected'] ?></div>
<div style="margin-bottom: 0.5rem;"><strong>Session:</strong> <?= $system_info['session_active'] ?></div>
<div style="margin-bottom: 0.5rem;"><strong>Current User:</strong> <?= htmlspecialchars($system_info['current_user']) ?></div>
<div style="margin-bottom: 0.5rem;"><strong>Admin Status:</strong> <?= $system_info['is_admin'] ?></div>
<div style="margin-bottom: 0.5rem;"><strong>Cache Status:</strong> <?= $system_info['cache_disabled'] ?></div>
<div style="margin-bottom: 0.5rem;"><strong>Timestamp:</strong> <?= $system_info['timestamp'] ?></div>
</div>
</div>
<!-- Quick Statistics -->
<div class="settings-card" style="background: rgba(255, 255, 255, 0.05); border-radius: 16px; padding: 2rem;">
<h3 style="margin-top: 0; color: white; font-size: 1.8rem;">
<i class="fas fa-chart-bar"></i> Quick Statistics
</h3>
<div style="display: grid; grid-template-columns: 1fr 1fr; gap: 1rem;">
<div style="background: rgba(102, 126, 234, 0.1); border-radius: 8px; padding: 1rem; text-align: center;">
<div style="font-size: 2rem; font-weight: bold; color: #667eea;"><?= number_format($quick_stats['total_tracks']) ?></div>
<div style="color: #a0aec0; font-size: 0.9rem;">Total Tracks</div>
</div>
<div style="background: rgba(34, 197, 94, 0.1); border-radius: 8px; padding: 1rem; text-align: center;">
<div style="font-size: 2rem; font-weight: bold; color: #22c55e;"><?= number_format($quick_stats['completed_tracks']) ?></div>
<div style="color: #a0aec0; font-size: 0.9rem;">Completed</div>
</div>
<div style="background: rgba(245, 158, 11, 0.1); border-radius: 8px; padding: 1rem; text-align: center;">
<div style="font-size: 2rem; font-weight: bold; color: #f59e0b;"><?= number_format($quick_stats['processing_tracks']) ?></div>
<div style="color: #a0aec0; font-size: 0.9rem;">Processing</div>
</div>
<div style="background: rgba(239, 68, 68, 0.1); border-radius: 8px; padding: 1rem; text-align: center;">
<div style="font-size: 2rem; font-weight: bold; color: #ef4444;"><?= number_format($quick_stats['failed_tracks']) ?></div>
<div style="color: #a0aec0; font-size: 0.9rem;">Failed</div>
</div>
</div>
<div style="margin-top: 1rem; color: #a0aec0; font-size: 0.9rem;">
<div><strong>Orphaned Tracks:</strong> <?= number_format($quick_stats['orphaned_tracks']) ?></div>
<div><strong>Users with Tracks:</strong> <?= number_format($quick_stats['users_with_tracks']) ?></div>
<div><strong>Total Users:</strong> <?= number_format($user_stats['total_users']) ?></div>
<div><strong>Total Credits:</strong> <?= number_format($user_stats['total_credits']) ?></div>
</div>
</div>
</div>
<!-- Testing Tools Categories -->
<div class="settings-grid" style="display: grid; grid-template-columns: repeat(auto-fit, minmax(350px, 1fr)); gap: 2rem; margin-bottom: 3rem;">
<!-- Track Management Tools -->
<div class="settings-card" style="background: rgba(255, 255, 255, 0.05); border-radius: 16px; padding: 2rem;">
<h3 style="margin-top: 0; color: white; font-size: 1.8rem;">
<i class="fas fa-music"></i> Track Management Tools
</h3>
<div style="display: flex; flex-direction: column; gap: 1rem;">
<a href="/fix_track_display.php" class="btn btn-primary" style="text-decoration: none; text-align: left;">
<i class="fas fa-search"></i> Track Display Diagnostic
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
Diagnose track ownership and display issues
</div>
</a>
<a href="/verify_track_ownership.php" class="btn btn-primary" style="text-decoration: none; text-align: left;">
<i class="fas fa-database"></i> Track Ownership Verification
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
View all tracks and their current owners
</div>
</a>
<a href="/fix_track_titles.php" class="btn btn-primary" style="text-decoration: none; text-align: left;">
<i class="fas fa-edit"></i> Fix Track Titles
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
Edit and fix track titles in bulk
</div>
</a>
<a href="/admin.php?tab=tracks" class="btn btn-secondary" style="text-decoration: none; text-align: left;">
<i class="fas fa-cogs"></i> Admin Track Management
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
Full track management with transfer capabilities
</div>
</a>
<a href="/admin.php?tab=orphaned" class="btn btn-warning" style="text-decoration: none; text-align: left;">
<i class="fas fa-user-slash"></i> Orphaned Tracks
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
Manage tracks without owners
</div>
</a>
</div>
</div>
<!-- User Management Tools -->
<div class="settings-card" style="background: rgba(255, 255, 255, 0.05); border-radius: 16px; padding: 2rem;">
<h3 style="margin-top: 0; color: white; font-size: 1.8rem;">
<i class="fas fa-users"></i> User Management Tools
</h3>
<div style="display: flex; flex-direction: column; gap: 1rem;">
<a href="/admin.php?tab=users" class="btn btn-primary" style="text-decoration: none; text-align: left;">
<i class="fas fa-user-cog"></i> User Management
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
View and manage all users
</div>
</a>
<a href="/admin_login_as_user.php" class="btn btn-secondary" style="text-decoration: none; text-align: left;">
<i class="fas fa-sign-in-alt"></i> Login as User
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
Test user experience by logging in as different users
</div>
</a>
<a href="/force_stephane_session.php" class="btn btn-warning" style="text-decoration: none; text-align: left;">
<i class="fas fa-user-secret"></i> Force Stephane Session
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
Force login as Stephane for testing
</div>
</a>
</div>
</div>
<!-- System Testing Tools -->
<div class="settings-card" style="background: rgba(255, 255, 255, 0.05); border-radius: 16px; padding: 2rem;">
<h3 style="margin-top: 0; color: white; font-size: 1.8rem;">
<i class="fas fa-vial"></i> System Testing Tools
</h3>
<div style="display: flex; flex-direction: column; gap: 1rem;">
<a href="/test_library_display.php" class="btn btn-primary" style="text-decoration: none; text-align: left;">
<i class="fas fa-eye"></i> Test Library Display
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
Test library page with forced session
</div>
</a>
<a href="/test_library_query.php" class="btn btn-secondary" style="text-decoration: none; text-align: left;">
<i class="fas fa-search"></i> Test Library Query
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
Test database queries for library
</div>
</a>
<a href="/debug_artist_preview.php" class="btn btn-warning" style="text-decoration: none; text-align: left;">
<i class="fas fa-bug"></i> Debug Artist Preview
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
Debug artist profile preview issues
</div>
</a>
</div>
</div>
<!-- Audio & File Tools -->
<div class="settings-card" style="background: rgba(255, 255, 255, 0.05); border-radius: 16px; padding: 2rem;">
<h3 style="margin-top: 0; color: white; font-size: 1.8rem;">
<i class="fas fa-file-audio"></i> Audio & File Tools
</h3>
<div style="display: flex; flex-direction: column; gap: 1rem;">
<a href="/utils/audiofiles.php" class="btn btn-primary" style="text-decoration: none; text-align: left;">
<i class="fas fa-play"></i> Audio Files Handler
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
Test audio file streaming and access
</div>
</a>
<a href="/utils/audiofiles_fixed.php" class="btn btn-secondary" style="text-decoration: none; text-align: left;">
<i class="fas fa-wrench"></i> Audio Files Fixed
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
Fixed version of audio file handler
</div>
</a>
<a href="/utils/test_audiofiles_fix.php" class="btn btn-warning" style="text-decoration: none; text-align: left;">
<i class="fas fa-vial"></i> Test Audio Files Fix
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
Test audio file fixes and improvements
</div>
</a>
<a href="/utils/update_to_proxy.php" class="btn btn-info" style="text-decoration: none; text-align: left;">
<i class="fas fa-shield-alt"></i> Update to Proxy URLs
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
Convert audio URLs to secure proxy URLs
</div>
</a>
</div>
</div>
<!-- Database & Import Tools -->
<div class="settings-card" style="background: rgba(255, 255, 255, 0.05); border-radius: 16px; padding: 2rem;">
<h3 style="margin-top: 0; color: white; font-size: 1.8rem;">
<i class="fas fa-database"></i> Database & Import Tools
</h3>
<div style="display: flex; flex-direction: column; gap: 1rem;">
<a href="/utils/import_track.php" class="btn btn-primary" style="text-decoration: none; text-align: left;">
<i class="fas fa-download"></i> Import Track
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
Import tracks from external sources
</div>
</a>
<a href="/utils/fix_andrew_track.php" class="btn btn-warning" style="text-decoration: none; text-align: left;">
<i class="fas fa-user-edit"></i> Fix Andrew's Track
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
Fix specific track for Andrew
</div>
</a>
<a href="/database_updates.sql" class="btn btn-secondary" style="text-decoration: none; text-align: left;">
<i class="fas fa-file-code"></i> Database Updates
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
View database schema updates
</div>
</a>
</div>
</div>
<!-- Cache & Performance Tools -->
<div class="settings-card" style="background: rgba(255, 255, 255, 0.05); border-radius: 16px; padding: 2rem;">
<h3 style="margin-top: 0; color: white; font-size: 1.8rem;">
<i class="fas fa-tachometer-alt"></i> Cache & Performance
</h3>
<div style="display: flex; flex-direction: column; gap: 1rem;">
<a href="/CACHE_REMOVAL_SUMMARY.md" class="btn btn-info" style="text-decoration: none; text-align: left;">
<i class="fas fa-file-alt"></i> Cache Removal Summary
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
View what caching was removed and why
</div>
</a>
<a href="/admin.php?tab=system" class="btn btn-secondary" style="text-decoration: none; text-align: left;">
<i class="fas fa-cogs"></i> System Management
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
System logs and cache management
</div>
</a>
<button onclick="clearAllCache()" class="btn btn-warning" style="text-align: left;">
<i class="fas fa-trash"></i> Clear All Cache
<div style="font-size: 0.9rem; color: #a0aec0; margin-top: 0.25rem;">
Clear browser and server cache
</div>
</button>
</div>
</div>
</div>
<!-- Quick Actions -->
<div class="section-header" style="margin-top: 3rem;">
<h3><i class="fas fa-bolt"></i> Quick Actions</h3>
<p>Common testing and debugging actions</p>
</div>
<div style="display: flex; gap: 1rem; flex-wrap: wrap; margin-bottom: 2rem;">
<button onclick="testDatabaseConnection()" class="btn btn-primary">
<i class="fas fa-database"></i> Test Database Connection
</button>
<button onclick="testEmailSystem()" class="btn btn-secondary">
<i class="fas fa-envelope"></i> Test Email System
</button>
<button onclick="checkSystemHealth()" class="btn btn-success">
<i class="fas fa-heartbeat"></i> System Health Check
</button>
<button onclick="clearSession()" class="btn btn-warning">
<i class="fas fa-user-times"></i> Clear Session
</button>
<button onclick="refreshPage()" class="btn btn-info">
<i class="fas fa-sync"></i> Hard Refresh Page
</button>
</div>
<script>
// Quick action functions
function testDatabaseConnection() {
fetch('/admin_api.php?action=test_db_connection')
.then(response => response.json())
.then(data => {
if (data.success) {
showNotification('Database connection successful!', 'success');
} else {
showNotification('Database connection failed: ' + data.error, 'error');
}
})
.catch(error => {
showNotification('Database test failed: ' + error, 'error');
});
}
function testEmailSystem() {
const testEmail = prompt('Enter email address to test:');
if (testEmail) {
fetch('/admin_api.php', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
action: 'test_email',
test_email: testEmail
})
})
.then(response => response.json())
.then(data => {
if (data.success) {
showNotification('Test email sent successfully!', 'success');
} else {
showNotification('Email test failed: ' + data.error, 'error');
}
})
.catch(error => {
showNotification('Email test failed: ' + error, 'error');
});
}
}
function checkSystemHealth() {
showNotification('System health check started...', 'info');
// Check various system components
Promise.all([
fetch('/admin_api.php?action=test_db_connection'),
fetch('/admin_api.php?action=check_file_permissions'),
fetch('/admin_api.php?action=check_disk_space')
])
.then(responses => Promise.all(responses.map(r => r.json())))
.then(results => {
const allGood = results.every(r => r.success);
if (allGood) {
showNotification('System health check passed! All systems operational.', 'success');
} else {
showNotification('System health check found issues. Check logs for details.', 'warning');
}
})
.catch(error => {
showNotification('System health check failed: ' + error, 'error');
});
}
function clearSession() {
if (confirm('Clear current session? You will be logged out.')) {
fetch('/auth/logout.php')
.then(() => {
window.location.href = '/auth/login.php';
})
.catch(error => {
showNotification('Session clear failed: ' + error, 'error');
});
}
}
function refreshPage() {
if (confirm('Perform hard refresh? This will clear browser cache.')) {
// Clear browser cache
if ('caches' in window) {
caches.keys().then(function(names) {
for (let name of names) caches.delete(name);
});
}
// Hard refresh
window.location.reload(true);
}
}
function clearAllCache() {
if (confirm('Clear all cache (browser and server)?')) {
// Clear browser cache
if ('caches' in window) {
caches.keys().then(function(names) {
for (let name of names) caches.delete(name);
});
}
// Clear server cache
fetch('/admin_api.php?action=clear_cache')
.then(response => response.json())
.then(data => {
if (data.success) {
showNotification('All cache cleared successfully!', 'success');
setTimeout(() => window.location.reload(true), 1000);
} else {
showNotification('Cache clear failed: ' + data.error, 'error');
}
})
.catch(error => {
showNotification('Cache clear failed: ' + error, 'error');
});
}
}
// Notification function
function showNotification(message, type = 'info') {
const notification = document.createElement('div');
notification.style.cssText = `
position: fixed;
top: 20px;
right: 20px;
padding: 15px 20px;
border-radius: 8px;
color: white;
font-weight: bold;
z-index: 10000;
max-width: 300px;
word-wrap: break-word;
`;
switch (type) {
case 'success':
notification.style.background = '#22c55e';
break;
case 'error':
notification.style.background = '#ef4444';
break;
case 'warning':
notification.style.background = '#f59e0b';
break;
default:
notification.style.background = '#667eea';
}
notification.textContent = message;
document.body.appendChild(notification);
setTimeout(() => {
notification.remove();
}, 5000);
}
</script>