diff options
Diffstat (limited to 'public')
| -rw-r--r-- | public/account/index.php | 24 | ||||
| -rw-r--r-- | public/account/login/twitch.php | 19 | ||||
| -rw-r--r-- | public/static/style.css | 12 | ||||
| -rw-r--r-- | public/users.php | 3 |
4 files changed, 54 insertions, 4 deletions
diff --git a/public/account/index.php b/public/account/index.php index 2edb39a..a216eea 100644 --- a/public/account/index.php +++ b/public/account/index.php @@ -16,7 +16,7 @@ if (!isset($_SESSION["user_id"], $_SESSION["user_name"])) { if ($_SERVER['REQUEST_METHOD'] == "POST") { $db = new PDO(DB_URL, DB_USER, DB_PASS); - $username = str_safe($_POST["username"], ACCOUNT_USERNAME_MAX_LENGTH); + $username = str_safe($_POST["username"] ?? "", ACCOUNT_USERNAME_MAX_LENGTH); if (!empty($username) && $username != $_SESSION["user_name"]) { if (!preg_match(ACCOUNT_USERNAME_REGEX, $username)) { @@ -43,7 +43,20 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { "../static/userdata/avatars/" . $_SESSION["user_id"], ACCOUNT_PFP_MAX_SIZE[0], ACCOUNT_PFP_MAX_SIZE[1], - false + false, + true + ); + } + + if (isset($_FILES["banner"])) { + $banner = $_FILES["banner"]; + resize_image( + $banner["tmp_name"], + "../static/userdata/banners/" . $_SESSION["user_id"], + ACCOUNT_BANNER_MAX_SIZE[0], + ACCOUNT_BANNER_MAX_SIZE[1], + false, + true ); } @@ -76,7 +89,12 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { <h3>Profile picture</h3> <img src="/static/userdata/avatars/<?php echo $_SESSION["user_id"] ?>" id="pfp" width="64" height="64"> - <input type="file" name="pfp" id="pfp"> + <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"> + <input type="file" name="banner"> <h3>Username</h3> <input type="text" name="username" id="username" value="<?php echo $_SESSION["user_name"] ?>"> diff --git a/public/account/login/twitch.php b/public/account/login/twitch.php index ec10583..1c72bc3 100644 --- a/public/account/login/twitch.php +++ b/public/account/login/twitch.php @@ -139,4 +139,23 @@ if (!is_file("$path/$user_id")) { fclose($fp); } +// downloading profile banner +$path = "../../static/userdata/banners"; + +if (!is_dir($path)) { + mkdir($path, 0777, true); +} + +if (!is_file("$path/$user_id")) { + $fp = fopen("$path/$user_id", "wb"); + $request = curl_init(); + curl_setopt($request, CURLOPT_URL, $twitch_user["offline_image_url"]); + curl_setopt($request, CURLOPT_FILE, $fp); + curl_setopt($request, CURLOPT_HEADER, 0); + + curl_exec($request); + curl_close($request); + fclose($fp); +} + header("Location: /account");
\ No newline at end of file diff --git a/public/static/style.css b/public/static/style.css index ae4574f..58eabdc 100644 --- a/public/static/style.css +++ b/public/static/style.css @@ -316,6 +316,18 @@ button.purple:hover, overflow: hidden; } +.box.background { + background-size: 100% 100%; + background-position: center; + background-repeat: no-repeat; + overflow: hidden; +} + +.box.background h1 { + color: white; + text-shadow: -1px 1px 4px black; +} + .box.emote:has(p) h1 { margin-top: 4px; line-height: 0; diff --git a/public/users.php b/public/users.php index de9bfc8..123d37f 100644 --- a/public/users.php +++ b/public/users.php @@ -299,7 +299,8 @@ if ($is_json) { <div class="box navtab"> <p>User #<?php echo $user->id() ?></p> </div> - <div class="box content"> + <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> </div> |
