welcome to osu!

This commit is contained in:
Pachira 2015-08-19 21:44:01 +02:00
parent 437e3c1039
commit b041779ebb
15 changed files with 115 additions and 83 deletions

View file

@ -2061,6 +2061,31 @@
"type": "UPD", "type": "UPD",
"change": "Converted profile.php to the new user API.", "change": "Converted profile.php to the new user API.",
"user": "Flashwave" "user": "Flashwave"
},
{
"type": "ADD",
"change": "Added OR statement capabilities to the database library.",
"user": "Flashwave"
},
{
"type": "UPD",
"change": "Make it possible to initialise a User object with the username_clean of that user.",
"user": "Flashwave"
},
{
"type": "UPD",
"change": "Switched currently logged in user data to the new API and fixed some references to checkLogin.",
"user": "Flashwave"
},
{
"type": "ADD",
"change": "Added expirimental site wide profile background feature.",
"user": "Flashwave"
},
{
"type": "FIX",
"change": "Clean up unneeded things from profile.php.",
"user": "Flashwave"
} }
] ]

View file

@ -16,7 +16,7 @@ class User {
function __construct($id) { function __construct($id) {
// Get the user database row // Get the user database row
$this->data = Database::fetch('users', false, ['id' => [$id, '=']]); $this->data = Database::fetch('users', false, ['id' => [$id, '=', true], 'username_clean' => [$id, '=']]);
// Check if the user actually exists // Check if the user actually exists
if(empty($this->data)) { if(empty($this->data)) {

View file

@ -94,7 +94,7 @@ class MySQL {
$prepare .= ' WHERE'; $prepare .= ' WHERE';
foreach($data as $key => $value) { foreach($data as $key => $value) {
$prepare .= ' `'. $key .'` '. $value[1] .' :'. $key . ($key == key(array_slice($data, -1, 1, true)) ? '' : ' AND'); $prepare .= ' `'. $key .'` '. $value[1] .' :'. $key . ($key == key(array_slice($data, -1, 1, true)) ? '' : ' '. (isset($value[2]) && $value[2] ? 'OR' : 'AND'));
// Unset variables to be safe // Unset variables to be safe
unset($key); unset($key);
@ -223,7 +223,7 @@ class MySQL {
// Do this complicated shit, I barely know what's going on anymore but it works // Do this complicated shit, I barely know what's going on anymore but it works
foreach($values as $column => $column_data) foreach($values as $column => $column_data)
$prepare .= ' `'. $column .'` '. ($key ? $column_data[1] : '=') .' :'. ($key ? 'w' : 's') .'_'. $column . ($column == key(array_slice($values, -1, 1, true)) ? ($key ? ';' : '') : ($key ? ' AND' : ',')); $prepare .= ' `'. $column .'` '. ($key ? $column_data[1] : '=') .' :'. ($key ? 'w' : 's') .'_'. $column . ($column == key(array_slice($values, -1, 1, true)) ? ($key ? ';' : '') : ($key ? ' '. (isset($value[2]) && $value[2] ? 'OR' : 'AND') : ','));
} }
@ -279,7 +279,7 @@ class MySQL {
$prepare .= ' WHERE'; $prepare .= ' WHERE';
foreach($data as $key => $value) { foreach($data as $key => $value) {
$prepare .= ' `'. $key .'` '. $value[1] .' :'. $key . ($key == key(array_slice($data, -1, 1, true)) ? '' : ' AND'); $prepare .= ' `'. $key .'` '. $value[1] .' :'. $key . ($key == key(array_slice($data, -1, 1, true)) ? '' : ' '. (isset($value[2]) && $value[2] ? 'OR' : 'AND'));
// Unset variables to be safe // Unset variables to be safe
unset($key); unset($key);
@ -320,7 +320,7 @@ class MySQL {
$prepare .= ' WHERE'; $prepare .= ' WHERE';
foreach($data as $key => $value) { foreach($data as $key => $value) {
$prepare .= ' `'. $key .'` '. $value[1] .' :'. $key . ($key == key(array_slice($data, -1, 1, true)) ? '' : ' AND'); $prepare .= ' `'. $key .'` '. $value[1] .' :'. $key . ($key == key(array_slice($data, -1, 1, true)) ? '' : ' '. (isset($value[2]) && $value[2] ? 'OR' : 'AND'));
// Unset variables to be safe // Unset variables to be safe
unset($key); unset($key);

View file

@ -111,15 +111,15 @@ if(!defined('SAKURA_NO_TPL')) {
], ],
'user' => [ 'session' => [
'checklogin' => Users::checkLogin(), 'checkLogin' => Users::checkLogin(),
'session' => Session::$sessionId, 'sessionId' => Session::$sessionId,
'data' => ($_init_udata = Users::getUser(Session::$userId)), 'userId' => Session::$userId
'rank' => ($_init_rdata = Users::getRank($_init_udata['rank_main'])),
'colour' => ($_init_udata['name_colour'] == null ? $_init_rdata['colour'] : $_init_udata['name_colour'])
] ],
'user' => new User(Session::$userId)
]; ];

View file

@ -1,4 +1,4 @@
{% if user.checklogin %} {% if session.checkLogin %}
<div class="head">Hi, {{ user.data.username }}!</div> <div class="head">Hi, {{ user.data.username }}!</div>
<a href="/settings/avatar"><img src="/a/{{ user.data.id }}" class="default-avatar-setting homepage-menu-avatar" /></a> <a href="/settings/avatar"><img src="/a/{{ user.data.id }}" class="default-avatar-setting homepage-menu-avatar" /></a>
<ul class="panelQuickLinks"> <ul class="panelQuickLinks">
@ -23,8 +23,8 @@
{% endif %} {% endif %}
{% endif %} {% endif %}
<div class="head">Stats</div> <div class="head">Stats</div>
We have <b>{{ stats.userCount }}</b>, We have <b>{{ stats.userCount }}</b>,
<b><a href="/u/{{ stats.newestUser.id }}" class="default">{{ stats.newestUser.username }}</a></b> is the newest user, <b><a href="/u/{{ stats.newestUser.id }}" class="default">{{ stats.newestUser.username }}</a></b> is the newest user,
it has been <b>{{ stats.lastRegDate }}</b> since the last user registered and the forum has <b>{{ stats.topicCount }}</b> and <b>{{ stats.postCount }}</b>. it has been <b>{{ stats.lastRegDate }}</b> since the last user registered and the forum has <b>{{ stats.topicCount }}</b> and <b>{{ stats.postCount }}</b>.
<div class="head">Online Users</div> <div class="head">Online Users</div>
{% if stats.onlineUsers %} {% if stats.onlineUsers %}

View file

@ -15,7 +15,7 @@
<div class="userdata"> <div class="userdata">
<div class="usertitle">{% if not post.user.usertitle %}{{ post.rank.title }}{% else %}{{ post.user.usertitle }}{% endif %}</div> <div class="usertitle">{% if not post.user.usertitle %}{{ post.rank.title }}{% else %}{{ post.user.usertitle }}{% endif %}</div>
<img src="{{ sakura.content_path }}/images/tenshi.png" alt="Tenshi"{% if not post.is_premium %} style="opacity: 0;"{% endif %} /> <img src="{{ sakura.content_path }}/images/flags/{% if post.user.country|lower == 'eu' %}europeanunion{% else %}{{ post.user.country|lower }}{% endif %}.png" alt="{{ post.country }}" /> <img src="{{ sakura.content_path }}/images/tenshi.png" alt="Tenshi"{% if not post.is_premium %} style="opacity: 0;"{% endif %} /> <img src="{{ sakura.content_path }}/images/flags/{% if post.user.country|lower == 'eu' %}europeanunion{% else %}{{ post.user.country|lower }}{% endif %}.png" alt="{{ post.country }}" />
{% if user.checklogin %} {% if session.checkLogin %}
<div class="actions"> <div class="actions">
{% if user.data.id == post.user.id %} {% if user.data.id == post.user.id %}
<a class="fa fa-pencil-square-o" title="Edit this post" href="/forum/post/{{ post.post_id }}/edit"></a> <a class="fa fa-pencil-square-o" title="Edit this post" href="/forum/post/{{ post.post_id }}/edit"></a>

View file

@ -62,7 +62,7 @@
"minUserLen": {{ sakura.minusernamelength }}, "minUserLen": {{ sakura.minusernamelength }},
"maxUserLen": {{ sakura.maxusernamelength }}, "maxUserLen": {{ sakura.maxusernamelength }},
"minPwdEntropy": {{ sakura.minpwdentropy }}, "minPwdEntropy": {{ sakura.minpwdentropy }},
"checklogin": {% if user.checklogin %}true{% else %}false{% endif %} "checklogin": {% if session.checkLogin %}true{% else %}false{% endif %}
}; };
@ -74,7 +74,7 @@
gotop.setAttribute('href', 'javascript:void(0);'); gotop.setAttribute('href', 'javascript:void(0);');
gotop.setAttribute('onclick', 'scrollToTop();'); gotop.setAttribute('onclick', 'scrollToTop();');
{% if user.checklogin %} {% if session.checkLogin %}
// Convert href to object in logout link // Convert href to object in logout link
prepareAjaxLink('headerLogoutLink', 'submitPost', ', true, "Logging out..."'); prepareAjaxLink('headerLogoutLink', 'submitPost', ', true, "Logging out..."');
{% elseif not sakura.lockauth and php.self != '/authenticate.php' %} {% elseif not sakura.lockauth and php.self != '/authenticate.php' %}
@ -87,12 +87,12 @@
createInput.setAttribute('value', 'true'); createInput.setAttribute('value', 'true');
createInput.setAttribute('type', 'hidden'); createInput.setAttribute('type', 'hidden');
headerLoginForm.appendChild(createInput); headerLoginForm.appendChild(createInput);
submit.setAttribute('type', 'button'); submit.setAttribute('type', 'button');
submit.setAttribute('onclick', 'submitPost(\''+ headerLoginForm.action +'\', formToObject(\'headerLoginForm\'), true, \'Logging in...\');'); submit.setAttribute('onclick', 'submitPost(\''+ headerLoginForm.action +'\', formToObject(\'headerLoginForm\'), true, \'Logging in...\');');
{% endif %} {% endif %}
{% if user.checklogin %} {% if session.checkLogin %}
// Make notification requests (there's a seperate one to make it happen before the first 60 seconds) // Make notification requests (there's a seperate one to make it happen before the first 60 seconds)
notifyRequest('{{ php.sessionid }}'); notifyRequest('{{ php.sessionid }}');
@ -102,12 +102,12 @@
}, 60000); }, 60000);
{% endif %} {% endif %}
{% if php.self == '/profile.php' and user.checklogin and user.data.id != profile.user.id %} {% if php.self == '/profile.php' and session.checkLogin and user.data.id != profile.user.id %}
// Make friend button dynamic // Make friend button dynamic
prepareAjaxLink('profileFriendToggle', 'submitPost', ', true, "{% if profile.friend == 0 %}Adding{% else %}Removing{% endif %} friend..."'); prepareAjaxLink('profileFriendToggle', 'submitPost', ', true, "{% if profile.friend == 0 %}Adding{% else %}Removing{% endif %} friend..."');
{% endif %} {% endif %}
{% if php.self == '/viewtopic.php' and user.checklogin %} {% if php.self == '/viewtopic.php' and session.checkLogin %}
var forumFriendToggles = document.querySelectorAll('.forum-friend-toggle'); var forumFriendToggles = document.querySelectorAll('.forum-friend-toggle');
for(var i in forumFriendToggles) { for(var i in forumFriendToggles) {
@ -146,6 +146,10 @@
} }
{% endif %} {% endif %}
{% if php.self == '/profile.php' ? profile.data.userData.profileBackground is defined : (user.checkPremium[0] and user.data.userData.profileBackgroundSiteWide and user.data.userData.profileBackground is defined) %}
initialiseParallax('userBackground');
{% endif %}
}); });
</script> </script>
</head> </head>
@ -162,14 +166,14 @@
<a class="menu-item" href="//chat.{{ sakura.url_main }}/" title="Chat with other Flashii members">Chat</a> <a class="menu-item" href="//chat.{{ sakura.url_main }}/" title="Chat with other Flashii members">Chat</a>
<a class="menu-item" href="/forum" title="Discuss things with other members but static">Forums</a> <a class="menu-item" href="/forum" title="Discuss things with other members but static">Forums</a>
<a class="menu-item" href="/search" title="Search on Flashii">Search</a> <a class="menu-item" href="/search" title="Search on Flashii">Search</a>
{% if user.checklogin %} {% if session.checkLogin %}
<a class="menu-item" href="/members" title="View a list with all the activated user accounts">Members</a> <a class="menu-item" href="/members" title="View a list with all the activated user accounts">Members</a>
<a class="menu-item menu-donate" href="/support" title="Give us money to keep the site (and other services) up and running">Support us</a> <a class="menu-item menu-donate" href="/support" title="Give us money to keep the site (and other services) up and running">Support us</a>
{% endif %} {% endif %}
</div> </div>
<div class="menu-ucp" id="navMenuUser"> <div class="menu-ucp" id="navMenuUser">
<!-- User menu, displayed on right side of the bar. --> <!-- User menu, displayed on right side of the bar. -->
{% if user.checklogin %} {% if session.checkLogin %}
<a class="menu-item avatar" href="/u/{{ user.data.id }}" title="View and edit your own profile" style="background-image: url('/a/{{ user.data.id }}'); width: auto; color: {{ user.colour }}; font-weight: 700;">{{ user.data.username }}</a> <a class="menu-item avatar" href="/u/{{ user.data.id }}" title="View and edit your own profile" style="background-image: url('/a/{{ user.data.id }}'); width: auto; color: {{ user.colour }}; font-weight: 700;">{{ user.data.username }}</a>
<a class="menu-item" href="/messages" title="Read your private message">Messages</a> <a class="menu-item" href="/messages" title="Read your private message">Messages</a>
<a class="menu-item" href="/manage" title="Manage the site">Manage</a> <a class="menu-item" href="/manage" title="Manage the site">Manage</a>
@ -191,7 +195,10 @@
</div> </div>
<div id="contentwrapper"> <div id="contentwrapper">
<div id="notifications"></div> <div id="notifications"></div>
{% if not user.checklogin and php.self != '/authenticate.php' %} {% if php.self == '/profile.php' ? profile.data.userData.profileBackground is defined : (user.checkPremium[0] and user.data.userData.profileBackgroundSiteWide and user.data.userData.profileBackground is defined) %}
<div id="userBackground" style="background-image: url('/bg/{{ (php.self == '/profile.php' ? profile : user).data.id }}');"></div>
{% endif %}
{% if not session.checkLogin and php.self != '/authenticate.php' %}
<form method="post" action="/authenticate" id="headerLoginForm" onkeydown="formEnterCatch(event, 'headerLoginButton');"> <form method="post" action="/authenticate" id="headerLoginForm" onkeydown="formEnterCatch(event, 'headerLoginButton');">
<input type="hidden" name="redirect" value="{{ sakura.currentpage }}" /> <input type="hidden" name="redirect" value="{{ sakura.currentpage }}" />
<input type="hidden" name="session" value="{{ php.sessionid }}" /> <input type="hidden" name="session" value="{{ php.sessionid }}" />

