<?php
// Deployment Readiness Checklist for M-AUTO
echo "<h1>M-AUTO Deployment Checklist</h1>";
echo "<style>
.checklist { margin: 20px 0; }
.check-item { margin: 10px 0; padding: 10px; border-radius: 5px; }
.completed { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.pending { background-color: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }
.critical { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.info { background-color: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
h2 { color: #333; border-bottom: 2px solid #007bff; padding-bottom: 10px; }
</style>";
// File checks
echo "<h2>📁 File Structure Check</h2>";
$required_files = [
'index.php' => 'Main homepage',
'includes/config.php' => 'Configuration file',
'includes/db_production.php' => 'Production database connection',
'.htaccess' => 'Apache configuration',
'robots.txt' => 'Search engine instructions',
'sitemap.xml' => 'Site map for SEO',
'404.php' => 'Custom 404 error page',
'500.php' => 'Custom 500 error page'
];
foreach ($required_files as $file => $description) {
if (file_exists($file)) {
echo "<div class='check-item completed'>✓ $description ($file)</div>";
} else {
echo "<div class='check-item critical'>✗ $description ($file) - MISSING</div>";
}
}
// Directory checks
echo "<h2>📂 Directory Structure Check</h2>";
$required_dirs = [
'admin' => 'Admin panel',
'includes' => 'Include files',
'assets' => 'Static assets',
'uploads' => 'Upload directory'
];
foreach ($required_dirs as $dir => $description) {
if (is_dir($dir)) {
$writable = is_writable($dir) ? 'Writable' : 'Not Writable';
$class = is_writable($dir) ? 'completed' : 'pending';
echo "<div class='check-item $class'>✓ $description ($dir) - $writable</div>";
} else {
echo "<div class='check-item critical'>✗ $description ($dir) - MISSING</div>";
}
}
// Database check
echo "<h2>🗄️ Database Check</h2>";
try {
include 'includes/db.php';
if ($conn && !$conn->connect_error) {
echo "<div class='check-item completed'>✓ Database connection successful</div>";
// Check critical tables
$critical_tables = ['users', 'permissions', 'user_permissions', 'cars', 'settings'];
foreach ($critical_tables as $table) {
$result = $conn->query("SHOW TABLES LIKE '$table'");
if ($result && $result->num_rows > 0) {
echo "<div class='check-item completed'>✓ Table '$table' exists</div>";
} else {
echo "<div class='check-item critical'>✗ Table '$table' missing</div>";
}
}
// Check admin user
$admin_check = $conn->query("SELECT COUNT(*) as count FROM users WHERE id = 1");
if ($admin_check) {
$admin_exists = $admin_check->fetch_assoc()['count'] > 0;
if ($admin_exists) {
echo "<div class='check-item completed'>✓ Admin user (ID=1) exists</div>";
} else {
echo "<div class='check-item critical'>✗ Admin user (ID=1) missing</div>";
}
}
} else {
echo "<div class='check-item critical'>✗ Database connection failed</div>";
}
} catch (Exception $e) {
echo "<div class='check-item critical'>✗ Database error: " . $e->getMessage() . "</div>";
}
// Security check
echo "<h2>🔒 Security Check</h2>";
$security_checks = [
'includes/config.php' => 'Configuration file should not be web accessible',
'includes/db.php' => 'Database file should not be web accessible',
'.htaccess' => 'Security rules should be in place'
];
// Check if sensitive files are protected
$htaccess_content = file_exists('.htaccess') ? file_get_contents('.htaccess') : '';
if (strpos($htaccess_content, 'includes/*') !== false) {
echo "<div class='check-item completed'>✓ Includes directory protected</div>";
} else {
echo "<div class='check-item pending'>⚠ Includes directory protection not found in .htaccess</div>";
}
if (strpos($htaccess_content, 'config.php') !== false) {
echo "<div class='check-item completed'>✓ Config file protected</div>";
} else {
echo "<div class='check-item pending'>⚠ Config file protection not found in .htaccess</div>";
}
// SEO check
echo "<h2>🔍 SEO Check</h2>";
if (file_exists('robots.txt')) {
echo "<div class='check-item completed'>✓ robots.txt exists</div>";
} else {
echo "<div class='check-item pending'>⚠ robots.txt missing</div>";
}
if (file_exists('sitemap.xml')) {
echo "<div class='check-item completed'>✓ sitemap.xml exists</div>";
} else {
echo "<div class='check-item pending'>⚠ sitemap.xml missing</div>";
}
// Performance check
echo "<h2>⚡ Performance Check</h2>";
if (strpos($htaccess_content, 'mod_deflate') !== false) {
echo "<div class='check-item completed'>✓ Gzip compression enabled</div>";
} else {
echo "<div class='check-item pending'>⚠ Gzip compression not configured</div>";
}
if (strpos($htaccess_content, 'mod_expires') !== false) {
echo "<div class='check-item completed'>✓ Browser caching configured</div>";
} else {
echo "<div class='check-item pending'>⚠ Browser caching not configured</div>";
}
// Final recommendations
echo "<h2>📋 Pre-Deployment Checklist</h2>";
echo "<div class='checklist'>";
echo "<div class='check-item info'>□ Update database credentials in includes/config.php</div>";
echo "<div class='check-item info'>□ Export database using export_database.php</div>";
echo "<div class='check-item info'>□ Test server_check.php on production server</div>";
echo "<div class='check-item info'>□ Run update_urls.php after deployment</div>";
echo "<div class='check-item info'>□ Install SSL certificate</div>";
echo "<div class='check-item info'>□ Enable HTTPS redirect in .htaccess</div>";
echo "<div class='check-item info'>□ Set up regular backups</div>";
echo "<div class='check-item info'>□ Configure error logging</div>";
echo "<div class='check-item info'>□ Delete deployment scripts after successful deployment</div>";
echo "</div>";
echo "<h2>🚀 Ready for Deployment?</h2>";
echo "<div class='check-item info'>";
echo "<strong>Next Steps:</strong><br>";
echo "1. Follow the instructions in DEPLOYMENT_GUIDE.md<br>";
echo "2. Upload files to your VPS<br>";
echo "3. Import database<br>";
echo "4. Update configuration<br>";
echo "5. Test everything<br>";
echo "6. Go live!";
echo "</div>";
echo "<p><strong>Generated on:</strong> " . date('Y-m-d H:i:s') . "</p>";
?>