Repository navigation
Expand file tree
/
Copy pathindex.php
More file actions
464 lines (435 loc) · 24.2 KB
/
Copy pathindex.php
File metadata and controls
464 lines (435 loc) · 24.2 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
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
<?php
/**
* Public page router. Resolves which `pages` row to render (by ?page_slug=, or the
* is_main page when none is given — the .htaccess rewrite is what turns /some-slug
* into ?page_slug=some-slug), then renders it.
*/
if (!file_exists(__DIR__ . '/includes/config.php')) {
header('Location: install.php');
exit;
}
require_once __DIR__ . '/includes/functions.php';
require_once __DIR__ . '/includes/security.php';
start_secure_session();
$isPreview = is_logged_in() && isset($_GET['preview']);
if ($isPreview && isset($_GET['page_id'])) {
// Admin live preview: page context comes from an explicit page_id, bypassing slug lookup.
$stmt = db()->prepare('SELECT * FROM pages WHERE id = ?');
$stmt->execute([(int) $_GET['page_id']]);
$page = $stmt->fetch();
} else {
$requestedSlug = isset($_GET['page_slug']) ? trim($_GET['page_slug']) : '';
if ($requestedSlug !== '') {
$stmt = db()->prepare('SELECT * FROM pages WHERE slug = ?');
$stmt->execute([$requestedSlug]);
$page = $stmt->fetch();
} else {
$page = db()->query('SELECT * FROM pages WHERE is_main = 1 LIMIT 1')->fetch();
}
}
if (!$page) {
http_response_code(404);
require __DIR__ . '/404.php';
exit;
}
$pageId = (int) $page['id'];
$appearanceSourceId = appearance_source_page_id($page);
$pageLanguage = $page['language'] ?? 'en';
$pageDir = $pageLanguage === 'ar' ? 'rtl' : 'ltr';
log_page_visit($pageId); // must run before any output (sets the visitor-id cookie)
security_headers();
if (get_setting('maintenance_mode', '0') === '1' && !is_admin_viewing()) {
http_response_code(503);
header('Retry-After: 3600');
?>
<!DOCTYPE html>
<html lang="<?= e($pageLanguage) ?>" dir="<?= e($pageDir) ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= e(get_setting('site_name', 'My Links')) ?></title>
<style>
body { font-family: system-ui, sans-serif; background: #f5f5f7; color: #1c1c1e; min-height: 100vh; display: flex; align-items: center; justify-content: center; margin: 0; text-align: center; padding: 1.5rem; }
</style>
</head>
<body>
<div>
<h1 style="font-size:1.3rem;">We'll be right back</h1>
<p style="opacity:.7;">This page is temporarily down for maintenance.</p>
</div>
</body>
</html>
<?php
exit;
}
// Admin-only live preview: unsaved Appearance-page edits can be reflected here via
// ?preview=1&page_id=<id>&<setting_key>=<value> without touching the database. Anyone
// else just gets the real, saved settings — same pattern as the QR preview endpoint.
const PREVIEWABLE_KEYS = [
'profile_name', 'bio', 'show_logo', 'show_site_name', 'show_profile_image', 'show_bio', 'show_visit_count',
'bg_type', 'bg_color', 'bg_gradient_start', 'bg_gradient_end', 'bg_video_source', 'bg_video_youtube_id',
'text_color', 'button_color', 'button_text_color', 'border_color', 'border_enabled', 'border_radius', 'button_shadow',
'page_max_width', 'font_family', 'button_style', 'icon_style', 'profile_image_shape', 'spacing',
'button_opacity', 'share_button_color', 'lang_switcher_color', 'share_lang_radius',
'card_enabled', 'card_bg_color', 'card_bg_opacity', 'card_border_color', 'card_border_enabled', 'card_border_radius',
'video_overlay_type', 'video_overlay_color', 'video_overlay_opacity',
'video_overlay_gradient_start', 'video_overlay_gradient_end',
];
function page_setting_or_preview(int $pageId, string $key, ?string $default, bool $isPreview): ?string
{
if ($isPreview && in_array($key, PREVIEWABLE_KEYS, true) && isset($_GET[$key])) {
return clean_str($_GET[$key]);
}
return get_page_setting($pageId, $key, $default);
}
// Translated / independent-per-page content — always read from this page's own row.
$siteName = get_setting('site_name', 'My Links');
$profileName = page_setting_or_preview($pageId, 'profile_name', '', $isPreview);
$bio = page_setting_or_preview($pageId, 'bio', '', $isPreview);
$favicon = get_setting('favicon', '');
$showLanguageSwitcher = get_page_setting($pageId, 'show_language_switcher', '1') === '1';
$pageTitle = get_page_setting($pageId, 'page_title', '') ?: ($page['title'] ?: $siteName);
$metaDesc = get_page_setting($pageId, 'meta_description', '');
$metaKeywords = get_page_setting($pageId, 'meta_keywords', '');
$ogTitle = get_page_setting($pageId, 'og_title', '') ?: $pageTitle;
$ogDesc = get_page_setting($pageId, 'og_description', '') ?: $metaDesc;
$ogImage = get_page_setting($pageId, 'og_image', '');
$canonicalUrl = get_page_setting($pageId, 'canonical_url', '') ?: page_public_url($page);
$showName = page_setting_or_preview($pageId, 'show_site_name', '1', $isPreview) === '1';
$showBio = page_setting_or_preview($pageId, 'show_bio', '1', $isPreview) === '1';
$showVisitCount = page_setting_or_preview($pageId, 'show_visit_count', '0', $isPreview) === '1';
$visitCount = 0;
if ($showVisitCount) {
$visitCountStmt = db()->prepare('SELECT COUNT(*) FROM page_visits WHERE page_id = ?');
$visitCountStmt->execute([$pageId]);
$visitCount = (int) $visitCountStmt->fetchColumn();
}
// Synced / appearance-source content — for a translation page this transparently reads
// from its primary via $appearanceSourceId (== $pageId for every standalone/primary page).
$profileImg = get_page_setting($appearanceSourceId, 'profile_image', '');
$logoImg = get_page_setting($appearanceSourceId, 'logo_image', '');
$showLinkDescriptions = get_page_setting($appearanceSourceId, 'show_link_descriptions', '1') === '1';
$showLogo = page_setting_or_preview($appearanceSourceId, 'show_logo', '0', $isPreview) === '1';
$showAvatar = page_setting_or_preview($appearanceSourceId, 'show_profile_image', '1', $isPreview) === '1';
$bgType = page_setting_or_preview($appearanceSourceId, 'bg_type', 'solid', $isPreview);
$bgColor = page_setting_or_preview($appearanceSourceId, 'bg_color', '#f5f5f7', $isPreview);
$bgGradStart = page_setting_or_preview($appearanceSourceId, 'bg_gradient_start', '#f5f5f7', $isPreview);
$bgGradEnd = page_setting_or_preview($appearanceSourceId, 'bg_gradient_end', '#e5e5ea', $isPreview);
$bgImage = get_page_setting($appearanceSourceId, 'bg_image', '');
$bgVideoSource = page_setting_or_preview($appearanceSourceId, 'bg_video_source', 'upload', $isPreview);
$bgVideoYoutubeRaw = page_setting_or_preview($appearanceSourceId, 'bg_video_youtube_id', '', $isPreview);
$bgVideoYoutubeId = $bgVideoYoutubeRaw ? extract_youtube_id($bgVideoYoutubeRaw) : null;
$bgVideoFile = get_page_setting($appearanceSourceId, 'bg_video_file', '');
$textColor = page_setting_or_preview($appearanceSourceId, 'text_color', '#1c1c1e', $isPreview);
$btnColor = page_setting_or_preview($appearanceSourceId, 'button_color', '#1c1c1e', $isPreview);
$btnTextColor = page_setting_or_preview($appearanceSourceId, 'button_text_color', '#ffffff', $isPreview);
$borderColor = page_setting_or_preview($appearanceSourceId, 'border_color', '#d1d1d6', $isPreview);
$borderEnabled = page_setting_or_preview($appearanceSourceId, 'border_enabled', '1', $isPreview) === '1';
$radius = (int) page_setting_or_preview($appearanceSourceId, 'border_radius', '12', $isPreview);
$buttonShadow = page_setting_or_preview($appearanceSourceId, 'button_shadow', '0', $isPreview) === '1';
$maxWidth = (int) page_setting_or_preview($appearanceSourceId, 'page_max_width', '600', $isPreview);
$fontKey = page_setting_or_preview($appearanceSourceId, 'font_family', 'system-ui', $isPreview);
$buttonStyle = page_setting_or_preview($appearanceSourceId, 'button_style', 'filled', $isPreview);
$iconStyle = page_setting_or_preview($appearanceSourceId, 'icon_style', 'plain', $isPreview);
$avatarShape = page_setting_or_preview($appearanceSourceId, 'profile_image_shape', 'circle', $isPreview);
$spacing = page_setting_or_preview($appearanceSourceId, 'spacing', 'normal', $isPreview);
$appearanceMode = get_page_setting($appearanceSourceId, 'appearance_mode', 'light');
$customCss = sanitize_custom_css(get_page_setting($appearanceSourceId, 'custom_css', ''));
$buttonOpacity = (int) page_setting_or_preview($appearanceSourceId, 'button_opacity', '100', $isPreview);
$shareBtnColor = page_setting_or_preview($appearanceSourceId, 'share_button_color', '#f0f0f0', $isPreview);
$langBtnColor = page_setting_or_preview($appearanceSourceId, 'lang_switcher_color', '#f0f0f0', $isPreview);
$cardEnabled = page_setting_or_preview($appearanceSourceId, 'card_enabled', '0', $isPreview) === '1';
$cardBgColor = page_setting_or_preview($appearanceSourceId, 'card_bg_color', '#ffffff', $isPreview);
$cardBgOpacity = (int) page_setting_or_preview($appearanceSourceId, 'card_bg_opacity', '100', $isPreview);
$cardBorderColor = page_setting_or_preview($appearanceSourceId, 'card_border_color', '#e5e5ea', $isPreview);
$cardBorderEnabled = page_setting_or_preview($appearanceSourceId, 'card_border_enabled', '1', $isPreview) === '1';
$cardBorderRadius = (int) page_setting_or_preview($appearanceSourceId, 'card_border_radius', '20', $isPreview);
$shareLangRadius = (int) page_setting_or_preview($appearanceSourceId, 'share_lang_radius', '21', $isPreview);
$videoOverlayType = page_setting_or_preview($appearanceSourceId, 'video_overlay_type', 'solid', $isPreview);
$videoOverlayColor = page_setting_or_preview($appearanceSourceId, 'video_overlay_color', '#000000', $isPreview);
$videoOverlayOpacity = (int) page_setting_or_preview($appearanceSourceId, 'video_overlay_opacity', '25', $isPreview);
$videoOverlayGradStart = page_setting_or_preview($appearanceSourceId, 'video_overlay_gradient_start', '#000000', $isPreview);
$videoOverlayGradEnd = page_setting_or_preview($appearanceSourceId, 'video_overlay_gradient_end', '#000000', $isPreview);
$fontStack = FONT_FAMILIES[$fontKey]['css'] ?? FONT_FAMILIES['system-ui']['css'];
$googleFontsUrl = google_fonts_url([$fontKey]);
// Skipped during live preview: reloading a heavy YouTube/video embed on every keystroke
// (the preview iframe fully reloads on every field change) makes the whole editor feel
// like it's freezing. The real saved page still renders the video normally.
$showVideoBg = !$isPreview && $bgType === 'video' && (
($bgVideoSource === 'youtube' && $bgVideoYoutubeId) ||
($bgVideoSource === 'upload' && $bgVideoFile)
);
switch (true) {
case $bgType === 'gradient':
$bgCss = 'linear-gradient(160deg, ' . e($bgGradStart) . ', ' . e($bgGradEnd) . ')';
break;
case $bgType === 'image':
$bgCss = $bgImage ? "url('" . e($bgImage) . "') center/cover no-repeat fixed" : e($bgColor);
break;
case $showVideoBg:
// The video itself renders as a fixed background element; this is just the color
// shown behind it before it loads (or if bg_type=video but nothing was configured).
$bgCss = '#000000';
break;
default:
$bgCss = e($bgColor);
}
// Button style variants (filled/outline/soft) resolve to a background + border pair.
switch ($buttonStyle) {
case 'outline':
$btnBgCss = 'transparent';
$btnTextCss = e($btnColor);
$btnBorderCss = e($btnColor);
break;
case 'soft':
$btnBgCss = e(hex_with_alpha($btnColor, 0.14));
$btnTextCss = e($btnColor);
$btnBorderCss = 'transparent';
break;
default:
$btnBgCss = e(hex_with_alpha($btnColor, $buttonOpacity / 100));
$btnTextCss = e($btnTextColor);
$btnBorderCss = $borderEnabled ? e($borderColor) : 'transparent';
}
$cardBgCss = e(hex_with_alpha($cardBgColor, $cardBgOpacity / 100));
switch ($videoOverlayType) {
case 'none':
$videoOverlayCss = 'transparent';
break;
case 'gradient':
$videoOverlayCss = 'linear-gradient(180deg, '
. hex_with_alpha($videoOverlayGradStart, $videoOverlayOpacity / 100) . ', '
. hex_with_alpha($videoOverlayGradEnd, $videoOverlayOpacity / 100) . ')';
break;
default:
$videoOverlayCss = hex_with_alpha($videoOverlayColor, $videoOverlayOpacity / 100);
}
$links = get_active_links($page);
$linkSections = group_links_into_sections($links, $page);
$shareEnabled = get_page_setting($appearanceSourceId, 'share_button_enabled', '1') === '1';
// QR settings are literal per-page (not synced through appearance_source_page_id), matching
// how the rest of the QR feature already works — each page's own code, even a translation.
$qrFloatingEnabled = get_page_setting($pageId, 'qr_enabled', '1') === '1'
&& get_page_setting($pageId, 'qr_floating_enabled', '0') === '1';
$profileUrl = page_public_url($page);
$translationPartner = get_translation_partner($page);
$bodyClasses = ['spacing-' . preg_replace('/[^a-z]/', '', $spacing), 'icon-style-' . preg_replace('/[^a-z]/', '', $iconStyle)];
if ($showVideoBg) {
$bodyClasses[] = 'has-video-bg';
}
if ($cardEnabled) {
$bodyClasses[] = 'has-card';
}
?>
<!DOCTYPE html>
<html lang="<?= e($pageLanguage) ?>" dir="<?= e($pageDir) ?>">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="color-scheme" content="<?= $appearanceMode === 'dark' ? 'dark' : 'light' ?>">
<title><?= e($pageTitle) ?></title>
<meta name="description" content="<?= e($metaDesc) ?>">
<?php if ($metaKeywords !== ''): ?><meta name="keywords" content="<?= e($metaKeywords) ?>"><?php endif; ?>
<link rel="canonical" href="<?= e($canonicalUrl) ?>">
<?php if ($favicon): ?><link rel="icon" href="<?= e($favicon) ?>"><?php endif; ?>
<meta property="og:type" content="profile">
<meta property="og:title" content="<?= e($ogTitle) ?>">
<meta property="og:description" content="<?= e($ogDesc) ?>">
<meta property="og:url" content="<?= e($canonicalUrl) ?>">
<?php if ($ogImage): ?><meta property="og:image" content="<?= e(current_base_url() . $ogImage) ?>"><?php endif; ?>
<meta name="twitter:card" content="<?= $ogImage ? 'summary_large_image' : 'summary' ?>">
<meta name="twitter:title" content="<?= e($ogTitle) ?>">
<meta name="twitter:description" content="<?= e($ogDesc) ?>">
<?php if ($ogImage): ?><meta name="twitter:image" content="<?= e(current_base_url() . $ogImage) ?>"><?php endif; ?>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
<?php if ($googleFontsUrl): ?>
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link rel="stylesheet" href="<?= e($googleFontsUrl) ?>">
<?php endif; ?>
<link rel="stylesheet" href="<?= e(asset_url('/assets/css/public.css')) ?>">
<style>
:root {
--page-bg-flat: <?= e($bgColor) ?>;
--page-bg: <?= $bgCss ?>;
--page-text: <?= e($textColor) ?>;
--page-font: <?= $fontStack ?>;
--btn-bg: <?= $btnBgCss ?>;
--btn-text: <?= $btnTextCss ?>;
--btn-border: <?= $btnBorderCss ?>;
--btn-radius: <?= $radius ?>px;
--btn-shadow: <?= $buttonShadow ? '0 4px 14px rgba(0, 0, 0, 0.12)' : 'none' ?>;
--page-max-width: <?= $maxWidth ?>px;
--share-btn-bg: <?= e($shareBtnColor) ?>;
--lang-btn-bg: <?= e($langBtnColor) ?>;
--share-lang-radius: <?= $shareLangRadius ?>px;
--card-bg: <?= $cardBgCss ?>;
--card-border: <?= $cardBorderEnabled ? e($cardBorderColor) : 'transparent' ?>;
--card-radius: <?= $cardBorderRadius ?>px;
--video-overlay: <?= $videoOverlayCss ?>;
}
</style>
<?php if ($customCss !== ''): ?>
<style id="custom-css"><?= $customCss ?></style>
<?php endif; ?>
</head>
<body class="<?= e(implode(' ', $bodyClasses)) ?>">
<?php if ($showVideoBg): ?>
<div class="bg-video-wrap" aria-hidden="true">
<?php if ($bgVideoSource === 'youtube' && $bgVideoYoutubeId): ?>
<iframe
src="https://www.youtube-nocookie.com/embed/<?= e($bgVideoYoutubeId) ?>?autoplay=1&mute=1&loop=1&playlist=<?= e($bgVideoYoutubeId) ?>&controls=0&showinfo=0&modestbranding=1&playsinline=1&disablekb=1&iv_load_policy=3"
frameborder="0"
allow="autoplay; encrypted-media"
tabindex="-1"
></iframe>
<?php else: ?>
<video autoplay muted loop playsinline>
<source src="<?= e($bgVideoFile) ?>" type="video/mp4">
</video>
<?php endif; ?>
</div>
<div class="bg-video-overlay" aria-hidden="true"></div>
<?php endif; ?>
<div class="profile-wrap">
<div class="profile-card">
<?php if ($showLanguageSwitcher && $translationPartner): ?>
<a href="<?= e(page_public_url($translationPartner)) ?>" class="lang-switcher" title="<?= e(SUPPORTED_LANGUAGES[$translationPartner['language']] ?? $translationPartner['language']) ?>">
<?= e(NATIVE_LANGUAGE_NAMES[$translationPartner['language']] ?? strtoupper($translationPartner['language'])) ?>
</a>
<?php endif; ?>
<?php if ($shareEnabled): ?>
<button type="button" class="share-fab" id="shareBtn" aria-label="Share this page" data-url="<?= e($profileUrl) ?>" data-title="<?= e($profileName ?: $siteName) ?>" data-page-id="<?= (int) $pageId ?>">
<i class="bi bi-share-fill"></i>
</button>
<div class="share-menu d-none" id="shareMenu">
<button type="button" class="share-menu__item" data-platform="copy_link">
<i class="bi bi-link-45deg"></i> Copy link
</button>
<a class="share-menu__item" data-platform="whatsapp" target="_blank" rel="noopener noreferrer" href="#">
<i class="bi bi-whatsapp"></i> WhatsApp
</a>
<a class="share-menu__item" data-platform="telegram" target="_blank" rel="noopener noreferrer" href="#">
<i class="bi bi-telegram"></i> Telegram
</a>
<a class="share-menu__item" data-platform="twitter" target="_blank" rel="noopener noreferrer" href="#">
<i class="bi bi-twitter-x"></i> X / Twitter
</a>
<a class="share-menu__item" data-platform="facebook" target="_blank" rel="noopener noreferrer" href="#">
<i class="bi bi-facebook"></i> Facebook
</a>
<a class="share-menu__item" data-platform="linkedin" target="_blank" rel="noopener noreferrer" href="#">
<i class="bi bi-linkedin"></i> LinkedIn
</a>
<a class="share-menu__item" data-platform="email" href="#">
<i class="bi bi-envelope"></i> Email
</a>
<button type="button" class="share-menu__item d-none" data-platform="native" id="shareNativeBtn">
<i class="bi bi-three-dots"></i> More options
</button>
</div>
<?php endif; ?>
<?php if ($showLogo && $logoImg): ?>
<img src="<?= e($logoImg) ?>" alt="Logo" class="profile-logo" loading="lazy">
<?php endif; ?>
<?php if ($showAvatar && $profileImg): ?>
<img src="<?= e($profileImg) ?>" alt="<?= e($profileName) ?>" class="profile-avatar profile-avatar--<?= e($avatarShape) ?>" loading="lazy">
<?php elseif ($showAvatar): ?>
<div class="profile-avatar profile-avatar--<?= e($avatarShape) ?> profile-avatar--placeholder">
<i class="bi bi-person-fill"></i>
</div>
<?php endif; ?>
<?php if ($showName && $profileName): ?>
<h1 class="profile-name"><?= e($profileName) ?></h1>
<?php endif; ?>
<?php if ($showBio && $bio): ?>
<p class="profile-bio"><?= nl2br(e($bio)) ?></p>
<?php endif; ?>
<?php if (empty($links)): ?>
<div class="link-list">
<p class="text-center text-muted small">No links to show yet.</p>
</div>
<?php endif; ?>
<?php foreach ($linkSections as $section): ?>
<div class="link-group">
<?php if ($section['group']): ?>
<h2 class="link-group__title"><?= e($section['group']['name']) ?></h2>
<?php endif; ?>
<div class="link-list">
<?php foreach ($section['links'] as $link): ?>
<?php
$href = link_href($link);
$target = $link['open_new_tab'] ? '_blank' : '_self';
$rel = $link['open_new_tab'] ? 'noopener noreferrer' : '';
$icon = $link['icon_source'] === 'upload' && $link['icon_path']
? null
: ($link['icon_class'] ?: link_type_icon($link['url_type']));
$customStyle = '';
if (!empty($link['button_color'])) {
$customStyle .= 'background-color:' . e($link['button_color']) . ';border-color:' . e($link['button_color']) . ';';
}
if (!empty($link['text_color'])) {
$customStyle .= 'color:' . e($link['text_color']) . ';';
}
?>
<?php if ($link['url_type'] === 'audio'): ?>
<div class="audio-player" data-link-id="<?= (int) $link['id'] ?>" style="<?= $customStyle ?>">
<button type="button" class="audio-player__toggle" aria-label="Play">
<i class="bi bi-play-fill"></i>
</button>
<div class="audio-player__title-wrap">
<span class="audio-player__preview-label"><?= $pageLanguage === 'ar' ? 'إستماع' : 'Preview' ?></span>
<span class="audio-player__title-scroll">
<span class="audio-player__title-track">
<span class="audio-player__title-text"><?= e($link['title']) ?></span>
</span>
</span>
</div>
<span class="audio-player__eq" aria-hidden="true"><span></span><span></span><span></span><span></span></span>
<div class="audio-player__seek" role="slider" tabindex="0" aria-label="Seek"
aria-valuemin="0" aria-valuemax="100" aria-valuenow="0">
<div class="audio-player__fill"></div>
</div>
<audio class="audio-player__audio" preload="none" src="<?= e($href) ?>"></audio>
</div>
<?php else: ?>
<a href="<?= e($href) ?>"
class="link-btn"
target="<?= e($target) ?>"
rel="<?= e($rel) ?>"
data-link-id="<?= (int) $link['id'] ?>"
style="<?= $customStyle ?>">
<span class="link-btn__icon">
<?php if ($icon): ?>
<i class="bi <?= e($icon) ?>"></i>
<?php else: ?>
<img src="<?= e($link['icon_path']) ?>" alt="" loading="lazy">
<?php endif; ?>
</span>
<span class="link-btn__text">
<span class="link-btn__title"><?= e($link['title']) ?></span>
<?php if ($showLinkDescriptions && !empty($link['description'])): ?>
<span class="link-btn__desc"><?= e($link['description']) ?></span>
<?php endif; ?>
</span>
</a>
<?php endif; ?>
<?php endforeach; ?>
</div>
</div>
<?php endforeach; ?>
<?php if ($showVisitCount): ?>
<p class="profile-visit-count"><i class="bi bi-eye"></i> <?= number_format($visitCount) ?> visits</p>
<?php endif; ?>
</div>
<footer class="profile-footer"><?= credit_html() ?></footer>
</div>
<?php if ($qrFloatingEnabled): ?>
<div class="qr-floating">
<img src="/api/qr.php?page_id=<?= $pageId ?>" alt="QR code" loading="lazy" width="120" height="120">
<span class="qr-floating__label"><?= $pageLanguage === 'ar' ? 'امسح لفتح الصفحة على الجوال' : 'Scan to open on mobile' ?></span>
</div>
<?php endif; ?>
<script src="<?= e(asset_url('/assets/js/public.js')) ?>"></script>
</body>
</html>