Skip to content

Commit 635647d

Browse files
authored
Merge pull request #184 from Mdwiki-TD/update_new
Add cookie notification message
2 parents 9499385 + 8925a71 commit 635647d

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

src/backend/userinfos_wrap.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
include_once __DIR__ . '/../../auth/oauth/user_infos.php';
99
}
1010

11-
if (isset($GLOBALS['global_username']) && $GLOBALS['global_username'] != '') {
11+
if (!empty($GLOBALS['global_username'])) {
1212
$global_username = $GLOBALS['global_username'];
1313
} else {
1414
$GLOBALS['global_username'] = '';

src/footer.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,28 @@
11
<?php
22

3+
if (!empty($GLOBALS['global_username'])) {
4+
5+
if (!isset($_COOKIE['cookie_alert_dismissed1'])) {
6+
echo <<<HTML
7+
<div id="cookie-alert" class="alert alert-dismissible fade show" role="alert">
8+
<div class="d-flex align-items-center justify-content-center text-center fixed-bottom">
9+
<div class="card border-warning m-1">
10+
<div class="w-100 d-flex justify-content-end">
11+
<button type="button" class="btn btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
12+
</div>
13+
<div class="card-body me-5">
14+
<p class="card-text">This website uses cookies to save your username for a better experience.</p>
15+
</div>
16+
<div class="card-footer text-muted">
17+
<button type="button" class="btn btn-sm btn-success" onclick="acceptCookieAlert()" data-bs-dismiss="alert" aria-label="Close">Accept</button>
18+
<button type="button" class="btn btn-sm btn-warning" data-bs-dismiss="alert" aria-label="Close">Dismiss</button>
19+
</div>
20+
</div>
21+
</div>
22+
</div>
23+
HTML;
24+
}
25+
}
326
if (isset($GLOBALS['time_start'])) {
427
$time_start = $GLOBALS['time_start'];
528
$time_end = microtime(true);
@@ -22,6 +45,10 @@
2245
</main>
2346
<script src="/Translation_Dashboard/js/c.js"></script>
2447
<script>
48+
function acceptCookieAlert() {
49+
document.cookie = "cookie_alert_dismissed1=true; max-age=31536000; path=/; Secure; SameSite=Lax";
50+
}
51+
2552
function copy_target_text(id) {
2653
let textarea = document.getElementById(id);
2754
textarea.select();

src/header.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
</li>
4747
HTML;
4848
//---
49-
if (isset($GLOBALS['global_username']) && $GLOBALS['global_username'] != '') {
49+
if (!empty($GLOBALS['global_username'])) {
5050
$u_name = $GLOBALS['global_username'];
5151
$li_user = <<<HTML
5252
<li class="nav-item col-6 col-lg-auto">

0 commit comments

Comments
 (0)