View file

@ -1,5 +1,5 @@
{% include 'global/header.tpl' %} {% include 'global/header.tpl' %}
{% if user.checklogin %} {% if session.checkLogin %}
<div class="membersPage" style="min-height: 500px;"> <div class="membersPage" style="min-height: 500px;">
<h1 style="text-shadow: 0px 0px 5px #555;{% if page.active %} color: {{ page.ranks[page.active].colour }};{% endif %}">{% if not page.active %}All members{% else %}{{ page.ranks[page.active].name }}{% if page.ranks[page.active].multi %}s{% endif %}{% endif %}</h1> <h1 style="text-shadow: 0px 0px 5px #555;{% if page.active %} color: {{ page.ranks[page.active].colour }};{% endif %}">{% if not page.active %}All members{% else %}{{ page.ranks[page.active].name }}{% if page.ranks[page.active].multi %}s{% endif %}{% endif %}</h1>
<h3 style="padding: 0px 0px 10px;">{% if not page.active %}The entire user list.{% else %}{{ page.ranks[page.active].description }}{% endif %}</h3> <h3 style="padding: 0px 0px 10px;">{% if not page.active %}The entire user list.{% else %}{{ page.ranks[page.active].description }}{% endif %}</h3>

View file

@ -1,5 +1,5 @@
{% include 'global/header.tpl' %} {% include 'global/header.tpl' %}
{% if page.notfound or profile.data.id < 1 or profile.data.password_algo == 'nologin' %} {% if profile.data.id < 1 or profile.data.password_algo == 'nologin' %}
<div class="content standalone" style="padding: 20px;"> <div class="content standalone" style="padding: 20px;">
<h1>The requested user does not exist!</h1> <h1>The requested user does not exist!</h1>
There are a few possible reasons for this: There are a few possible reasons for this:
@ -11,7 +11,6 @@
</ul> </ul>
</div> </div>
{% else %} {% else %}
<div id="userBackground"></div>
<div class="content profile"> <div class="content profile">
<div class="{% if profile.userPage|length > 1 %}content-right {% endif %}content-column"> <div class="{% if profile.userPage|length > 1 %}content-right {% endif %}content-column">
<div style="text-align: center;"> <div style="text-align: center;">
@ -20,7 +19,7 @@
<span style="font-size: .8em;">{{ profile.userTitle }}</span> <span style="font-size: .8em;">{{ profile.userTitle }}</span>
<h1 style="color: {{ profile.colour }}; text-shadow: 0 0 7px {% if profile.colour != 'inherit' %}{{ profile.colour }}{% else %}#222{% endif %}; padding: 0 0 2px;">{{ profile.data.username }}</h1> <h1 style="color: {{ profile.colour }}; text-shadow: 0 0 7px {% if profile.colour != 'inherit' %}{{ profile.colour }}{% else %}#222{% endif %}; padding: 0 0 2px;">{{ profile.data.username }}</h1>
{% if profile.checkPremium[0] %}<img src="{{ sakura.content_path }}/images/tenshi.png" alt="Tenshi" /> {% endif %}<img src="{{ sakura.content_path }}/images/flags/{% if profile.country.short|lower == 'eu' %}europeanunion{% else %}{{ profile.country.short|lower }}{% endif %}.png" alt="{{ profile.country.short }}" /> <span style="font-size: .9em; line-height: 11px;">{{ profile.country.long }}</span> {% if profile.checkPremium[0] %}<img src="{{ sakura.content_path }}/images/tenshi.png" alt="Tenshi" /> {% endif %}<img src="{{ sakura.content_path }}/images/flags/{% if profile.country.short|lower == 'eu' %}europeanunion{% else %}{{ profile.country.short|lower }}{% endif %}.png" alt="{{ profile.country.short }}" /> <span style="font-size: .9em; line-height: 11px;">{{ profile.country.long }}</span>
{% if user.checklogin %} {% if session.checkLogin %}
<div class="user-actions"> <div class="user-actions">
{% if user.data.id == profile.data.id %} {% if user.data.id == profile.data.id %}
<a class="fa fa-pencil-square-o" title="Edit your profile" href="/settings/profile"></a> <a class="fa fa-pencil-square-o" title="Edit your profile" href="/settings/profile"></a>
@ -43,7 +42,7 @@
<b>{{ profile.data.username }} has {% if not profile.forumStats.posts %}no{% else %}{{ profile.forumStats.posts }}{% endif %} forum post{% if profile.forumStats.posts != 1 %}s{% endif %}.</b> <b>{{ profile.data.username }} has {% if not profile.forumStats.posts %}no{% else %}{{ profile.forumStats.posts }}{% endif %} forum post{% if profile.forumStats.posts != 1 %}s{% endif %}.</b>
{% if profile.profileFields %} {% if profile.profileFields %}
<hr class="default" /> <hr class="default" />
{% if user.checklogin %} {% if session.checkLogin %}
<table style="width: 100%;"> <table style="width: 100%;">
{% for name,field in profile.profileFields %} {% for name,field in profile.profileFields %}
<tr> <tr>
@ -94,10 +93,5 @@
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
{% if profile.data.userData.profileBackground is defined %}
<script type="text/javascript">
initialiseParallax('userBackground');
</script>
{% endif %}
{% endif %} {% endif %}
{% include 'global/footer.tpl' %} {% include 'global/footer.tpl' %}

View file

@ -73,7 +73,7 @@
<div class="sectionHeader"> <div class="sectionHeader">
Payment Options Payment Options
<div style="float: right; font-size: 10px; text-align: right;"> <div style="float: right; font-size: 10px; text-align: right;">
Our transactions are handled through PayPal. Our transactions are handled through PayPal.
<div class="paymentOptions fa"> <div class="paymentOptions fa">
<div class="fa-cc-paypal"></div> <div class="fa-cc-paypal"></div>
<div class="fa-cc-visa"></div> <div class="fa-cc-visa"></div>
@ -84,7 +84,7 @@
</div> </div>
</div> </div>
</div> </div>
{% if user.checklogin and perms.canGetPremium %} {% if session.checkLogin and perms.canGetPremium %}
<div class="slider"> <div class="slider">
<input class="inputStyling" type="range" min="1" max="{{ page.amount_max }}" value="1" onchange="document.getElementById('monthsNo').value = this.value; document.getElementById('monthNoBtn').innerHTML = this.value; document.getElementById('monthsTrailingS').innerHTML = (this.value == 1 ? '' : 's'); document.getElementById('totalAmount').innerHTML = (this.value * {{ page.price }}).formatMoney(2);" /> <input class="inputStyling" type="range" min="1" max="{{ page.amount_max }}" value="1" onchange="document.getElementById('monthsNo').value = this.value; document.getElementById('monthNoBtn').innerHTML = this.value; document.getElementById('monthsTrailingS').innerHTML = (this.value == 1 ? '' : 's'); document.getElementById('totalAmount').innerHTML = (this.value * {{ page.price }}).formatMoney(2);" />
</div> </div>
@ -97,13 +97,13 @@
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>
{% elseif user.checklogin %} {% elseif session.checkLogin %}
<h1 style="text-align: center; margin: 1em auto;" class="stylised">You can't get Tenshi at the current moment!</h1> <h1 style="text-align: center; margin: 1em auto;" class="stylised">You can't get Tenshi at the current moment!</h1>
{% else %} {% else %}
<h1 style="text-align: center; margin: 1em auto;" class="stylised">You need to be logged in to get Tenshi!</h1> <h1 style="text-align: center; margin: 1em auto;" class="stylised">You need to be logged in to get Tenshi!</h1>
{% endif %} {% endif %}
</div> </div>
{% if user.checklogin and perms.canGetPremium %} {% if session.checkLogin and perms.canGetPremium %}
<form action="/support" method="post" id="purchaseForm" class="hidden"> <form action="/support" method="post" id="purchaseForm" class="hidden">
<input type="hidden" name="mode" value="purchase" /> <input type="hidden" name="mode" value="purchase" />
<input type="hidden" name="time" value="{{ php.time }}" /> <input type="hidden" name="time" value="{{ php.time }}" />

