-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwelcome.php
More file actions
424 lines (391 loc) · 16.6 KB
/
Copy pathwelcome.php
File metadata and controls
424 lines (391 loc) · 16.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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
<?php
$title = "Welcome";
// Detect in-viewer context *before* output starts (viewer headers/cookies)
if (file_exists(__DIR__ . "/include/viewer_context.php")) {
include_once __DIR__ . "/include/viewer_context.php";
}
// Load config early (needed before header outputs HTML)
require_once __DIR__ . "/include/config.php";
// Build RSS URL (optionally mark viewer mode for compact/compatible rendering)
$rssUrl = RSS_FEED_URL;
if (!empty($IS_VIEWER)) {
$rssUrl .= (strpos($rssUrl, '?') !== false ? '&' : '?') . 'view=viewer';
}
require_once __DIR__ . "/include/header.php";
require_once __DIR__ . "/include/utils.php";
?>
<style>
/* 1. HERO & SLIDESHOW */
.welcome-hero {
position: relative;
border-radius: 15px;
padding: 4rem 2rem;
margin-bottom: 1.5rem;
text-align: center;
color: white;
overflow: hidden;
box-shadow: 0 10px 30px rgba(0,0,0,0.3);
min-height: 450px;
display: flex;
align-items: center;
justify-content: center;
}
.slideshow-container {
position: absolute; top: 0; left: 0; width: 100%; height: 100%;
z-index: 0;
}
.slideshow-overlay {
position: absolute; top: 0; left: 0; width: 100%; height: 100%;
background: linear-gradient(135deg, rgba(0,0,0,0.8), rgba(0,0,0,0.4));
z-index: 1;
}
.slide-image {
position: absolute; top: 0; left: 0; width: 100%; height: 100%;
object-fit: cover; opacity: 0; transition: opacity 2s ease-in-out;
}
.slide-image.active { opacity: 1; }
.hero-content {
position: relative; z-index: 2;
max-width: 800px; margin: 0 auto;
}
.welcome-title {
font-size: 3.5rem; font-weight: 800; margin-bottom: 0.5rem;
text-shadow: 2px 2px 10px rgba(0,0,0,0.6);
letter-spacing: -1px;
}
.welcome-subtitle {
font-size: 1.25rem; margin-bottom: 2rem; opacity: 0.95; font-weight: 500;
text-shadow: 1px 1px 4px rgba(0,0,0,0.5);
}
/* 2. STATS GRID */
.stats-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
gap: 1.5rem; margin-top: 1.5rem;
}
.stat-card {
/* Use card-bg variable for proper theme color */
background-color: var(--card-bg) !important;
border: 1px solid color-mix(in srgb, var(--primary-color), transparent 90%);
color: var(--primary-color);
border-radius: 12px;
padding: 1.5rem;
text-align: left;
box-shadow: 0 4px 6px rgba(0,0,0,0.05);
transition: transform 0.3s ease, opacity 0.6s ease;
opacity: 0; transform: translateY(20px);
display: flex;
align-items: center;
justify-content: center;
}
.stat-card:hover { transform: translateY(-5px) !important; box-shadow: 0 10px 20px rgba(0,0,0,0.1); }
.stat-content-wrapper { display: flex; align-items: center; }
.stat-icon {
font-size: 2.5rem;
margin-right: 1rem;
opacity: 0.8;
color: var(--accent-color); /* Icon matches buttons */
}
.stat-number {
font-size: 1.75rem;
font-weight: 700;
color: var(--accent-color); /* Number matches buttons */
line-height: 1;
}
.stat-label {
font-size: 0.85rem;
font-weight: 600;
opacity: 0.8;
text-transform: uppercase;
margin-top: 4px;
color: var(--primary-color); /* Label matches readable text */
}
/* 3. CONTENT CONTAINERS */
.content-card {
background-color: var(--card-bg) !important;
border-radius: 12px;
padding: 2rem;
margin-bottom: 1.5rem;
border: 1px solid color-mix(in srgb, var(--primary-color), transparent 90%);
box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}
.section-title {
font-weight: 700;
margin-bottom: 1.5rem;
display: flex; align-items: center;
color: var(--primary-color);
}
.section-title i { margin-right: 10px; color: var(--accent-color); }
/* 4. UPDATES & LISTS */
.daily-updates {
background: linear-gradient(135deg, var(--header-color), var(--footer-color));
border-radius: 12px;
padding: 2rem;
color: white;
margin-bottom: 1.5rem;
box-shadow: 0 10px 30px rgba(0,0,0,0.15);
}
/* Region List */
.region-item {
display: flex; justify-content: space-between; align-items: center;
padding: 0.8rem 1rem; margin-bottom: 0.5rem;
background-color: color-mix(in srgb, var(--card-bg), var(--primary-color) 6%);
border-radius: 10px; transition: all 0.2s;
border-left: 4px solid transparent;
color: var(--primary-color);
}
.region-item:hover {
background-color: color-mix(in srgb, var(--card-bg), var(--primary-color) 10%);
border-left-color: var(--accent-color);
transform: translateX(5px);
}
/* Link uses Accent Color (same as buttons) */
.region-link { text-decoration: none; color: var(--accent-color); font-weight: 600; }
.region-link:hover { color: var(--primary-color); }
</style>
<div class="welcome-hero">
<div class="slideshow-container">
<div class="slideshow-overlay"></div>
<?php
$image_folder = SLIDESHOW_FOLDER;
$allowed_extensions = ['jpg', 'jpeg', 'png', 'gif'];
$images = [];
if (is_dir($image_folder)) {
$files = scandir($image_folder);
foreach ($files as $file) {
if (!in_array($file, [".", "..", "_notes", "Thumbs.db"])) {
$file_info = pathinfo($image_folder . "/" . $file);
if (isset($file_info['extension']) && in_array(strtolower($file_info['extension']), $allowed_extensions)) {
$images[] = $image_folder . "/" . $file;
}
}
}
}
foreach ($images as $index => $image): ?>
<img class="slide-image <?php echo $index === 0 ? 'active' : ''; ?>"
src="<?php echo htmlspecialchars($image); ?>"
alt="Slide <?php echo $index + 1; ?>">
<?php endforeach; ?>
</div>
<div class="hero-content">
<h1 class="welcome-title"><?php echo SITE_NAME; ?></h1>
<p class="welcome-subtitle">Welcome to our OpenSimulator Grid</p>
<?php if (TEXT_ON === 'ON'): ?>
<div class="welcome-text mb-4 opacity-90">
<?php echo WELCOME_TEXT; ?>
</div>
<?php endif; ?>
<div class="mt-4 d-flex gap-3 justify-content-center">
<a href="register.php" class="btn btn-lg btn-outline-primary rounded-pill px-5 fw-bold shadow">Join Now</a>
<a href="login.php" class="btn btn-lg btn-outline-primary rounded-pill px-5 fw-bold shadow">Login</a>
</div>
</div>
</div>
<div class="content-card">
<h3 class="section-title"><i class="bi bi-bar-chart-fill"></i> Grid Statistics</h3>
<?php
$con = null;
try {
$con = db();
if (!$con) throw new Exception("DB Connection Failed");
$stats = ['online'=>0, 'regions'=>0, 'accounts'=>0, 'active'=>0, 'var'=>0, 'single'=>0];
if($r=mysqli_query($con, "SELECT COUNT(DISTINCT UserID) FROM Presence")) {
$stats['online'] = mysqli_fetch_row($r)[0];
} elseif($r=mysqli_query($con, "SELECT COUNT(*) FROM Presence")) {
$stats['online'] = mysqli_fetch_row($r)[0];
}
if($r=mysqli_query($con, "SELECT COUNT(*) FROM regions")) $stats['regions'] = mysqli_fetch_row($r)[0];
// Var / Single region counts (requires regions.sizeX/sizeY)
$hasSizeX = false; $hasSizeY = false;
if ($r = mysqli_query($con, "SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME='regions' AND COLUMN_NAME='sizeX'")) {
$hasSizeX = ((int)mysqli_fetch_row($r)[0] > 0);
}
if ($r = mysqli_query($con, "SELECT COUNT(*) FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_SCHEMA = DATABASE() AND TABLE_NAME='regions' AND COLUMN_NAME='sizeY'")) {
$hasSizeY = ((int)mysqli_fetch_row($r)[0] > 0);
}
if ($hasSizeX && $hasSizeY) {
if ($r = mysqli_query($con, "SELECT SUM(CASE WHEN (sizeX > 256 OR sizeY > 256) THEN 1 ELSE 0 END) AS var_regions, SUM(CASE WHEN (sizeX = 256 AND sizeY = 256) THEN 1 ELSE 0 END) AS single_regions FROM regions")) {
$row = mysqli_fetch_assoc($r);
$stats['var'] = (int)($row['var_regions'] ?? 0);
$stats['single'] = (int)($row['single_regions'] ?? 0);
}
} else {
$stats['var'] = 'N/A';
$stats['single'] = 'N/A';
}
if($r=mysqli_query($con, "SELECT COUNT(*) FROM UserAccounts")) $stats['accounts'] = mysqli_fetch_row($r)[0];
if($r=mysqli_query($con, "SELECT COUNT(*) FROM GridUser WHERE Login > (UNIX_TIMESTAMP() - (30*86400))")) $stats['active'] = mysqli_fetch_row($r)[0];
} catch (Exception $e) {
$stats = array_fill_keys(['online','regions','accounts','active','var','single'], 'N/A');
} finally {
if (!empty($con) && $con instanceof mysqli) {
mysqli_close($con);
}
}
?>
<div class="stats-grid">
<div class="stat-card">
<div class="stat-content-wrapper">
<i class="bi bi-people-fill stat-icon"></i>
<div>
<div class="stat-number"><?php echo $stats['online']; ?></div>
<div class="stat-label">Online</div>
</div>
</div>
</div>
<div class="stat-card">
<div class="stat-content-wrapper">
<i class="bi bi-map-fill stat-icon"></i>
<div>
<div class="stat-number"><?php echo $stats['regions']; ?></div>
<div class="stat-label">Regions</div>
</div>
</div>
</div>
<div class="stat-card">
<div class="stat-content-wrapper">
<i class="bi bi-person-badge-fill stat-icon"></i>
<div>
<div class="stat-number"><?php echo $stats['accounts']; ?></div>
<div class="stat-label">Accounts</div>
</div>
</div>
</div>
<div class="stat-card">
<div class="stat-content-wrapper">
<i class="bi bi-activity stat-icon"></i>
<div>
<div class="stat-number"><?php echo $stats['active']; ?></div>
<div class="stat-label">Active</div>
</div>
</div>
</div>
<div class="stat-card">
<div class="stat-content-wrapper">
<i class="bi bi-globe stat-icon"></i>
<div>
<div class="stat-number"><?php echo (($stats['var']==='N/A' || $stats['single']==='N/A') ? 'N/A' : ((int)$stats['var'] . ' / ' . (int)$stats['single'])); ?></div>
<div class="stat-label">Var / Single</div>
</div>
</div>
</div>
</div>
</div>
<?php if (SHOW_DAILY_UPDATE): ?>
<div class="daily-updates">
<h3 class="mb-3" style="font-weight:700"><i class="bi bi-newspaper me-2"></i> Daily Updates</h3>
<div class="update-content">
<?php if (DAILY_UPDATE_TYPE === 'rss'): ?>
<div id="rss-content">Loading updates...</div>
<script>
(function(){
const el = document.getElementById('rss-content');
if (!el) return;
const url = '<?php echo $rssUrl; ?>';
// Some embedded viewers are missing fetch(); fall back to XHR.
if (window.fetch) {
fetch(url)
.then(r => r.text())
.then(d => { el.innerHTML = d; })
.catch(() => { el.innerHTML = 'Updates unavailable.'; });
} else {
try {
const xhr = new XMLHttpRequest();
xhr.open('GET', url, true);
xhr.onload = function(){
el.innerHTML = (xhr.status >= 200 && xhr.status < 300) ? xhr.responseText : 'Updates unavailable.';
};
xhr.onerror = function(){ el.innerHTML = 'Updates unavailable.'; };
xhr.send();
} catch (e) {
el.innerHTML = 'Updates unavailable.';
}
}
})();
</script>
<?php else: ?>
<p class="lead mb-0"><?php echo DAILYTEXT; ?></p>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<div class="content-card">
<h3 class="section-title"><i class="bi bi-geo-alt-fill"></i> Recent Regions</h3>
<div class="regions-list">
<?php
$con = null;
try {
$con = db();
if ($con) {
$sql = "SELECT regionName FROM regions ORDER BY last_seen DESC LIMIT 10";
$res = mysqli_query($con, $sql);
if ($res && mysqli_num_rows($res) > 0) {
while ($row = mysqli_fetch_assoc($res)) {
// In-viewer splash page context: populates the "Start Location" box before login
if (!empty($IS_VIEWER)) {
$url = "secondlife://" . rawurlencode($row['regionName']) . "/110/128/22";
} else {
// External web browser context: uses hop:// URI scheme
$cleanHost = rtrim(str_replace(['http://', 'https://'], '', BASE_URL), '/');
$port = defined('GRID_PORT') ? ltrim(GRID_PORT, ':') : '';
$gridHost = $cleanHost . ($port !== '' ? ':' . $port : '');
$url = "hop://" . $gridHost . "/" . rawurlencode($row['regionName']);
}
?>
<div class="region-item">
<div>
<div class="fw-bold fs-5"><?php echo htmlspecialchars($row['regionName']); ?></div>
</div>
<a href="<?php echo $url; ?>" class="btn btn-sm btn-outline-primary rounded-pill px-3">
<i class="bi bi-box-arrow-in-right me-1"></i> Teleport
</a>
</div>
<?php
}
} else { echo '<div class="text-muted p-3">No active regions found.</div>'; }
}
} catch (Exception $e) {
// Silently swallow errors or add log if desired
} finally {
if (!empty($con) && $con instanceof mysqli) {
mysqli_close($con);
}
}
?>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
// Slideshow
const slides = document.querySelectorAll('.slide-image');
let currentSlide = 0;
if (slides.length > 1) {
setInterval(() => {
slides[currentSlide].classList.remove('active');
currentSlide = (currentSlide + 1) % slides.length;
slides[currentSlide].classList.add('active');
}, <?php echo (int)(defined('SLIDESHOW_DELAY') ? SLIDESHOW_DELAY : 5000); ?>);
}
// Animations (IntersectionObserver is missing in some embedded viewers)
if ('IntersectionObserver' in window) {
const observer = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting) {
entry.target.style.opacity = '1';
entry.target.style.transform = 'translateY(0)';
}
});
});
document.querySelectorAll('.stat-card').forEach((card, index) => {
card.style.transition = `opacity 0.6s ease ${index * 0.1}s, transform 0.6s ease ${index * 0.1}s`;
observer.observe(card);
});
} else {
document.querySelectorAll('.stat-card').forEach((card) => {
card.style.opacity = '1';
card.style.transform = 'translateY(0)';
});
}
});
</script>
<?php include_once "include/" . FOOTER_FILE; ?>