welcome to osu!
This commit is contained in:
parent
437e3c1039
commit
b041779ebb
15 changed files with 115 additions and 83 deletions
|
@ -2061,6 +2061,31 @@
|
|||
"type": "UPD",
|
||||
"change": "Converted profile.php to the new user API.",
|
||||
"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"
|
||||
}
|
||||
|
||||
]
|
||||
|
|
|
@ -16,7 +16,7 @@ class User {
|
|||
function __construct($id) {
|
||||
|
||||
// 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
|
||||
if(empty($this->data)) {
|
||||
|
|
|
@ -94,7 +94,7 @@ class MySQL {
|
|||
$prepare .= ' WHERE';
|
||||
|
||||
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($key);
|
||||
|
@ -223,7 +223,7 @@ class MySQL {
|
|||
|
||||
// Do this complicated shit, I barely know what's going on anymore but it works
|
||||
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';
|
||||
|
||||
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($key);
|
||||
|
@ -320,7 +320,7 @@ class MySQL {
|
|||
$prepare .= ' WHERE';
|
||||
|
||||
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($key);
|
||||
|
|
|
@ -111,15 +111,15 @@ if(!defined('SAKURA_NO_TPL')) {
|
|||
|
||||
],
|
||||
|
||||
'user' => [
|
||||
'session' => [
|
||||
|
||||
'checklogin' => Users::checkLogin(),
|
||||
'session' => Session::$sessionId,
|
||||
'data' => ($_init_udata = Users::getUser(Session::$userId)),
|
||||
'rank' => ($_init_rdata = Users::getRank($_init_udata['rank_main'])),
|
||||
'colour' => ($_init_udata['name_colour'] == null ? $_init_rdata['colour'] : $_init_udata['name_colour'])
|
||||
'checkLogin' => Users::checkLogin(),
|
||||
'sessionId' => Session::$sessionId,
|
||||
'userId' => Session::$userId
|
||||
|
||||
]
|
||||
],
|
||||
|
||||
'user' => new User(Session::$userId)
|
||||
|
||||
];
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
{% if user.checklogin %}
|
||||
{% if session.checkLogin %}
|
||||
<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>
|
||||
<ul class="panelQuickLinks">
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
<div class="userdata">
|
||||
<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 }}" />
|
||||
{% if user.checklogin %}
|
||||
{% if session.checkLogin %}
|
||||
<div class="actions">
|
||||
{% 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>
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
"minUserLen": {{ sakura.minusernamelength }},
|
||||
"maxUserLen": {{ sakura.maxusernamelength }},
|
||||
"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('onclick', 'scrollToTop();');
|
||||
|
||||
{% if user.checklogin %}
|
||||
{% if session.checkLogin %}
|
||||
// Convert href to object in logout link
|
||||
prepareAjaxLink('headerLogoutLink', 'submitPost', ', true, "Logging out..."');
|
||||
{% elseif not sakura.lockauth and php.self != '/authenticate.php' %}
|
||||
|
@ -92,7 +92,7 @@
|
|||
submit.setAttribute('onclick', 'submitPost(\''+ headerLoginForm.action +'\', formToObject(\'headerLoginForm\'), true, \'Logging in...\');');
|
||||
{% endif %}
|
||||
|
||||
{% if user.checklogin %}
|
||||
{% if session.checkLogin %}
|
||||
// Make notification requests (there's a seperate one to make it happen before the first 60 seconds)
|
||||
notifyRequest('{{ php.sessionid }}');
|
||||
|
||||
|
@ -102,12 +102,12 @@
|
|||
}, 60000);
|
||||
{% 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
|
||||
prepareAjaxLink('profileFriendToggle', 'submitPost', ', true, "{% if profile.friend == 0 %}Adding{% else %}Removing{% endif %} friend..."');
|
||||
{% endif %}
|
||||
|
||||
{% if php.self == '/viewtopic.php' and user.checklogin %}
|
||||
{% if php.self == '/viewtopic.php' and session.checkLogin %}
|
||||
var forumFriendToggles = document.querySelectorAll('.forum-friend-toggle');
|
||||
|
||||
for(var i in forumFriendToggles) {
|
||||
|
@ -146,6 +146,10 @@
|
|||
}
|
||||
{% 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>
|
||||
</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="/forum" title="Discuss things with other members but static">Forums</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 menu-donate" href="/support" title="Give us money to keep the site (and other services) up and running">Support us</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div class="menu-ucp" id="navMenuUser">
|
||||
<!-- 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" href="/messages" title="Read your private message">Messages</a>
|
||||
<a class="menu-item" href="/manage" title="Manage the site">Manage</a>
|
||||
|
@ -191,7 +195,10 @@
|
|||
</div>
|
||||
<div id="contentwrapper">
|
||||
<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');">
|
||||
<input type="hidden" name="redirect" value="{{ sakura.currentpage }}" />
|
||||
<input type="hidden" name="session" value="{{ php.sessionid }}" />
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% include 'global/header.tpl' %}
|
||||
{% if user.checklogin %}
|
||||
{% if session.checkLogin %}
|
||||
<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>
|
||||
<h3 style="padding: 0px 0px 10px;">{% if not page.active %}The entire user list.{% else %}{{ page.ranks[page.active].description }}{% endif %}</h3>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
{% 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;">
|
||||
<h1>The requested user does not exist!</h1>
|
||||
There are a few possible reasons for this:
|
||||
|
@ -11,7 +11,6 @@
|
|||
</ul>
|
||||
</div>
|
||||
{% else %}
|
||||
<div id="userBackground"></div>
|
||||
<div class="content profile">
|
||||
<div class="{% if profile.userPage|length > 1 %}content-right {% endif %}content-column">
|
||||
<div style="text-align: center;">
|
||||
|
@ -20,7 +19,7 @@
|
|||
<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>
|
||||
{% 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">
|
||||
{% if user.data.id == profile.data.id %}
|
||||
<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>
|
||||
{% if profile.profileFields %}
|
||||
<hr class="default" />
|
||||
{% if user.checklogin %}
|
||||
{% if session.checkLogin %}
|
||||
<table style="width: 100%;">
|
||||
{% for name,field in profile.profileFields %}
|
||||
<tr>
|
||||
|
@ -94,10 +93,5 @@
|
|||
</div>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
{% if profile.data.userData.profileBackground is defined %}
|
||||
<script type="text/javascript">
|
||||
initialiseParallax('userBackground');
|
||||
</script>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% include 'global/footer.tpl' %}
|
||||
|
|
|
@ -84,7 +84,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if user.checklogin and perms.canGetPremium %}
|
||||
{% if session.checkLogin and perms.canGetPremium %}
|
||||
<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);" />
|
||||
</div>
|
||||
|
@ -97,13 +97,13 @@
|
|||
</div>
|
||||
<div class="clear"></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>
|
||||
{% else %}
|
||||
<h1 style="text-align: center; margin: 1em auto;" class="stylised">You need to be logged in to get Tenshi!</h1>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% if user.checklogin and perms.canGetPremium %}
|
||||
{% if session.checkLogin and perms.canGetPremium %}
|
||||
<form action="/support" method="post" id="purchaseForm" class="hidden">
|
||||
<input type="hidden" name="mode" value="purchase" />
|
||||
<input type="hidden" name="time" value="{{ php.time }}" />
|
||||
|
|
|
@ -9,6 +9,9 @@
|
|||
</div>
|
||||
<div>
|
||||
<input type="file" name="avatar" />
|
||||
<div style="font-size: .8em;">
|
||||
(Leave upload box empty to remove avatar)
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<input type="submit" value="Submit" name="submit" class="inputStyling" />
|
||||
|
|
|
@ -9,7 +9,15 @@
|
|||
</div>
|
||||
<div>
|
||||
<input type="file" name="background" />
|
||||
<div style="font-size: .8em;">
|
||||
(Leave upload box empty to remove background)
|
||||
</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>
|
||||
<input type="submit" value="Submit" name="submit" class="inputStyling" />
|
||||
</div>
|
||||
|
|
|
@ -326,7 +326,7 @@ a#gotop.exit {
|
|||
font-weight: 700;
|
||||
font-size: 20px;
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ a#gotop.exit {
|
|||
font-weight: 700;
|
||||
font-size: 20px;
|
||||
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;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -9,47 +9,19 @@ namespace Sakura;
|
|||
// Include components
|
||||
require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php';
|
||||
|
||||
// Get user data
|
||||
if(isset($_GET['u'])) {
|
||||
|
||||
// Get the user's context
|
||||
$profile = new User($_GET['u']);
|
||||
// Get the user's context
|
||||
$profile = new User(isset($_GET['u']) ? $_GET['u'] : 0);
|
||||
|
||||
// Assign the object to a renderData variable
|
||||
$renderData['profile'] = $profile;
|
||||
// Assign the object to a renderData variable
|
||||
$renderData['profile'] = $profile;
|
||||
|
||||
$renderData['page'] = [
|
||||
|
||||
'notfound' => false,
|
||||
'title' => ($profile->data['id'] < 1 || $profile->data['password_algo'] == 'nologin' ? 'User not found!' : 'Profile of '. $profile->data['username']),
|
||||
'style' => (!empty($profile->data['userData']['profileBackground']) ? [
|
||||
|
||||
'#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!'
|
||||
|
||||
];
|
||||
|
||||
}
|
||||
// Set proper page title
|
||||
$renderData['page']['title'] = (
|
||||
$profile->data['id'] < 1 || $profile->data['password_algo'] == 'nologin'
|
||||
? 'User not found!'
|
||||
: 'Profile of '. $profile->data['username']
|
||||
);
|
||||
|
||||
// Print page contents
|
||||
print Templates::render('main/profile.tpl', $renderData);
|
||||
|
|
|
@ -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
|
||||
Users::updateUserDataField(Session::$userId, [$userDataKey => basename($filename)]);
|
||||
Users::updateUserDataField(Session::$userId, $updated);
|
||||
|
||||
// Set render data
|
||||
$renderData['page'] = [
|
||||
|
|
Reference in a new issue