One Hat Cyber Team
Your IP :
216.73.216.55
Server IP :
5.189.175.239
Server :
Linux panel.gemx-ai.com 5.14.0-570.19.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 4 04:00:24 EDT 2025 x86_64
Server Software :
LiteSpeed
PHP Version :
8.2.28
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
home
/
farmersapp
/
loans.farmersapp.store
/
View File Name :
install.php
<?php /** * Installation Wizard * Farmers Loan Management System */ // Disable error reporting for clean installation error_reporting(0); ini_set('display_errors', 0); // Define paths define('APP_ROOT', dirname(__FILE__)); define('INSTALLER_VERSION', '1.0.0'); // Check if already installed $installed_file = APP_ROOT . '/config/installed.php'; if (file_exists($installed_file)) { include $installed_file; if (defined('INSTALLED') && INSTALLED === true) { header('Location: index.php'); exit; } } // Installation steps $steps = [ 1 => 'Welcome', 2 => 'System Requirements', 3 => 'Database Configuration', 4 => 'Admin Account Setup', 5 => 'Final Configuration', 6 => 'Installation Complete' ]; // Get current step $current_step = isset($_GET['step']) ? (int)$_GET['step'] : 1; if ($current_step < 1 || $current_step > count($steps)) { $current_step = 1; } // Handle form submissions if ($_SERVER['REQUEST_METHOD'] === 'POST') { switch ($current_step) { case 3: // Database configuration $_SESSION['install_db'] = $_POST; break; case 4: // Admin account setup $_SESSION['install_admin'] = $_POST; break; case 5: // Perform installation performInstallation(); break; } // Move to next step header('Location: install.php?step=' . ($current_step + 1)); exit; } // Function to check system requirements function checkRequirements() { $requirements = []; // PHP Version $requirements['php_version'] = [ 'name' => 'PHP Version', 'required' => '7.4.0', 'current' => PHP_VERSION, 'status' => version_compare(PHP_VERSION, '7.4.0', '>='), 'message' => 'PHP 7.4 or higher required' ]; // Extensions $required_extensions = [ 'pdo_mysql' => 'PDO MySQL Extension', 'mysqli' => 'MySQLi Extension', 'mbstring' => 'Multibyte String Extension', 'json' => 'JSON Extension', 'openssl' => 'OpenSSL Extension', 'gd' => 'GD Library (for image processing)', 'zip' => 'Zip Extension (for backups)' ]; foreach ($required_extensions as $ext => $name) { $requirements[$ext] = [ 'name' => $name, 'required' => 'Enabled', 'current' => extension_loaded($ext) ? 'Enabled' : 'Disabled', 'status' => extension_loaded($ext), 'message' => $name . ' must be enabled' ]; } // Directory permissions $required_dirs = [ 'config' => APP_ROOT . '/config', 'uploads' => APP_ROOT . '/uploads', 'logs' => APP_ROOT . '/logs', 'cache' => APP_ROOT . '/cache' ]; foreach ($required_dirs as $name => $path) { $writable = is_writable($path) || (!file_exists($path) && is_writable(dirname($path))); $requirements['dir_' . $name] = [ 'name' => ucfirst($name) . ' Directory', 'required' => 'Writable', 'current' => $writable ? 'Writable' : 'Not Writable', 'status' => $writable, 'message' => $path . ' must be writable' ]; } // File upload settings $requirements['upload_size'] = [ 'name' => 'File Upload Size', 'required' => '>= 5MB', 'current' => ini_get('upload_max_filesize'), 'status' => (intval(ini_get('upload_max_filesize')) >= 5), 'message' => 'Minimum 5MB upload size required' ]; return $requirements; } // Function to test database connection function testDatabaseConnection($host, $username, $password, $database, $port = 3306) { try { $dsn = "mysql:host=$host;port=$port;charset=utf8mb4"; $pdo = new PDO($dsn, $username, $password, [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION, PDO::ATTR_TIMEOUT => 5 ]); // Check if database exists $stmt = $pdo->query("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '$database'"); $db_exists = $stmt->fetch(PDO::FETCH_ASSOC); return [ 'success' => true, 'message' => $db_exists ? 'Database exists' : 'Database will be created', 'version' => $pdo->getAttribute(PDO::ATTR_SERVER_VERSION) ]; } catch (PDOException $e) { return [ 'success' => false, 'message' => $e->getMessage() ]; } } // Function to perform installation function performInstallation() { $db_config = $_SESSION['install_db'] ?? []; $admin_config = $_SESSION['install_admin'] ?? []; // Create database connection try { $dsn = "mysql:host={$db_config['db_host']};port={$db_config['db_port']};charset=utf8mb4"; $pdo = new PDO($dsn, $db_config['db_user'], $db_config['db_pass'], [ PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION ]); // Create database if not exists $pdo->exec("CREATE DATABASE IF NOT EXISTS `{$db_config['db_name']}` CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci"); $pdo->exec("USE `{$db_config['db_name']}`"); // Read and execute schema file $schema_file = APP_ROOT . '/database/schema.sql'; if (file_exists($schema_file)) { $sql = file_get_contents($schema_file); $pdo->exec($sql); } // Create admin user $password_hash = password_hash($admin_config['admin_password'], PASSWORD_DEFAULT); $stmt = $pdo->prepare(" INSERT INTO users (username, email, password_hash, first_name, last_name, role_id, is_active, created_at) VALUES (?, ?, ?, ?, ?, 1, 1, NOW()) "); $stmt->execute([ $admin_config['admin_username'], $admin_config['admin_email'], $password_hash, $admin_config['admin_first_name'], $admin_config['admin_last_name'] ]); // Create configuration file $config_content = "<?php\n"; $config_content .= "// Installation completed on " . date('Y-m-d H:i:s') . "\n"; $config_content .= "define('INSTALLED', true);\n"; $config_content .= "define('DB_HOST', '{$db_config['db_host']}');\n"; $config_content .= "define('DB_NAME', '{$db_config['db_name']}');\n"; $config_content .= "define('DB_USER', '{$db_config['db_user']}');\n"; $config_content .= "define('DB_PASS', '{$db_config['db_pass']}');\n"; $config_content .= "define('DB_PORT', '{$db_config['db_port']}');\n"; $config_content .= "define('DB_CHARSET', 'utf8mb4');\n"; $config_content .= "define('ENVIRONMENT', 'production');\n"; $config_content .= "define('APP_KEY', '" . bin2hex(random_bytes(32)) . "');\n"; $config_content .= "?>"; file_put_contents(APP_ROOT . '/config/installed.php', $config_content); // Create .htaccess file $htaccess_content = "# Apache Configuration\n"; $htaccess_content .= "RewriteEngine On\n"; $htaccess_content .= "RewriteCond %{REQUEST_FILENAME} !-f\n"; $htaccess_content .= "RewriteCond %{REQUEST_FILENAME} !-d\n"; $htaccess_content .= "RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]\n"; file_put_contents(APP_ROOT . '/.htaccess', $htaccess_content); return true; } catch (Exception $e) { return false; } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Installation Wizard - <?php echo APP_NAME; ?></title> <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet"> <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> <style> body { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; } .install-container { background: white; border-radius: 15px; box-shadow: 0 20px 60px rgba(0,0,0,0.3); max-width: 800px; width: 100%; overflow: hidden; } .install-header { background: linear-gradient(135deg, #4e73df 0%, #224abe 100%); color: white; padding: 30px; text-align: center; } .install-progress { background: #f8f9fa; padding: 20px; border-bottom: 1px solid #e3e6f0; } .install-content { padding: 40px; } .install-footer { background: #f8f9fa; padding: 20px; border-top: 1px solid #e3e6f0; text-align: center; } .step-circle { width: 40px; height: 40px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: bold; margin: 0 auto; background: #e3e6f0; color: #858796; } .step-circle.active { background: #4e73df; color: white; } .step-circle.completed { background: #1cc88a; color: white; } .step-label { margin-top: 10px; font-size: 12px; color: #858796; text-align: center; } .step-label.active { color: #4e73df; font-weight: bold; } .requirement-item { padding: 10px 15px; margin-bottom: 10px; border-radius: 5px; border-left: 4px solid #e3e6f0; } .requirement-item.passed { border-left-color: #1cc88a; background: #f8fff9; } .requirement-item.failed { border-left-color: #e74a3b; background: #fff8f8; } .form-control:focus { border-color: #4e73df; box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25); } .btn-install { background: linear-gradient(135deg, #4e73df 0%, #224abe 100%); border: none; color: white; padding: 12px 30px; font-weight: bold; border-radius: 5px; transition: all 0.3s; } .btn-install:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(78, 115, 223, 0.4); } .alert-install { border-left: 4px solid; border-radius: 5px; padding: 15px; margin-bottom: 20px; } .alert-success { border-left-color: #1cc88a; background: #f8fff9; } .alert-danger { border-left-color: #e74a3b; background: #fff8f8; } .alert-warning { border-left-color: #f6c23e; background: #fffdf6; } .alert-info { border-left-color: #36b9cc; background: #f8feff; } </style> </head> <body> <div class="install-container"> <!-- Header --> <div class="install-header"> <h1 class="h3 mb-2"> <i class="fas fa-hand-holding-usd me-2"></i> <?php echo APP_NAME; ?> </h1> <p class="mb-0">Installation Wizard</p> </div> <!-- Progress Bar --> <div class="install-progress"> <div class="row"> <?php foreach ($steps as $step_num => $step_name): ?> <div class="col text-center"> <div class="step-circle <?php echo $step_num == $current_step ? 'active' : ''; ?> <?php echo $step_num < $current_step ? 'completed' : ''; ?>"> <?php if ($step_num < $current_step): ?> <i class="fas fa-check"></i> <?php else: ?> <?php echo $step_num; ?> <?php endif; ?> </div> <div class="step-label <?php echo $step_num == $current_step ? 'active' : ''; ?>"> <?php echo $step_name; ?> </div> </div> <?php endforeach; ?> </div> </div> <!-- Content --> <div class="install-content"> <form method="POST" action="" id="installForm"> <?php if ($current_step == 1): ?> <!-- Step 1: Welcome --> <div class="text-center mb-4"> <i class="fas fa-hand-holding-usd fa-4x text-primary mb-3"></i> <h2>Welcome to <?php echo APP_NAME; ?></h2> <p class="text-muted">Thank you for choosing our loan management system.</p> </div> <div class="alert-install alert-info"> <h5><i class="fas fa-info-circle me-2"></i>Before You Begin</h5> <p class="mb-2">Please ensure you have the following information ready:</p> <ul class="mb-0"> <li>MySQL database credentials</li> <li>Administrator account details</li> <li>System requirements met</li> </ul> </div> <div class="alert-install alert-warning"> <h5><i class="fas fa-exclamation-triangle me-2"></i>Important Notes</h5> <ul class="mb-0"> <li>This installation will create database tables</li> <li>Make sure you have backup of existing data</li> <li>Keep this information secure</li> </ul> </div> <?php elseif ($current_step == 2): ?> <!-- Step 2: System Requirements --> <h3 class="mb-4">System Requirements Check</h3> <?php $requirements = checkRequirements(); $all_passed = true; foreach ($requirements as $req): if (!$req['status']) $all_passed = false; ?> <div class="requirement-item <?php echo $req['status'] ? 'passed' : 'failed'; ?>"> <div class="d-flex justify-content-between align-items-center"> <div> <h6 class="mb-1"><?php echo $req['name']; ?></h6> <p class="mb-0 text-muted"><?php echo $req['message']; ?></p> </div> <div class="text-end"> <small class="d-block">Required: <?php echo $req['required']; ?></small> <small class="d-block">Current: <?php echo $req['current']; ?></small> <span class="badge bg-<?php echo $req['status'] ? 'success' : 'danger'; ?>"> <?php echo $req['status'] ? 'PASSED' : 'FAILED'; ?> </span> </div> </div> </div> <?php endforeach; ?> <?php if (!$all_passed): ?> <div class="alert-install alert-danger mt-4"> <h5><i class="fas fa-times-circle me-2"></i>Requirements Not Met</h5> <p class="mb-0">Please fix the failed requirements before proceeding.</p> </div> <?php endif; ?> <?php elseif ($current_step == 3): ?> <!-- Step 3: Database Configuration --> <h3 class="mb-4">Database Configuration</h3> <p class="text-muted mb-4">Enter your MySQL database connection details.</p> <div class="row g-3"> <div class="col-md-6"> <label for="db_host" class="form-label">Database Host</label> <input type="text" class="form-control" id="db_host" name="db_host" value="<?php echo $_SESSION['install_db']['db_host'] ?? 'localhost'; ?>" required> <div class="form-text">Usually "localhost"</div> </div> <div class="col-md-6"> <label for="db_port" class="form-label">Database Port</label> <input type="number" class="form-control" id="db_port" name="db_port" value="<?php echo $_SESSION['install_db']['db_port'] ?? '3306'; ?>" required> <div class="form-text">Default MySQL port is 3306</div> </div> <div class="col-md-6"> <label for="db_name" class="form-label">Database Name</label> <input type="text" class="form-control" id="db_name" name="db_name" value="<?php echo $_SESSION['install_db']['db_name'] ?? ''; ?>" required> <div class="form-text">Database will be created if it doesn't exist</div> </div> <div class="col-md-6"> <label for="db_user" class="form-label">Database Username</label> <input type="text" class="form-control" id="db_user" name="db_user" value="<?php echo $_SESSION['install_db']['db_user'] ?? 'root'; ?>" required> <div class="form-text">MySQL username with create privileges</div> </div> <div class="col-md-6"> <label for="db_pass" class="form-label">Database Password</label> <input type="password" class="form-control" id="db_pass" name="db_pass" value="<?php echo $_SESSION['install_db']['db_pass'] ?? ''; ?>"> <div class="form-text">Leave empty if no password</div> </div> <div class="col-md-6"> <label for="db_prefix" class="form-label">Table Prefix (Optional)</label> <input type="text" class="form-control" id="db_prefix" name="db_prefix" value="<?php echo $_SESSION['install_db']['db_prefix'] ?? 'flms_'; ?>"> <div class="form-text">Prefix for all database tables</div> </div> </div> <div class="mt-4"> <button type="button" class="btn btn-outline-primary" onclick="testConnection()"> <i class="fas fa-plug me-2"></i>Test Connection </button> <div id="testResult" class="mt-2"></div> </div> <script> function testConnection() { const formData = { db_host: document.getElementById('db_host').value, db_port: document.getElementById('db_port').value, db_name: document.getElementById('db_name').value, db_user: document.getElementById('db_user').value, db_pass: document.getElementById('db_pass').value }; const resultDiv = document.getElementById('testResult'); resultDiv.innerHTML = '<div class="alert alert-info">Testing connection...</div>'; fetch('install.php?action=test_db', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify(formData) }) .then(response => response.json()) .then(data => { if (data.success) { resultDiv.innerHTML = ` <div class="alert alert-success"> <i class="fas fa-check-circle me-2"></i> Connection successful! ${data.message} ${data.version ? '<br><small>MySQL Version: ' + data.version + '</small>' : ''} </div> `; } else { resultDiv.innerHTML = ` <div class="alert alert-danger"> <i class="fas fa-times-circle me-2"></i> Connection failed: ${data.message} </div> `; } }) .catch(error => { resultDiv.innerHTML = ` <div class="alert alert-danger"> <i class="fas fa-times-circle me-2"></i> Error: ${error.message} </div> `; }); } </script> <?php elseif ($current_step == 4): ?> <!-- Step 4: Admin Account Setup --> <h3 class="mb-4">Administrator Account Setup</h3> <p class="text-muted mb-4">Create your administrator account.</p> <div class="row g-3"> <div class="col-md-6"> <label for="admin_username" class="form-label">Username</label> <input type="text" class="form-control" id="admin_username" name="admin_username" value="<?php echo $_SESSION['install_admin']['admin_username'] ?? 'admin'; ?>" required> <div class="form-text">Used for login</div> </div> <div class="col-md-6"> <label for="admin_email" class="form-label">Email Address</label> <input type="email" class="form-control" id="admin_email" name="admin_email" value="<?php echo $_SESSION['install_admin']['admin_email'] ?? ''; ?>" required> <div class="form-text">For notifications and password reset</div> </div> <div class="col-md-6"> <label for="admin_first_name" class="form-label">First Name</label> <input type="text" class="form-control" id="admin_first_name" name="admin_first_name" value="<?php echo $_SESSION['install_admin']['admin_first_name'] ?? ''; ?>" required> </div> <div class="col-md-6"> <label for="admin_last_name" class="form-label">Last Name</label> <input type="text" class="form-control" id="admin_last_name" name="admin_last_name" value="<?php echo $_SESSION['install_admin']['admin_last_name'] ?? ''; ?>" required> </div> <div class="col-md-6"> <label for="admin_password" class="form-label">Password</label> <div class="input-group"> <input type="password" class="form-control" id="admin_password" name="admin_password" required> <button type="button" class="btn btn-outline-secondary" onclick="togglePassword('admin_password')"> <i class="fas fa-eye"></i> </button> </div> <div class="form-text">Minimum 8 characters</div> </div> <div class="col-md-6"> <label for="admin_confirm_password" class="form-label">Confirm Password</label> <div class="input-group"> <input type="password" class="form-control" id="admin_confirm_password" name="admin_confirm_password" required> <button type="button" class="btn btn-outline-secondary" onclick="togglePassword('admin_confirm_password')"> <i class="fas fa-eye"></i> </button> </div> </div> </div> <div class="mt-4"> <div class="alert-install alert-info"> <h5><i class="fas fa-shield-alt me-2"></i>Security Recommendations</h5> <ul class="mb-0"> <li>Use a strong, unique password</li> <li>Change the default username from "admin"</li> <li>Keep your credentials secure</li> <li>Enable two-factor authentication after installation</li> </ul> </div> </div> <script> function togglePassword(fieldId) { const field = document.getElementById(fieldId); const button = field.nextElementSibling.querySelector('i'); if (field.type === 'password') { field.type = 'text'; button.classList.remove('fa-eye'); button.classList.add('fa-eye-slash'); } else { field.type = 'password'; button.classList.remove('fa-eye-slash'); button.classList.add('fa-eye'); } } // Password validation document.getElementById('installForm').addEventListener('submit', function(e) { const password = document.getElementById('admin_password').value; const confirm = document.getElementById('admin_confirm_password').value; if (password !== confirm) { e.preventDefault(); alert('Passwords do not match!'); return false; } if (password.length < 8) { e.preventDefault(); alert('Password must be at least 8 characters long!'); return false; } }); </script> <?php elseif ($current_step == 5): ?> <!-- Step 5: Final Configuration --> <h3 class="mb-4">Final Configuration</h3> <div class="alert-install alert-warning"> <h5><i class="fas fa-exclamation-triangle me-2"></i>Ready to Install</h5> <p class="mb-0">Please review your settings before proceeding with installation.</p> </div> <div class="row"> <div class="col-md-6"> <h5>Database Settings</h5> <table class="table table-sm"> <tr> <th>Host:</th> <td><?php echo htmlspecialchars($_SESSION['install_db']['db_host'] ?? ''); ?></td> </tr> <tr> <th>Database:</th> <td><?php echo htmlspecialchars($_SESSION['install_db']['db_name'] ?? ''); ?></td> </tr> <tr> <th>Username:</th> <td><?php echo htmlspecialchars($_SESSION['install_db']['db_user'] ?? ''); ?></td> </tr> </table> </div> <div class="col-md-6"> <h5>Admin Account</h5> <table class="table table-sm"> <tr> <th>Username:</th> <td><?php echo htmlspecialchars($_SESSION['install_admin']['admin_username'] ?? ''); ?></td> </tr> <tr> <th>Email:</th> <td><?php echo htmlspecialchars($_SESSION['install_admin']['admin_email'] ?? ''); ?></td> </tr> <tr> <th>Name:</th> <td><?php echo htmlspecialchars($_SESSION['install_admin']['admin_first_name'] ?? '') . ' ' . htmlspecialchars($_SESSION['install_admin']['admin_last_name'] ?? ''); ?></td> </tr> </table> </div> </div> <div class="mt-4"> <div class="form-check mb-3"> <input class="form-check-input" type="checkbox" id="agree_terms" required> <label class="form-check-label" for="agree_terms"> I understand that this will install the system and create database tables. I have backed up any existing data. </label> </div> <div class="form-check mb-3"> <input class="form-check-input" type="checkbox" id="send_stats" checked> <label class="form-check-label" for="send_stats"> Send anonymous usage statistics to help improve the system </label> </div> </div> <div class="alert-install alert-info mt-4"> <h5><i class="fas fa-info-circle me-2"></i>What will be installed?</h5> <ul class="mb-0"> <li>Database tables (40+ tables)</li> <li>Default settings and configurations</li> <li>Administrator account</li> <li>Sample loan products</li> <li>System configuration files</li> </ul> </div> <?php elseif ($current_step == 6): ?> <!-- Step 6: Installation Complete --> <div class="text-center"> <div class="mb-4"> <i class="fas fa-check-circle fa-5x text-success"></i> </div> <h2 class="mb-3">Installation Complete!</h2> <p class="text-muted mb-4"> <?php echo APP_NAME; ?> has been successfully installed on your server. </p> <div class="alert-install alert-success mb-4"> <h5><i class="fas fa-key me-2"></i>Your Login Credentials</h5> <div class="row"> <div class="col-md-6"> <p class="mb-1"><strong>Username:</strong> <?php echo htmlspecialchars($_SESSION['install_admin']['admin_username'] ?? ''); ?></p> </div> <div class="col-md-6"> <p class="mb-1"><strong>Password:</strong> [The password you set]</p> </div> </div> <p class="mb-0 mt-2 text-danger"> <i class="fas fa-exclamation-triangle me-1"></i> Please save these credentials in a secure place! </p> </div> <div class="row mb-4"> <div class="col-md-6"> <div class="card"> <div class="card-body"> <h5 class="card-title">Next Steps</h5> <ul class="text-start"> <li>Login to the admin panel</li> <li>Configure your settings</li> <li>Add your branches</li> <li>Create loan products</li> <li>Add staff members</li> </ul> </div> </div> </div> <div class="col-md-6"> <div class="card"> <div class="card-body"> <h5 class="card-title">Security Checklist</h5> <ul class="text-start"> <li>Change default admin password</li> <li>Configure SSL certificate</li> <li>Set up regular backups</li> <li>Enable two-factor authentication</li> <li>Restrict file permissions</li> </ul> </div> </div> </div> </div> <div class="d-grid gap-2 d-md-flex justify-content-center"> <a href="/login" class="btn btn-install btn-lg"> <i class="fas fa-sign-in-alt me-2"></i>Go to Login Page </a> <a href="/dashboard" class="btn btn-outline-primary btn-lg"> <i class="fas fa-tachometer-alt me-2"></i>Go to Dashboard </a> </div> <div class="mt-4 text-muted"> <small> <i class="fas fa-exclamation-circle me-1"></i> For security reasons, please delete the <code>install.php</code> file </small> </div> </div> <?php endif; ?> <!-- Navigation Buttons --> <?php if ($current_step < 6): ?> <div class="install-footer"> <div class="d-flex justify-content-between"> <?php if ($current_step > 1): ?> <a href="install.php?step=<?php echo $current_step - 1; ?>" class="btn btn-outline-secondary"> <i class="fas fa-arrow-left me-2"></i>Back </a> <?php else: ?> <div></div> <?php endif; ?> <?php if ($current_step < count($steps)): ?> <button type="submit" class="btn btn-install"> <?php if ($current_step == 5): ?> <i class="fas fa-play me-2"></i>Begin Installation <?php else: ?> Continue <i class="fas fa-arrow-right ms-2"></i> <?php endif; ?> </button> <?php endif; ?> </div> </div> <?php endif; ?> </form> </div> </div> <!-- Bootstrap JS --> <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script> <script> // Form validation document.getElementById('installForm').addEventListener('submit', function(e) { // Validate current step const currentStep = <?php echo $current_step; ?>; if (currentStep === 3) { // Database validation const dbHost = document.getElementById('db_host').value.trim(); const dbName = document.getElementById('db_name').value.trim(); const dbUser = document.getElementById('db_user').value.trim(); if (!dbHost || !dbName || !dbUser) { e.preventDefault(); alert('Please fill in all required database fields'); return false; } } if (currentStep === 4) { // Admin validation const password = document.getElementById('admin_password').value; const confirm = document.getElementById('admin_confirm_password').value; if (password !== confirm) { e.preventDefault(); alert('Passwords do not match!'); return false; } if (password.length < 8) { e.preventDefault(); alert('Password must be at least 8 characters long!'); return false; } } if (currentStep === 5) { // Terms agreement if (!document.getElementById('agree_terms').checked) { e.preventDefault(); alert('You must agree to the terms to continue'); return false; } } // Show loading const submitBtn = this.querySelector('button[type="submit"]'); if (submitBtn) { submitBtn.disabled = true; submitBtn.innerHTML = '<i class="fas fa-spinner fa-spin me-2"></i> Processing...'; } }); // Handle test database connection via AJAX if (window.location.search.includes('action=test_db')) { // This would be handled by PHP } </script> </body> </html> <?php // Handle AJAX test connection if (isset($_GET['action']) && $_GET['action'] === 'test_db' && $_SERVER['REQUEST_METHOD'] === 'POST') { $data = json_decode(file_get_contents('php://input'), true); $result = testDatabaseConnection( $data['db_host'] ?? '', $data['db_user'] ?? '', $data['db_pass'] ?? '', $data['db_name'] ?? '', $data['db_port'] ?? 3306 ); header('Content-Type: application/json'); echo json_encode($result); exit; } ?>