fix install script8
This commit is contained in:
parent
0cdefdbf9a
commit
e1be64747c
65
UI/.htaccess
65
UI/.htaccess
|
|
@ -1,65 +0,0 @@
|
||||||
# ZitiNexus Router Enrollment UI - Apache Configuration
|
|
||||||
# Simplified configuration to ensure assets load correctly
|
|
||||||
|
|
||||||
RewriteEngine On
|
|
||||||
|
|
||||||
# Serve assets directly - NO rewriting for assets
|
|
||||||
RewriteRule ^assets/ - [L]
|
|
||||||
|
|
||||||
# Default page redirect
|
|
||||||
RewriteRule ^$ index.php [L]
|
|
||||||
|
|
||||||
# Security: Deny access to sensitive directories
|
|
||||||
<Files "*.php">
|
|
||||||
<RequireAll>
|
|
||||||
Require all granted
|
|
||||||
</RequireAll>
|
|
||||||
</Files>
|
|
||||||
|
|
||||||
<Directory "includes">
|
|
||||||
Require all denied
|
|
||||||
</Directory>
|
|
||||||
|
|
||||||
<Directory "logs">
|
|
||||||
Require all denied
|
|
||||||
</Directory>
|
|
||||||
|
|
||||||
<Directory "temp">
|
|
||||||
Require all denied
|
|
||||||
</Directory>
|
|
||||||
|
|
||||||
# Set proper MIME types for assets
|
|
||||||
<IfModule mod_mime.c>
|
|
||||||
AddType text/css .css
|
|
||||||
AddType application/javascript .js
|
|
||||||
AddType image/png .png
|
|
||||||
AddType image/jpeg .jpg .jpeg
|
|
||||||
AddType image/gif .gif
|
|
||||||
AddType image/svg+xml .svg
|
|
||||||
AddType image/x-icon .ico
|
|
||||||
</IfModule>
|
|
||||||
|
|
||||||
# Enable compression for text files
|
|
||||||
<IfModule mod_deflate.c>
|
|
||||||
AddOutputFilterByType DEFLATE text/plain
|
|
||||||
AddOutputFilterByType DEFLATE text/html
|
|
||||||
AddOutputFilterByType DEFLATE text/xml
|
|
||||||
AddOutputFilterByType DEFLATE text/css
|
|
||||||
AddOutputFilterByType DEFLATE application/xml
|
|
||||||
AddOutputFilterByType DEFLATE application/xhtml+xml
|
|
||||||
AddOutputFilterByType DEFLATE application/rss+xml
|
|
||||||
AddOutputFilterByType DEFLATE application/javascript
|
|
||||||
AddOutputFilterByType DEFLATE application/x-javascript
|
|
||||||
</IfModule>
|
|
||||||
|
|
||||||
# Set cache headers for static assets
|
|
||||||
<IfModule mod_expires.c>
|
|
||||||
ExpiresActive On
|
|
||||||
ExpiresByType text/css "access plus 1 month"
|
|
||||||
ExpiresByType application/javascript "access plus 1 month"
|
|
||||||
ExpiresByType image/png "access plus 1 month"
|
|
||||||
ExpiresByType image/jpeg "access plus 1 month"
|
|
||||||
ExpiresByType image/gif "access plus 1 month"
|
|
||||||
ExpiresByType image/svg+xml "access plus 1 month"
|
|
||||||
ExpiresByType image/x-icon "access plus 1 year"
|
|
||||||
</IfModule>
|
|
||||||
|
|
@ -1,40 +1,26 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Main dashboard for ZitiNexus Router Enrollment UI
|
|
||||||
* Universal version that works with any IP address/domain
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once 'includes/auth.php';
|
require_once 'includes/auth.php';
|
||||||
require_once 'includes/enrollment.php';
|
require_once 'includes/enrollment.php';
|
||||||
|
|
||||||
// Require authentication
|
|
||||||
AuthManager::requireAuth();
|
AuthManager::requireAuth();
|
||||||
|
|
||||||
// Get current user
|
|
||||||
$currentUser = AuthManager::getCurrentUser();
|
$currentUser = AuthManager::getCurrentUser();
|
||||||
|
|
||||||
// Initialize enrollment manager
|
|
||||||
$enrollmentManager = new EnrollmentManager();
|
$enrollmentManager = new EnrollmentManager();
|
||||||
|
|
||||||
// Handle AJAX requests
|
|
||||||
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
|
if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest') {
|
||||||
header('Content-Type: application/json');
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
if (isset($_GET['action']) && $_GET['action'] === 'get_status') {
|
if (isset($_GET['action']) && $_GET['action'] === 'get_status') {
|
||||||
// Get system status
|
|
||||||
$status = $enrollmentManager->getSystemStatus();
|
$status = $enrollmentManager->getSystemStatus();
|
||||||
echo json_encode($status);
|
echo json_encode($status);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'enroll') {
|
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'enroll') {
|
||||||
// Handle enrollment request
|
|
||||||
AuthManager::requireCSRF();
|
AuthManager::requireCSRF();
|
||||||
|
|
||||||
$hashKey = sanitizeInput($_POST['hashKey'] ?? '');
|
$hashKey = sanitizeInput($_POST['hashKey'] ?? '');
|
||||||
$apiEndpoint = sanitizeInput($_POST['apiEndpoint'] ?? DEFAULT_API_ENDPOINT);
|
$apiEndpoint = sanitizeInput($_POST['apiEndpoint'] ?? DEFAULT_API_ENDPOINT);
|
||||||
|
|
||||||
// Validate inputs
|
|
||||||
if (!ApiClient::validateHashKey($hashKey)) {
|
if (!ApiClient::validateHashKey($hashKey)) {
|
||||||
echo json_encode(['success' => false, 'error' => 'Invalid hash key format']);
|
echo json_encode(['success' => false, 'error' => 'Invalid hash key format']);
|
||||||
exit;
|
exit;
|
||||||
|
|
@ -45,22 +31,13 @@ if (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQU
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start enrollment
|
|
||||||
$result = $enrollmentManager->enrollRouter($hashKey, $apiEndpoint);
|
$result = $enrollmentManager->enrollRouter($hashKey, $apiEndpoint);
|
||||||
echo json_encode($result);
|
echo json_encode($result);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get system status for initial page load
|
|
||||||
$systemStatus = $enrollmentManager->getSystemStatus();
|
$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>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
@ -68,31 +45,10 @@ $assetBase = $basePath . '/assets';
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title><?php echo APP_NAME; ?> - Dashboard</title>
|
<title><?php echo APP_NAME; ?> - Dashboard</title>
|
||||||
<link rel="stylesheet" href="<?php echo $assetBase; ?>/css/style.css">
|
<link rel="stylesheet" href="/assets/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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="dashboard-container">
|
<div class="dashboard-container">
|
||||||
<!-- Header -->
|
|
||||||
<header class="header">
|
<header class="header">
|
||||||
<div class="header-content">
|
<div class="header-content">
|
||||||
<h1 class="header-title"><?php echo APP_NAME; ?></h1>
|
<h1 class="header-title"><?php echo APP_NAME; ?></h1>
|
||||||
|
|
@ -113,9 +69,7 @@ $assetBase = $basePath . '/assets';
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<!-- Main Content -->
|
|
||||||
<main class="main-content">
|
<main class="main-content">
|
||||||
<!-- System Status Card -->
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h2 class="card-title">System Status</h2>
|
<h2 class="card-title">System Status</h2>
|
||||||
|
|
@ -201,7 +155,6 @@ $assetBase = $basePath . '/assets';
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Enrollment Form Card -->
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h2 class="card-title">Router Enrollment</h2>
|
<h2 class="card-title">Router Enrollment</h2>
|
||||||
|
|
@ -251,7 +204,6 @@ $assetBase = $basePath . '/assets';
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<!-- Progress Container -->
|
|
||||||
<div id="progressContainer" class="progress-container">
|
<div id="progressContainer" class="progress-container">
|
||||||
<div class="progress-bar">
|
<div class="progress-bar">
|
||||||
<div id="progressFill" class="progress-fill"></div>
|
<div id="progressFill" class="progress-fill"></div>
|
||||||
|
|
@ -272,13 +224,11 @@ $assetBase = $basePath . '/assets';
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="logContainer" class="log-container">
|
<div id="logContainer" class="log-container">
|
||||||
<!-- Log entries will be added here dynamically -->
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Information Card -->
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<h2 class="card-title">Information</h2>
|
<h2 class="card-title">Information</h2>
|
||||||
|
|
@ -332,13 +282,6 @@ $assetBase = $basePath . '/assets';
|
||||||
</main>
|
</main>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="<?php echo $assetBase; ?>/js/app.js"></script>
|
<script src="/assets/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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
64
UI/index.php
64
UI/index.php
|
|
@ -1,18 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
/**
|
|
||||||
* Login page for ZitiNexus Router Enrollment UI
|
|
||||||
* Universal version that works with any IP address/domain
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once 'includes/auth.php';
|
require_once 'includes/auth.php';
|
||||||
|
|
||||||
// Redirect if already authenticated
|
|
||||||
if (isAuthenticated() && isSessionValid()) {
|
if (isAuthenticated() && isSessionValid()) {
|
||||||
header('Location: dashboard.php');
|
header('Location: dashboard.php');
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle messages
|
|
||||||
$message = '';
|
$message = '';
|
||||||
$messageType = '';
|
$messageType = '';
|
||||||
|
|
||||||
|
|
@ -42,13 +35,6 @@ if (isset($loginError)) {
|
||||||
$message = $loginError;
|
$message = $loginError;
|
||||||
$messageType = 'error';
|
$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>
|
<!DOCTYPE html>
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
|
@ -56,29 +42,7 @@ $assetBase = $basePath . '/assets';
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title><?php echo APP_NAME; ?> - Login</title>
|
<title><?php echo APP_NAME; ?> - Login</title>
|
||||||
<link rel="stylesheet" href="<?php echo $assetBase; ?>/css/style.css">
|
<link rel="stylesheet" href="/assets/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>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div class="login-container">
|
<div class="login-container">
|
||||||
|
|
@ -138,31 +102,5 @@ $assetBase = $basePath . '/assets';
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
|
||||||
// Auto-focus on username field
|
|
||||||
document.addEventListener('DOMContentLoaded', function() {
|
|
||||||
const usernameField = document.getElementById('username');
|
|
||||||
if (usernameField && !usernameField.value) {
|
|
||||||
usernameField.focus();
|
|
||||||
} else {
|
|
||||||
const passwordField = document.getElementById('password');
|
|
||||||
if (passwordField) {
|
|
||||||
passwordField.focus();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// Handle form submission
|
|
||||||
document.querySelector('form').addEventListener('submit', function(e) {
|
|
||||||
const submitBtn = this.querySelector('button[type="submit"]');
|
|
||||||
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>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue