Profile backgrounds

This commit is contained in:
Pachira 2015-05-03 21:43:25 +00:00
parent ff488c6b84
commit b336e65909
6 changed files with 63 additions and 14 deletions

View file

@ -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."
}
]
}

View file

@ -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');

View file

@ -14,6 +14,17 @@
<link rel="stylesheet" type="text/css" href="//{{ sakura.urls.content }}/global.css" />
<link rel="stylesheet" type="text/css" href="{{ sakura.resources }}/css/yuuno.css" />
<link rel="stylesheet" type="text/css" href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" />
{% if page.style %}
<style type="text/css">
{% for element,properties in page.style %}
{{ element|raw }} {
{% for property,value in properties %}
{{ property|raw }}: {{ value|raw }};
{% endfor %}
}
{% endfor %}
</style>
{% endif %}
<!-- JS -->
<script type="text/javascript" src="{{ sakura.resources }}/js/yuuno.js"></script>
<script type="text/javascript">
@ -108,7 +119,7 @@
};
</script>
</head>
<body>
<body{% if page.background %} style="background: url('{{ page.background }}') no-repeat fixed center center / cover inherit !important;"{% endif %}>
<div id="container">
<span id="top"></span>
<div class="header" id="header">

View file

@ -11,7 +11,7 @@
</ul>
</div>
{% else %}
<div class="content profile">
<div class="content profile"{% if page.background %} style="background: rgba(211, 191, 255, .8) !important;"{% endif %}>
<div class="{% if profile.profpage|length > 1 %}content-right {% endif %}content-column">
<div style="text-align: center;">
<img src="/a/{{ profile.user.id }}" alt="{{ profile.user.username }}'s Avatar" class="default-avatar-setting" style="box-shadow: 0 3px 7px #{% if profile.online %}484{% else %}844{% endif %};" />

View file

@ -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);

View file

@ -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 {