-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathinstall.php
More file actions
303 lines (274 loc) · 15.6 KB
/
Copy pathinstall.php
File metadata and controls
303 lines (274 loc) · 15.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
<?php
require_once('config.php');
$current = new Version();
$pageTitle = 'LibreKB Installer';
// Detect base path from config if available
$basePath = '';
if (class_exists('Config') && method_exists('Config', 'get')) {
$systemURL = Config::get('systemURL');
if ($systemURL) {
$basePath = rtrim(parse_url($systemURL, PHP_URL_PATH), '/');
}
} else {
// Fallback: try to detect from request URI
$scriptName = $_SERVER['SCRIPT_NAME'] ?? '';
$requestUri = $_SERVER['REQUEST_URI'] ?? '';
// Get the directory path of the script
$scriptDir = dirname($scriptName);
if ($scriptDir !== '/' && $scriptDir !== '.') {
$basePath = $scriptDir;
}
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?php echo($pageTitle); ?></title>
<link href="<?php echo $basePath; ?>/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
<link href="<?php echo $basePath; ?>/css/other.css" rel="stylesheet" type="text/css">
</head>
<body class="install-page">
<div class="container">
<div class="install-container">
<div class="install-header">
<div class="install-icon">
<i class="bi bi-download"></i>
</div>
<h1 class="install-title">LibreKB Installer</h1>
<div class="version-badge">
Version <?php echo $current->version; ?>
</div>
</div>
<?php
if (isset($error) && !empty($error)) {
echo '<div class="alert alert-danger" role="alert"><i class="bi bi-exclamation-triangle me-2"></i>' . htmlspecialchars($error) . '</div>';
}
if (isset($message) && !empty($message)) {
echo '<div class="alert alert-success" role="alert"><i class="bi bi-check-circle me-2"></i>' . htmlspecialchars($message) . '</div>';
if ($message === 'Installation completed successfully.') {
echo '<div class="info-text"><strong>Next step:</strong> go to <a href="' . $basePath . '/admin/" class="external-link">admin panel</a> to continue.</div>';
exit;
}
}
?>
<div class="info-text">
Before you begin, please make sure you have configured your database information in <code>config.php</code>.
For more information, visit <a href="https://librekb.com/" target="_blank" class="external-link">librekb.com</a>.
</div>
<h3 class="section-title">
<i class="bi bi-server me-2"></i>Server Compatibility Check
</h3>
<div class="compatibility-check mb-4">
<?php
$phpVersion = phpversion();
$requiredVersion = '8.4.0';
$isPhpCompatible = version_compare($phpVersion, $requiredVersion, '>=');
// Check web server
$serverSoftware = $_SERVER['SERVER_SOFTWARE'] ?? 'Unknown';
$webServer = 'Unknown';
$isWebServerCompatible = false;
if (stripos($serverSoftware, 'apache') !== false) {
$webServer = 'Apache';
$isWebServerCompatible = true;
} elseif (stripos($serverSoftware, 'lighttpd') !== false) {
$webServer = 'Lighttpd';
$isWebServerCompatible = true;
} elseif (stripos($serverSoftware, 'development') !== false || php_sapi_name() === 'cli-server') {
$webServer = 'PHP Built-in Server';
$isWebServerCompatible = true;
} elseif (stripos($serverSoftware, 'litespeed') !== false) {
$webServer = 'LiteSpeed';
$isWebServerCompatible = true;
} elseif (stripos($serverSoftware, 'openlitespeed') !== false) {
$webServer = 'OpenLiteSpeed';
$isWebServerCompatible = true;
} else {
$webServer = $serverSoftware;
// Other servers don't support .htaccess natively
$isWebServerCompatible = false;
}
// Check PHP cURL extension
$isCurlAvailable = extension_loaded('curl');
// Check PHP mbstring extension
$isMbstringAvailable = extension_loaded('mbstring');
// Check all PHP extensions
$requiredExtensions = ['curl', 'mbstring'];
$missingExtensions = [];
$extensionStatus = [];
foreach ($requiredExtensions as $ext) {
$isLoaded = extension_loaded($ext);
$extensionStatus[$ext] = $isLoaded;
if (!$isLoaded) {
$missingExtensions[] = $ext;
}
}
$areExtensionsCompatible = empty($missingExtensions);
// Get database connection status from controller
$dbConnection = isset($dbConnection) ? $dbConnection : ['success' => false, 'message' => 'Database connection not checked', 'error' => 'Unknown error'];
// Check if requirements bypass is enabled
$bypassRequirements = false;
if (class_exists('Config') && method_exists('Config', 'get')) {
$bypassRequirements = Config::get('bypassRequirements');
} elseif (class_exists('Config')) {
$config = new Config();
$bypassRequirements = isset($config->bypassRequirements) ? $config->bypassRequirements : false;
}
$isFullyCompatible = $isPhpCompatible && $isWebServerCompatible && $areExtensionsCompatible && $dbConnection['success'];
if ($bypassRequirements) {
$isFullyCompatible = true;
}
?>
<?php if ($bypassRequirements): ?>
<div class="alert alert-warning mb-4">
<i class="bi bi-exclamation-triangle-fill me-2"></i>
<strong>Requirements Bypass Enabled:</strong> System checks are being ignored.
</div>
<?php endif; ?>
<div class="compatibility-item">
<div class="d-flex justify-content-between align-items-center">
<span class="compatibility-label">
<i class="bi bi-database me-2"></i>Database Connection
</span>
<div class="d-flex align-items-center">
<span class="compatibility-value me-2">
<?php echo $dbConnection['success'] ? 'OK' : 'Failed'; ?>
</span>
<?php if ($dbConnection['success']): ?>
<i class="bi bi-check-circle-fill text-success"></i>
<?php else: ?>
<i class="bi bi-x-circle-fill text-danger"></i>
<?php endif; ?>
</div>
</div>
<div class="compatibility-requirement">
<?php if ($dbConnection['success']): ?>
Established MySQL Database Connection
<?php else: ?>
<span class="text-danger">
<?php echo htmlspecialchars($dbConnection['message']); ?>
<?php if (!empty($dbConnection['error'])): ?>
<br><small>Error: <?php echo htmlspecialchars($dbConnection['error']); ?></small>
<?php endif; ?>
</span>
<?php endif; ?>
</div>
</div>
<div class="compatibility-item">
<div class="d-flex justify-content-between align-items-center">
<span class="compatibility-label">
<i class="bi bi-code-slash me-2"></i>PHP Version
</span>
<div class="d-flex align-items-center">
<span class="compatibility-value me-2"><?php echo $phpVersion; ?></span>
<?php if ($isPhpCompatible): ?>
<i class="bi bi-check-circle-fill text-success"></i>
<?php else: ?>
<i class="bi bi-x-circle-fill text-danger"></i>
<?php endif; ?>
</div>
</div>
<div class="compatibility-requirement">
Requires PHP <?php echo $requiredVersion; ?> or higher.
</div>
</div>
<div class="compatibility-item">
<div class="d-flex justify-content-between align-items-center">
<span class="compatibility-label">
<i class="bi bi-puzzle me-2"></i>PHP Extensions
</span>
<div class="d-flex align-items-center">
<span class="compatibility-value me-2">
<?php echo $areExtensionsCompatible ? 'OK' : count($missingExtensions) . ' Missing'; ?>
</span>
<?php if ($areExtensionsCompatible): ?>
<i class="bi bi-check-circle-fill text-success"></i>
<?php else: ?>
<i class="bi bi-x-circle-fill text-danger"></i>
<?php endif; ?>
</div>
</div>
<div class="compatibility-requirement">
Required: curl, mbstring
</div>
</div>
<div class="compatibility-item">
<div class="d-flex justify-content-between align-items-center">
<span class="compatibility-label">
<i class="bi bi-globe me-2"></i>Web Server
</span>
<div class="d-flex align-items-center">
<span class="compatibility-value me-2"><?php echo htmlspecialchars($webServer); ?></span>
<?php if ($isWebServerCompatible): ?>
<i class="bi bi-check-circle-fill text-success"></i>
<?php else: ?>
<i class="bi bi-x-circle-fill text-danger"></i>
<?php endif; ?>
</div>
</div>
<div class="compatibility-requirement">
Requires Apache-style .htaccess support (Apache, LiteSpeed, OpenLiteSpeed, Lighttpd)
<?php if (!$isWebServerCompatible): ?>
<div class="text-danger mt-1">
<small>
<i class="bi bi-exclamation-triangle me-1"></i>
Your web server does not support .htaccess files. LibreKB requires .htaccess for URL rewriting.
</small>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php if (!$isFullyCompatible): ?>
<div class="alert alert-danger" role="alert">
<div class="d-flex justify-content-between align-items-start">
<div>
<strong>Unable to Continue</strong><br>
Please address any issues and refresh this page to proceed with the installation.
</div>
</div>
</div>
<?php endif; ?>
<form action="<?php echo $basePath; ?>/install" method="POST" <?php echo (!$isFullyCompatible) ? 'style="display: none;"' : ''; ?>>
<h3 class="section-title">
<i class="bi bi-person-plus me-2"></i>Create Admin User
</h3>
<div class="mb-3">
<label for="email" class="form-label">
<i class="bi bi-envelope me-2"></i>Email Address
</label>
<input type="email" class="form-control" id="email" name="email" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">
<i class="bi bi-lock me-2"></i>Password
</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<div class="d-grid">
<button type="submit" class="btn btn-primary">
<i class="bi bi-play-circle me-2"></i>Run Installer
</button>
</div>
</form>
</div>
</div>
<script src="<?php echo $basePath; ?>/vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
<script>
// Add loading state when installation form is submitted
document.addEventListener('DOMContentLoaded', function() {
const installForm = document.querySelector('form[action*="/install"]');
const submitButton = document.querySelector('button[type="submit"]');
if (installForm && submitButton) {
installForm.addEventListener('submit', function() {
submitButton.disabled = true;
submitButton.innerHTML = '<i class="bi bi-arrow-repeat spinner-border spinner-border-sm me-2" role="status"></i>Installing...';
});
}
});
</script>
</body>
</html>
?>