diff options
| author | ilotterytea <iltsu@alright.party> | 2025-05-07 14:42:30 +0500 |
|---|---|---|
| committer | ilotterytea <iltsu@alright.party> | 2025-05-07 14:42:30 +0500 |
| commit | d857bf78c0f8639eae9e21ffe4e04ee68e94d04b (patch) | |
| tree | 2cecbfa99e3ac428d7e4537a14bda0682dee3e5d /src | |
| parent | ff7178fd42240cb1ad012c6afd11f40020963f53 (diff) | |
feat: display default avatar if user doesn't have one
Diffstat (limited to 'src')
| -rw-r--r-- | src/partials.php | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/partials.php b/src/partials.php index 07f2636..38e63bb 100644 --- a/src/partials.php +++ b/src/partials.php @@ -72,12 +72,18 @@ function html_navigation_bar() </div> <?php if (isset($_SESSION["user_id"])) { - echo '' ?> - <a href="/users.php?id=<?php echo $_SESSION["user_id"] ?>" class="links" style="margin-left:auto;"> - Signed in as <?php echo $_SESSION["user_name"] ?> <img - src="/static/userdata/avatars/<?php echo $_SESSION["user_id"] ?>" width="24" height="24" /> - </a> - <?php ; + echo '<a href="/users.php?id=' . $_SESSION["user_id"] . '" class="links" style="margin-left:auto;">'; + echo 'Signed in as ' . $_SESSION["user_name"] . ' '; + echo '<img src="/static/'; + if ( + is_file($_SERVER['DOCUMENT_ROOT'] . "/static/userdata/avatars/" . $_SESSION["user_id"]) + ) { + echo 'userdata/avatars/' . $_SESSION["user_id"]; + } else { + echo 'img/defaults/profile_picture.png'; + } + echo '" width="24" height="24" />'; + echo '</a>'; } ?> </section> |
