diff options
| -rw-r--r-- | public/account/index.php | 18 | ||||
| -rw-r--r-- | public/users.php | 39 | ||||
| -rw-r--r-- | src/partials.php | 18 |
3 files changed, 56 insertions, 19 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 --> 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> |
