From b336e659098749f90d4ab9e708df9eea748ffbfa Mon Sep 17 00:00:00 2001 From: flashwave Date: Sun, 3 May 2015 21:43:25 +0000 Subject: [PATCH] Profile backgrounds --- _sakura/changelog.json | 12 +++++++- _sakura/sakura.php | 2 +- _sakura/templates/yuuno/global/header.tpl | 13 ++++++++- _sakura/templates/yuuno/main/profile.tpl | 2 +- main/imageserve.php | 35 +++++++++++++++++------ main/profile.php | 13 +++++++-- 6 files changed, 63 insertions(+), 14 deletions(-) diff --git a/_sakura/changelog.json b/_sakura/changelog.json index 395e1c1..ded72df 100644 --- a/_sakura/changelog.json +++ b/_sakura/changelog.json @@ -22,7 +22,8 @@ "20150430", "20150501", "20150502", - "20150503" + "20150503", + "20150503.1" ] @@ -880,6 +881,15 @@ "change": "Begin work on forum script." } + ], + + "20150503.1": [ + + { + "type": "ADD", + "change": "Added profile backgrounds." + } + ] } diff --git a/_sakura/sakura.php b/_sakura/sakura.php index af55c40..76a9fdf 100644 --- a/_sakura/sakura.php +++ b/_sakura/sakura.php @@ -8,7 +8,7 @@ namespace Sakura; // Define Sakura version -define('SAKURA_VERSION', '20150503'); +define('SAKURA_VERSION', '20150503.1'); define('SAKURA_VLABEL', 'Heliotrope'); define('SAKURA_VTYPE', 'Development'); define('SAKURA_COLOUR', '#DF73FF'); diff --git a/_sakura/templates/yuuno/global/header.tpl b/_sakura/templates/yuuno/global/header.tpl index 45e40b3..1531cd3 100644 --- a/_sakura/templates/yuuno/global/header.tpl +++ b/_sakura/templates/yuuno/global/header.tpl @@ -14,6 +14,17 @@ + {% if page.style %} + + {% endif %} - +
{% else %} -
+
{{ profile.user.username }}'s Avatar diff --git a/main/imageserve.php b/main/imageserve.php index bb9ab9f..4173348 100644 --- a/main/imageserve.php +++ b/main/imageserve.php @@ -14,9 +14,11 @@ header('Content-Type: application/octet-stream'); // Check if the m(ode) GET request is set if(isset($_GET['m'])) { + switch($_GET['m']) { + case 'avatar': - // Set path to no avatar picture + // Set paths $noAvatar = ROOT .'content/images/no-av.png'; $deactiveAvatar = ROOT .'content/images/deactivated-av.png'; $bannedAvatar = ROOT .'content/images/banned-av.png'; @@ -52,10 +54,11 @@ if(isset($_GET['m'])) { // Check if the avatar exist and assign it to a value $serveImage = $avatarDirPath . $user['avatar_url']; break; - + case 'background': - // Set path to no avatar picture - $noBackground = ROOT .'content/pixel.png'; + // Set paths + $noBackground = ROOT .'content/pixel.png'; + $bgDirPath = ROOT .'content/images/backgrounds/'; // If ?u= isn't set or if it isn't numeric if(!isset($_GET['u']) || !is_numeric($_GET['u'])) { @@ -63,16 +66,32 @@ if(isset($_GET['m'])) { break; } + // Get user data + $user = Users::getUser($_GET['u']); + + // If user is deactivated don't display background + if(Users::checkIfUserHasRanks([0, 1], $user, true)) { + $serveImage = $noBackground; + break; + } + + // Check if user has an avatar set + if(empty($user['background_url']) || !file_exists($bgDirPath . $user['background_url'])) { + $serveImage = $noAvatar; + break; + } + // Check if the avatar exist and assign it to a value - $serveImage = empty(Users::getUser($_GET['u'])['profilebg']) ? $noBackground : Users::getUser($_GET['u'])['profilebg']; + $serveImage = $bgDirPath . $user['background_url']; break; - + default: $serveImage = ROOT .'content/pixel.png'; + } -} else { + +} else $serveImage = ROOT .'content/pixel.png'; -} $serveImage = file_get_contents($serveImage); diff --git a/main/profile.php b/main/profile.php index d7c3458..9d705a4 100644 --- a/main/profile.php +++ b/main/profile.php @@ -36,8 +36,17 @@ if(isset($_GET['u'])) { 'profpage' => Main::mdParse(base64_decode($_PROFILE_USER_DATA['profile_md'])), 'data' => Users::getUserProfileData($_PROFILE_USER_DATA['id']) ]; - - $renderData['page']['title'] = ($_PROFILE_USER_DATA['id'] < 1 || $_PROFILE_USER_DATA['password_algo'] == 'nologin' ? 'User not found!' : 'Profile of '. $renderData['profile']['user']['username']); + $renderData['page'] = [ + 'title' => ($_PROFILE_USER_DATA['id'] < 1 || $_PROFILE_USER_DATA['password_algo'] == 'nologin' ? 'User not found!' : 'Profile of '. $_PROFILE_USER_DATA['username']), + 'style' => ($_PROFILE_USER_DATA['background_url'] ? [ + 'body' => [ + 'background' => 'url("/bg/'. $_PROFILE_USER_DATA['id'] .'") no-repeat fixed center center / cover transparent !important' + ], + '.profile' => [ + 'background' => 'rgba(211, 191, 255, .8) !important' + ] + ] : null) + ]; } else {