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 /public | |
| parent | ff7178fd42240cb1ad012c6afd11f40020963f53 (diff) | |
feat: display default avatar if user doesn't have one
Diffstat (limited to 'public')
| -rw-r--r-- | public/account/index.php | 18 | ||||
| -rw-r--r-- | public/users.php | 39 |
2 files changed, 44 insertions, 13 deletions
diff --git a/public/account/index.php b/public/account/index.php index 8ecce33..5455727 100644 --- a/public/account/index.php +++ b/public/account/index.php @@ -88,13 +88,23 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { <form action="/account" method="POST" enctype="multipart/form-data"> <h2>Profile</h2> <h3>Profile picture</h3> - <img src="/static/userdata/avatars/<?php echo $_SESSION["user_id"] ?>" id="pfp" width="64" - height="64"> + <?php + if (is_file("../static/userdata/avatars/" . $_SESSION["user_id"])) { + echo '<img src="/static/userdata/avatars/' . $_SESSION["user_id"] . '" id="pfp" width="64" height="64">'; + } else { + echo "<p>You don't have profile picture</p>"; + } + ?> <input type="file" name="pfp"> <h3>Profile banner</h3> - <img src="/static/userdata/banners/<?php echo $_SESSION["user_id"] ?>" id="banner" width="192" - height="108"> + <?php + if (is_file("../static/userdata/banners/" . $_SESSION["user_id"])) { + echo '<img src="/static/userdata/banners/' . $_SESSION["user_id"] . '" id="banner" width="192" height="108">'; + } else { + echo "<p>You don't have profile banner</p>"; + } + ?> <input type="file" name="banner"> <h3>Username</h3> diff --git a/public/users.php b/public/users.php index 933ada4..f1aa3e7 100644 --- a/public/users.php +++ b/public/users.php @@ -86,9 +86,15 @@ if ($id == "" && $alias_id == "") { $last_active = format_timestamp($diff); } - echo '<tr>'; - echo '<td><img src="/static/userdata/avatars/' . $row["id"] . '" width="24" height="24"></td>'; - echo '<td><a href="/users.php?id=' . $row["id"] . '">' . $row["username"] . '</a></td>'; + echo '<tr><td>'; + echo '<img src="/static/'; + if (is_file("static/userdata/avatars/" . $row["id"])) { + echo 'userdata/avatars/' . $row["id"]; + } else { + echo 'img/defaults/profile_picture.png'; + } + echo '" width="24" height="24">'; + echo '</td><td><a href="/users.php?id=' . $row["id"] . '">' . $row["username"] . '</a></td>'; echo "<td>$last_active ago</td>"; echo '</tr>'; } @@ -322,13 +328,28 @@ if ($is_json) { <section class="user-bar column small-gap"> <section class="box"> <div class="box navtab"> - <p>User #<?php echo $user->id() ?></p> - </div> - <div class="box content background" - style="background-image: url('/static/userdata/banners/<?php echo $user->id() ?>');"> - <img src="/static/userdata/avatars/<?php echo $user->id() ?>" width="96" height="96"> - <h1><?php echo $user->username() ?></h1> + <p>User</p> </div> + <?php + echo '<div class="box content background"'; + + if (is_file("static/userdata/banners/" . $user->id())) { + echo ' style="background-image: url(\'/static/userdata/banners/' . $user->id() . '\');">'; + } else { + echo '>'; + } + + echo '<img src="/static/'; + if (is_file("static/userdata/avatars/" . $user->id())) { + echo 'userdata/avatars/' . $user->id(); + } else { + echo 'img/defaults/profile_picture.png'; + } + echo '" width="96" height="96">'; + echo '<h1>' . $user->username() . '</h1>'; + + echo '</div>'; + ?> </section> <!-- STATS --> |