View file

@ -9,6 +9,9 @@
</div> </div>
<div> <div>
<input type="file" name="avatar" /> <input type="file" name="avatar" />
<div style="font-size: .8em;">
(Leave upload box empty to remove avatar)
</div>
</div> </div>
<div> <div>
<input type="submit" value="Submit" name="submit" class="inputStyling" /> <input type="submit" value="Submit" name="submit" class="inputStyling" />

View file

@ -9,7 +9,15 @@
</div> </div>
<div> <div>
<input type="file" name="background" /> <input type="file" name="background" />
<div style="font-size: .8em;">
(Leave upload box empty to remove background)
</div>
</div> </div>
{% if user.checkPremium[0] %}
<div style="padding: 10px;">
<input type="checkbox" name="sitewide" id="swbgbtn" /><label for="swbgbtn"> Display background sidewide when logged in</label>
</div>
{% endif %}
<div> <div>
<input type="submit" value="Submit" name="submit" class="inputStyling" /> <input type="submit" value="Submit" name="submit" class="inputStyling" />
</div> </div>

View file

@ -326,7 +326,7 @@ a#gotop.exit {
font-weight: 700; font-weight: 700;
font-size: 20px; font-size: 20px;
color: #306; color: #306;
background: linear-gradient(90deg, rgba(148,117,178,.7), rgba(148,117,178,0)) #C2AFFE; background: linear-gradient(90deg, rgba(148, 117, 178, .7), rgba(148, 117, 178, 0)) #C2AFFE;
border-radius: 2px; border-radius: 2px;
} }
@ -337,7 +337,7 @@ a#gotop.exit {
font-weight: 700; font-weight: 700;
font-size: 20px; font-size: 20px;
color: #306; color: #306;
background: linear-gradient(270deg, rgba(148,117,178,.7), rgba(148,117,178,0)) #C2AFFE; background: linear-gradient(270deg, rgba(148, 117, 178, .7), rgba(148, 117, 178, 0)) #C2AFFE;
border-radius: 2px; border-radius: 2px;
} }
@ -1120,7 +1120,7 @@ a#gotop.exit {
*/ */
.messages table { .messages table {
width: 100%; width: 100%;
border-spacing: 0; border-spacing: 0;
} }
.messages table > tbody > tr.unread { .messages table > tbody > tr.unread {
@ -1280,6 +1280,19 @@ a#gotop.exit {
} }
/*
* User Background
*/
#userBackground {
position: fixed;
top: 0;
bottom: 0;
left: 0;
right: 0;
z-index: -1;
background: no-repeat center center / cover transparent;
}
/* /*
* Settings page styling * Settings page styling
*/ */

