-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgc_public_top.php
More file actions
148 lines (127 loc) · 4.64 KB
/
Copy pathgc_public_top.php
File metadata and controls
148 lines (127 loc) · 4.64 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
<?php
// Shared layout for public pages (index/plans/login/dashboard)
require_once __DIR__ . '/helpers.php';
require_once __DIR__ . '/db.php';
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
// Enforce maintenance mode for public storefront pages (frontend)
try {
$pdo_maint = db();
if (function_exists('gc_enforce_maintenance')) {
gc_enforce_maintenance($pdo_maint, ['format' => 'html']);
}
} catch (Throwable $e) {
// ignore (never block rendering due to maintenance check errors)
}
$page = basename($_SERVER['PHP_SELF'] ?? '');
function _gc_active(string $file): string {
$p = basename($_SERVER['PHP_SELF'] ?? '');
return $p === $file ? 'active' : '';
}
$PUBLIC_TITLE = $PUBLIC_TITLE ?? 'XTREAM ui GAME CHANGER';
$PUBLIC_SIDEBAR = (bool)($PUBLIC_SIDEBAR ?? false);
$PUBLIC_PAGE = $PUBLIC_PAGE ?? $page;
$user = null;
$displayName = 'Guest';
$initial = 'G';
$avatarUrl = null;
try {
if (!empty($_SESSION['store_user'])) {
$pdo = db();
$uid = is_array($_SESSION['store_user']) ? (int)($_SESSION['store_user']['id'] ?? 0) : (int)$_SESSION['store_user'];
if ($uid > 0) {
$st = $pdo->prepare('SELECT id, username, name FROM users WHERE id=?');
$st->execute([$uid]);
$user = $st->fetch();
if ($user) {
$displayName = trim((string)($user['name'] ?? ''));
if ($displayName === '') $displayName = (string)($user['username'] ?? '');
$initial = strtoupper(substr($displayName, 0, 1));
$avatarUrl = gc_avatar_url((int)($user['id'] ?? 0));
}
}
}
} catch (Throwable $e) {
// layout must never break pages
}
?><!doctype html>
<html>
<head>
<link rel="icon" href="/favicon.ico">
<link rel="icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<link rel="apple-touch-icon" sizes="180x180" href="/apple-touch-icon.png">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title><?= e($PUBLIC_TITLE) ?></title>
<link rel="stylesheet" href="/portal/assets/portal.css">
<link rel="stylesheet" href="/portal/assets/public.css">
</head>
<body data-page="<?= e($PUBLIC_PAGE) ?>">
<?php
// Sliding background wall (public home only)
require_once __DIR__ . '/hero_wall.php';
if (basename($_SERVER['PHP_SELF'] ?? '') === 'index.php') {
echo gc_hero_wall_render();
}
?>
<div class="portal<?= $PUBLIC_SIDEBAR ? '' : ' public' ?>">
<div class="topbar">
<div class="brand">
<div class="logoX">X</div>
<div class="textblock">
<div class="title">TREAM<span class="ui">ui</span></div>
<div class="subtitle">GAME CHANGER</div>
</div>
</div>
<div class="topnav">
<a class="<?= _gc_active('index.php') ?>" href="/index.php">Home</a>
<a class="<?= _gc_active('plans.php') ?>" href="/plans.php">Plans</a>
<?php if ($user): ?>
<a href="/portal/">Portal</a>
<a class="<?= _gc_active('dashboard.php') ?>" href="/dashboard.php">My Account</a>
<?php else: ?>
<a class="<?= _gc_active('login.php') ?>" href="/login.php">Login</a>
<?php endif; ?>
</div>
<div class="userbox">
<div class="avatar<?= $user ? '' : ' guest' ?>">
<?php if ($avatarUrl): ?>
<img src="<?= e($avatarUrl) ?>" alt="Avatar">
<?php elseif (!$user): ?>
<img src="/portal/assets/guest.svg" alt="Guest">
<?php else: ?>
<img src="/default-avatar.png" alt="Default Avatar">
<?php endif; ?>
</div>
<div>
<div class="name"><?= e($displayName) ?></div>
<div style="margin-top:2px;">
<?php if ($user): ?>
<a href="/logout.php">Logout</a>
<?php else: ?>
<a href="/register.php">Register</a>
<?php endif; ?>
</div>
</div>
</div>
</div>
<?php if ($PUBLIC_SIDEBAR): ?>
<div class="sidebar">
<div class="sidegroup">
<div class="label">Browse</div>
<a class="sideitem" href="/portal/"><span class="icon"><?= gc_svg_icon('home') ?></span>Portal Home</a>
<a class="sideitem" href="/portal/live/"><span class="icon"><?= gc_svg_icon('tv') ?></span>Live TV</a>
<a class="sideitem" href="/portal/movies/"><span class="icon"><?= gc_svg_icon('movies') ?></span>Movies</a>
<a class="sideitem" href="/portal/series/"><span class="icon"><?= gc_svg_icon('series') ?></span>Series</a>
</div>
<div class="sidegroup">
<div class="label">Account</div>
<a class="sideitem active" href="/dashboard.php"><span class="icon"><?= gc_svg_icon('user') ?></span>My Account</a>
</div>
</div>
<?php endif; ?>
<div class="main">
<div class="container">
<?php flash_show(); ?>