fix install script7

This commit is contained in:
Edmund Tan 2025-07-22 02:23:28 +08:00
parent 19f86290ff
commit 0cdefdbf9a
3 changed files with 77 additions and 22 deletions

View File

@ -1,24 +1,14 @@
# ZitiNexus Router Enrollment UI - Apache Configuration
# This file helps serve assets correctly when document root is not set to /public/
# Simplified configuration to ensure assets load correctly
RewriteEngine On
# Serve assets directly from assets directory (highest priority)
RewriteRule ^assets/(.*)$ assets/$1 [L]
# Serve assets directly - NO rewriting for assets
RewriteRule ^assets/ - [L]
# Serve root-level PHP files directly (for current setup)
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule ^(index|dashboard)\.php$ $1.php [L]
# Fallback: redirect to public directory only if file doesn't exist in root
# Default page redirect
RewriteRule ^$ index.php [L]
# Handle other requests only if file doesn't exist in root
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} !^/assets/
RewriteRule ^(.*)$ public/$1 [L]
# Security: Deny access to sensitive directories
<Files "*.php">
<RequireAll>

View File

@ -1,7 +1,7 @@
<?php
/**
* Main dashboard for ZitiNexus Router Enrollment UI
* This is a copy for direct access when document root is set to main UI directory
* Universal version that works with any IP address/domain
*/
require_once 'includes/auth.php';
@ -54,6 +54,13 @@ if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQU
// Get system status for initial page load
$systemStatus = $enrollmentManager->getSystemStatus();
// Get base path for assets (works with any domain/IP)
$basePath = dirname($_SERVER['SCRIPT_NAME']);
if ($basePath === '/') {
$basePath = '';
}
$assetBase = $basePath . '/assets';
?>
<!DOCTYPE html>
<html lang="en">
@ -61,8 +68,27 @@ $systemStatus = $enrollmentManager->getSystemStatus();
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo APP_NAME; ?> - Dashboard</title>
<link rel="stylesheet" href="assets/css/style.css">
<link rel="icon" type="image/x-icon" href="assets/images/favicon.ico">
<link rel="stylesheet" href="<?php echo $assetBase; ?>/css/style.css">
<link rel="icon" type="image/x-icon" href="<?php echo $assetBase; ?>/images/favicon.ico">
<style>
/* Inline critical CSS to ensure basic styling loads */
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; margin: 0; padding: 0; background: #f5f5f5; }
.dashboard-container { min-height: 100vh; }
.header { background: #fff; border-bottom: 1px solid #e0e0e0; padding: 1rem 2rem; }
.header-content { display: flex; justify-content: space-between; align-items: center; }
.header-title { margin: 0; color: #333; }
.main-content { padding: 2rem; }
.card { background: #fff; border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); margin-bottom: 2rem; }
.card-header { padding: 1.5rem; border-bottom: 1px solid #e0e0e0; }
.card-title { margin: 0; color: #333; }
.card-body { padding: 1.5rem; }
.btn { padding: 0.5rem 1rem; border: none; border-radius: 4px; cursor: pointer; text-decoration: none; display: inline-block; }
.btn-primary { background: #007bff; color: white; }
.btn-secondary { background: #6c757d; color: white; }
.form-input { width: 100%; padding: 0.5rem; border: 1px solid #ddd; border-radius: 4px; }
.form-group { margin-bottom: 1rem; }
.form-label { display: block; margin-bottom: 0.5rem; font-weight: 500; }
</style>
</head>
<body>
<div class="dashboard-container">
@ -306,6 +332,13 @@ $systemStatus = $enrollmentManager->getSystemStatus();
</main>
</div>
<script src="assets/js/app.js"></script>
<script src="<?php echo $assetBase; ?>/js/app.js"></script>
<!-- Debug info for troubleshooting -->
<script>
console.log('Asset base path:', '<?php echo $assetBase; ?>');
console.log('CSS should load from:', '<?php echo $assetBase; ?>/css/style.css');
console.log('JS should load from:', '<?php echo $assetBase; ?>/js/app.js');
</script>
</body>
</html>

View File

@ -1,7 +1,7 @@
<?php
/**
* Login page for ZitiNexus Router Enrollment UI
* This is a copy for direct access when document root is set to main UI directory
* Universal version that works with any IP address/domain
*/
require_once 'includes/auth.php';
@ -42,6 +42,13 @@ if (isset($loginError)) {
$message = $loginError;
$messageType = 'error';
}
// Get base path for assets (works with any domain/IP)
$basePath = dirname($_SERVER['SCRIPT_NAME']);
if ($basePath === '/') {
$basePath = '';
}
$assetBase = $basePath . '/assets';
?>
<!DOCTYPE html>
<html lang="en">
@ -49,8 +56,29 @@ if (isset($loginError)) {
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title><?php echo APP_NAME; ?> - Login</title>
<link rel="stylesheet" href="assets/css/style.css">
<link rel="icon" type="image/x-icon" href="assets/images/favicon.ico">
<link rel="stylesheet" href="<?php echo $assetBase; ?>/css/style.css">
<link rel="icon" type="image/x-icon" href="<?php echo $assetBase; ?>/images/favicon.ico">
<style>
/* Inline critical CSS to ensure basic styling loads */
body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; margin: 0; padding: 0; background: #f5f5f5; }
.login-container { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 2rem; }
.login-card { background: #fff; border-radius: 8px; box-shadow: 0 4px 6px rgba(0,0,0,0.1); padding: 2rem; width: 100%; max-width: 400px; }
.login-header { text-align: center; margin-bottom: 2rem; }
.login-header h1 { margin: 0 0 0.5rem 0; color: #333; }
.form-group { margin-bottom: 1rem; }
.form-label { display: block; margin-bottom: 0.5rem; font-weight: 500; color: #333; }
.form-input { width: 100%; padding: 0.75rem; border: 1px solid #ddd; border-radius: 4px; font-size: 1rem; }
.btn { padding: 0.75rem 1.5rem; border: none; border-radius: 4px; cursor: pointer; text-decoration: none; display: inline-block; font-size: 1rem; }
.btn-primary { background: #007bff; color: white; width: 100%; }
.btn-full { width: 100%; }
.alert { padding: 1rem; border-radius: 4px; margin-bottom: 1rem; }
.alert-error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.alert-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeaa7; }
.alert-info { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-secondary { color: #6c757d; }
</style>
</head>
<body>
<div class="login-container">
@ -100,7 +128,7 @@ if (isset($loginError)) {
</button>
</form>
<div style="margin-top: 2rem; padding-top: 1rem; border-top: 1px solid var(--border-color); text-align: center;">
<div style="margin-top: 2rem; padding-top: 1rem; border-top: 1px solid #e0e0e0; text-align: center;">
<p class="text-sm text-secondary">
Default credentials: <strong>admin</strong> / <strong>admin123</strong>
</p>
@ -131,6 +159,10 @@ if (isset($loginError)) {
submitBtn.disabled = true;
submitBtn.innerHTML = '<span class="spinner"></span>Signing In...';
});
// Debug info for troubleshooting
console.log('Asset base path:', '<?php echo $assetBase; ?>');
console.log('CSS should load from:', '<?php echo $assetBase; ?>/css/style.css');
</script>
</body>
</html>