View file

@ -9,47 +9,19 @@ namespace Sakura;
// Include components // Include components
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php'; require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php';
// Get user data
if(isset($_GET['u'])) {
// Get the user's context // Get the user's context
$profile = new User($_GET['u']); $profile = new User(isset($_GET['u']) ? $_GET['u'] : 0);
// Assign the object to a renderData variable // Assign the object to a renderData variable
$renderData['profile'] = $profile; $renderData['profile'] = $profile;
$renderData['page'] = [ // Set proper page title
$renderData['page']['title'] = (
'notfound' => false, $profile->data['id'] < 1 || $profile->data['password_algo'] == 'nologin'
'title' => ($profile->data['id'] < 1 || $profile->data['password_algo'] == 'nologin' ? 'User not found!' : 'Profile of '. $profile->data['username']), ? 'User not found!'
'style' => (!empty($profile->data['userData']['profileBackground']) ? [ : 'Profile of '. $profile->data['username']
);
'#userBackground' => [
'background' => 'url("/bg/'. $profile->data['id'] .'") no-repeat center center / cover transparent !important',
'position' => 'fixed',
'top' => '0',
'bottom' => '0',
'right' => '0',
'left' => '0',
'z-index' => '-1'
]
] : null)
];
} else {
$renderData['page'] = [
'notfound' => true,
'title' => 'User not found!'
];
}
// Print page contents // Print page contents
print Templates::render('main/profile.tpl', $renderData); print Templates::render('main/profile.tpl', $renderData);

View file

@ -280,7 +280,7 @@ if(isset($_REQUEST['request-notifications']) && $_REQUEST['request-notifications
]; ];
break; break;
} }
// Check if the upload went properly // Check if the upload went properly
@ -438,8 +438,18 @@ if(isset($_REQUEST['request-notifications']) && $_REQUEST['request-notifications
} }
// Create new array
$updated = [$userDataKey => basename($filename)];
// Check for the site wide name
if($mode == 'background') {
$updated['profileBackgroundSiteWide'] = isset($_REQUEST['sitewide']);
}
// Update database // Update database
Users::updateUserDataField(Session::$userId, [$userDataKey => basename($filename)]); Users::updateUserDataField(Session::$userId, $updated);
// Set render data // Set render data
$renderData['page'] = [ $renderData['page'] = [
@ -624,7 +634,7 @@ if(Users::checkLogin()) {
// Profile // Profile
case 'userpage': case 'userpage':
break; break;
// Profile // Profile