r20151111.1
Signed-off-by: Flashwave <me@flash.moe>
This commit is contained in:
parent
32eb5bcc00
commit
082bd62efc
13 changed files with 134 additions and 291 deletions
|
@ -142,14 +142,13 @@ class Main
|
|||
]
|
||||
)) {
|
||||
// If so assign the errid
|
||||
$errid = $past['id'];
|
||||
$errid = $past['error_id'];
|
||||
} else {
|
||||
// Create an error ID
|
||||
$errid = substr(md5(microtime()), rand(0, 22), 10);
|
||||
|
||||
// Log the error
|
||||
Database::insert('error_log', [
|
||||
|
||||
'error_id' => $errid,
|
||||
'error_timestamp' => date("r"),
|
||||
'error_revision' => SAKURA_VERSION,
|
||||
|
@ -158,7 +157,6 @@ class Main
|
|||
'error_string' => $errstr,
|
||||
'error_file' => $errfile,
|
||||
'error_backtrace' => $backtrace,
|
||||
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@ -188,6 +186,11 @@ class Main
|
|||
ob_clean();
|
||||
ob_end_clean();
|
||||
|
||||
// Check if this request was made through the ajax thing
|
||||
if (isset($_REQUEST['ajax'])) {
|
||||
die('An error occurred while executing the script.|1|javascript:alert("' . (isset($errid) ? 'Error Log ID: '. $errid : 'Failed to log.') . '");');
|
||||
}
|
||||
|
||||
// Build page
|
||||
$errorPage = '<!DOCTYPE html>
|
||||
<html>
|
||||
|
|
|
@ -170,6 +170,15 @@ class User
|
|||
// Check if a user is online
|
||||
public function isOnline()
|
||||
{
|
||||
// Get all sessions
|
||||
$sessions = Database::fetch('sessions', true, ['user_id' => [$this->id(), '=']]);
|
||||
|
||||
// If there's no entries just straight up return false
|
||||
if(!$sessions) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Otherwise use the standard method
|
||||
return $this->data['user_last_online'] > (time() - Config::getConfig('max_online_time'));
|
||||
}
|
||||
|
||||
|
@ -197,6 +206,52 @@ class User
|
|||
return $times;
|
||||
}
|
||||
|
||||
// Add ranks to a user
|
||||
public function addRanks($ranks) {
|
||||
// Update the ranks array
|
||||
$ranks = array_map('intval', array_unique(array_merge($this->ranks(), $ranks)));
|
||||
|
||||
// Save to the database
|
||||
Database::update('users', [
|
||||
[
|
||||
'user_ranks' => json_encode($ranks),
|
||||
],
|
||||
[
|
||||
'user_id' => [$this->id(), '='],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
// Remove ranks from a user
|
||||
public function removeRanks($ranks)
|
||||
{
|
||||
// Current ranks
|
||||
$currRanks = $this->ranks();
|
||||
|
||||
// Iterate over the ranks
|
||||
foreach ($ranks as $rank) {
|
||||
// Try to find the value
|
||||
if($key = array_search($rank, $currRanks)) {
|
||||
unset($currRanks[$key]);
|
||||
|
||||
// Change the main rank if it's set to the rank that's currently being remove
|
||||
if ($this->mainRank() == $rank) {
|
||||
$this->setMainRank($this->ranks()[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Save to the database
|
||||
Database::update('users', [
|
||||
[
|
||||
'user_ranks' => json_encode($currRanks),
|
||||
],
|
||||
[
|
||||
'user_id' => [$this->id(), '='],
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
// Set the main rank of this user
|
||||
public function setMainRank($rank)
|
||||
{
|
||||
|
@ -206,7 +261,7 @@ class User
|
|||
}
|
||||
|
||||
// If it does exist update their row
|
||||
Database::update('user', [
|
||||
Database::update('users', [
|
||||
[
|
||||
'rank_main' => $rank,
|
||||
],
|
||||
|
@ -239,12 +294,6 @@ class User
|
|||
return false;
|
||||
}
|
||||
|
||||
// For compatibility, too lazy to update the references right now!
|
||||
public function checkIfUserHasRanks($ranks)
|
||||
{
|
||||
return $this->hasRanks($ranks);
|
||||
}
|
||||
|
||||
// Add a new friend
|
||||
public function addFriend($uid)
|
||||
{
|
||||
|
@ -256,11 +305,8 @@ class User
|
|||
return [0, 'USER_NOT_EXIST'];
|
||||
}
|
||||
|
||||
// Get check
|
||||
$check = $this->checkFriends($uid);
|
||||
|
||||
// Check if the user already has this user a friend
|
||||
if ($check) {
|
||||
if ($this->isFriends($uid)) {
|
||||
return [0, 'ALREADY_FRIENDS'];
|
||||
}
|
||||
|
||||
|
@ -272,7 +318,7 @@ class User
|
|||
]);
|
||||
|
||||
// Return true because yay
|
||||
return [1, $check == 2 ? 'FRIENDS' : 'NOT_MUTUAL'];
|
||||
return [1, $user->isFriends($this->id()) ? 'FRIENDS' : 'NOT_MUTUAL'];
|
||||
}
|
||||
|
||||
// Remove a friend
|
||||
|
@ -287,7 +333,7 @@ class User
|
|||
}
|
||||
|
||||
// Check if the user has this user a friend
|
||||
if (!$this->checkFriends($uid)) {
|
||||
if (!$this->isFriends($uid)) {
|
||||
return [0, 'ALREADY_REMOVED'];
|
||||
}
|
||||
|
||||
|
@ -334,12 +380,6 @@ class User
|
|||
return 0;
|
||||
}
|
||||
|
||||
// Compat.
|
||||
public function checkFriends($with)
|
||||
{
|
||||
return $this->isFriends($with);
|
||||
}
|
||||
|
||||
// Get all the friend of this user
|
||||
public function friends($level = 0, $noObj = false)
|
||||
{
|
||||
|
@ -400,12 +440,6 @@ class User
|
|||
return $objects;
|
||||
}
|
||||
|
||||
// Compatibility
|
||||
public function getFriends()
|
||||
{
|
||||
return $this->friends();
|
||||
}
|
||||
|
||||
// Check if the user is banned
|
||||
public function checkBan()
|
||||
{
|
||||
|
@ -530,11 +564,11 @@ class User
|
|||
}
|
||||
|
||||
// Check if user has Premium
|
||||
public function checkPremium()
|
||||
public function isPremium()
|
||||
{
|
||||
|
||||
// Check if the user has static premium
|
||||
if (Permissions::check('SITE', 'STATIC_PREMIUM', $this->data['user_id'], 1)) {
|
||||
if ($this->checkPermission('SITE', 'STATIC_PREMIUM')) {
|
||||
return [2, 0, time() + 1];
|
||||
}
|
||||
|
||||
|
@ -550,8 +584,6 @@ class User
|
|||
|
||||
// Check if the Tenshi hasn't expired
|
||||
if ($getRecord['premium_expire'] < time()) {
|
||||
Users::removeUserPremium($this->data['user_id']);
|
||||
Users::updatePremiumMeta($this->data['user_id']);
|
||||
return [0, $getRecord['premium_start'], $getRecord['premium_expire']];
|
||||
}
|
||||
|
||||
|
|
|
@ -636,82 +636,6 @@ class Users
|
|||
return $code;
|
||||
}
|
||||
|
||||
// Set the default rank of a user
|
||||
public static function setDefaultRank($uid, $rid, $userIdIsUserData = false)
|
||||
{
|
||||
return (new User($uid))->setMainRank($rid);
|
||||
}
|
||||
|
||||
// Add a rank to a user
|
||||
public static function addRanksToUser($ranks, $uid, $userIdIsUserData = false)
|
||||
{
|
||||
// Define $current
|
||||
$current = [];
|
||||
|
||||
// Go over all the new ranks
|
||||
foreach ($ranks as $rank) {
|
||||
// Check if the user already has this rank and set it if not
|
||||
if (!in_array($rank, $current)) {
|
||||
$current[] = (int) $rank;
|
||||
}
|
||||
}
|
||||
|
||||
// Encode the array
|
||||
$current = json_encode($current);
|
||||
|
||||
// Update the row
|
||||
Database::update('users', [
|
||||
[
|
||||
'user_ranks' => $current,
|
||||
],
|
||||
[
|
||||
'user_id' => [$uid, '='],
|
||||
],
|
||||
]);
|
||||
|
||||
// Return true because
|
||||
return true;
|
||||
}
|
||||
|
||||
// Removing ranks from a user
|
||||
public static function removeRanksFromUser($ranks, $uid, $userIdIsUserData = false)
|
||||
{
|
||||
// Get the specified user
|
||||
$user = new User($uid);
|
||||
|
||||
$current = $user->ranks();
|
||||
|
||||
// Check the current ranks for ranks in the set array
|
||||
foreach ($current as $key => $rank) {
|
||||
// Unset the rank
|
||||
if (in_array($rank, $user->ranks())) {
|
||||
unset($current[$key]);
|
||||
}
|
||||
}
|
||||
|
||||
// Encode the array
|
||||
$current = json_encode($current);
|
||||
|
||||
// Update the row
|
||||
Database::update('users', [
|
||||
[
|
||||
'user_ranks' => $current,
|
||||
],
|
||||
[
|
||||
'user_id' => [$uid, '='],
|
||||
],
|
||||
]);
|
||||
|
||||
// Return true
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check if a user has these ranks
|
||||
public static function checkIfUserHasRanks($ranks, $userid, $userIdIsUserData = false)
|
||||
{
|
||||
return (new User($userid))->checkIfUserHasRanks($ranks);
|
||||
}
|
||||
|
||||
// Check if a user exists
|
||||
public static function userExists($user, $id = true)
|
||||
{
|
||||
|
@ -830,64 +754,35 @@ class Users
|
|||
return $expire;
|
||||
}
|
||||
|
||||
// Remove the premium status of a user
|
||||
public static function removeUserPremium($id)
|
||||
{
|
||||
Database::delete('premium', [
|
||||
'user_id' => [$id, '='],
|
||||
]);
|
||||
}
|
||||
|
||||
// Check if user has Premium
|
||||
public static function checkUserPremium($id)
|
||||
{
|
||||
// Check if the user has static premium
|
||||
if (Permissions::check('SITE', 'STATIC_PREMIUM', $id, 1)) {
|
||||
return [2, 0, time() + 1];
|
||||
}
|
||||
|
||||
// Attempt to retrieve the premium record from the database
|
||||
$getRecord = Database::fetch('premium', false, [
|
||||
'user_id' => [$id, '='],
|
||||
]);
|
||||
|
||||
// If nothing was returned just return false
|
||||
if (empty($getRecord)) {
|
||||
return [0];
|
||||
}
|
||||
|
||||
// Check if the Tenshi hasn't expired
|
||||
if ($getRecord['premium_expire'] < time()) {
|
||||
self::removeUserPremium($id);
|
||||
self::updatePremiumMeta($id);
|
||||
return [0, $getRecord['premium_start'], $getRecord['premium_expire']];
|
||||
}
|
||||
|
||||
// Else return the start and expiration date
|
||||
return [1, $getRecord['premium_start'], $getRecord['premium_expire']];
|
||||
}
|
||||
|
||||
// Update the premium data
|
||||
public static function updatePremiumMeta($id)
|
||||
{
|
||||
// Get the ID for the premium user rank from the database
|
||||
$premiumRank = Config::getConfig('premium_rank_id');
|
||||
|
||||
// Create user object
|
||||
$user = new User($id);
|
||||
|
||||
// Run the check
|
||||
$check = self::checkUserPremium($id);
|
||||
$check = $user->isPremium();
|
||||
|
||||
// Check if the user has premium
|
||||
if ($check[0] == 1) {
|
||||
if ($check[0]) {
|
||||
// If so add the rank to them
|
||||
self::addRanksToUser([$premiumRank], $id);
|
||||
$user->addRanks([$premiumRank]);
|
||||
|
||||
// Check if the user's default rank is standard user and update it to premium
|
||||
if (((new User($id))->mainRank()) == 2) {
|
||||
self::setDefaultRank($id, $premiumRank);
|
||||
if ($user->mainRank() == 2) {
|
||||
$user->setMainRank($premiumRank);
|
||||
}
|
||||
} elseif ($check[0] == 0 && count($check) > 1) {
|
||||
} elseif (!$check[0] && count($check) > 1) {
|
||||
// Remove the expired entry
|
||||
Database::delete('premium', [
|
||||
'user_id' => [$user->id(), '='],
|
||||
]);
|
||||
|
||||
// Else remove the rank from them
|
||||
self::removeRanksFromUser([$premiumRank], $id);
|
||||
$user->removeRanks([$premiumRank]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -921,7 +816,7 @@ class Users
|
|||
// Go over all users and check if they have the rank id
|
||||
foreach ($users as $user) {
|
||||
// If so store the user's row in the array
|
||||
if (self::checkIfUserHasRanks([$rankId], $user->id())
|
||||
if ($user->hasRanks([$rankId], $user->id())
|
||||
&& ($excludeAbyss ? $user->password()['password_algo'] != 'nologin' : true)) {
|
||||
$rank[] = $user;
|
||||
}
|
||||
|
@ -1047,83 +942,6 @@ class Users
|
|||
]);
|
||||
}
|
||||
|
||||
// Get friends
|
||||
public static function getFriends($uid = null, $timestamps = false, $getData = false, $checkOnline = false)
|
||||
{
|
||||
// Assign $uid
|
||||
if (!$uid) {
|
||||
$uid = Users::checkLogin()[0];
|
||||
}
|
||||
|
||||
// Get all friends
|
||||
$getFriends = Database::fetch('friends', true, [
|
||||
'user_id' => [$uid, '='],
|
||||
]);
|
||||
|
||||
// Create the friends array
|
||||
$friends = [];
|
||||
|
||||
// Iterate over the raw database return
|
||||
foreach ($getFriends as $key => $friend) {
|
||||
// Add friend to array
|
||||
$friends[($timestamps ? $friend['friend_id'] : $key)] = $getData ? ([
|
||||
|
||||
'user' => ($_UDATA = new User($friend['friend_id'])),
|
||||
'rank' => new Rank($_UDATA->mainRank()),
|
||||
|
||||
]) : $friend[($timestamps ? 'friend_timestamp' : 'friend_id')];
|
||||
}
|
||||
|
||||
// Check who is online and who isn't
|
||||
if ($checkOnline) {
|
||||
// Check each user
|
||||
foreach ($friends as $key => $friend) {
|
||||
$friends[
|
||||
(new User($getData ? $friend['user']->id() : $friend))->checkOnline() ? 'online' : 'offline'
|
||||
][] = $friend;
|
||||
}
|
||||
}
|
||||
|
||||
// Return formatted array
|
||||
return $friends;
|
||||
}
|
||||
|
||||
// Get non-mutual friends
|
||||
public static function getPendingFriends($uid = null, $getData = false)
|
||||
{
|
||||
// Assign $of automatically if it's not set
|
||||
if (!$uid) {
|
||||
$uid = self::checkLogin()[0];
|
||||
}
|
||||
|
||||
// Get all friend entries from other people involved the current user
|
||||
$friends = Database::fetch('friends', true, [
|
||||
'friend_id' => [$uid, '='],
|
||||
]);
|
||||
|
||||
// Create pending array
|
||||
$pending = [];
|
||||
|
||||
// Check if the friends are mutual
|
||||
foreach ($friends as $friend) {
|
||||
// Create user object
|
||||
$user = new User($uid);
|
||||
|
||||
// Check if the friend is mutual
|
||||
if (!$user->checkFriends($friend['user_id'])) {
|
||||
$pending[] = $getData ? ([
|
||||
|
||||
'user' => ($_UDATA = new User($friend['user_id'])),
|
||||
'rank' => new Rank($_UDATA->mainRank()),
|
||||
|
||||
]) : $friend;
|
||||
}
|
||||
}
|
||||
|
||||
// Return the pending friends
|
||||
return $pending;
|
||||
}
|
||||
|
||||
// Get the ID of the newest user
|
||||
public static function getNewestUserId()
|
||||
{
|
||||
|
|
|
@ -26,25 +26,19 @@ set_time_limit(0);
|
|||
|
||||
// Clean expired sessions
|
||||
Database::delete('sessions', [
|
||||
|
||||
'session_expire' => [time(), '<'],
|
||||
'session_remember' => ['1', '!='],
|
||||
|
||||
]);
|
||||
|
||||
// Delete notifications that are older than a month but not unread
|
||||
Database::delete('notifications', [
|
||||
|
||||
'alert_timestamp' => [(time() - 109500), '<'],
|
||||
'alert_read' => ['1', '='],
|
||||
|
||||
]);
|
||||
|
||||
// Get expired premium accounts
|
||||
$expiredPremium = Database::fetch('premium', true, [
|
||||
|
||||
'premium_expire' => [time(), '<'],
|
||||
|
||||
]);
|
||||
|
||||
// Process expired premium accounts
|
||||
|
|
|
@ -139,6 +139,7 @@ if (!defined('SAKURA_NO_TPL')) {
|
|||
'dateFormat' => Config::getConfig('date_format'),
|
||||
'currentPage' => '//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'],
|
||||
'referrer' => (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null),
|
||||
'onlineTimeout' => Config::getConfig('max_online_time'),
|
||||
|
||||
'recaptchaPublic' => Config::getConfig('recaptcha_public'),
|
||||
'recaptchaEnabled' => Config::getConfig('recaptcha'),
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div class="head">Hi, {{ user.username }}!</div>
|
||||
<a href="{{ urls.format('SETTING_MODE', ['appearance', 'avatar']) }}"><img src="{{ urls.format('IMAGE_AVATAR', [user.id]) }}" class="default-avatar-setting homepage-menu-avatar" /></a>
|
||||
<ul class="panelQuickLinks">
|
||||
<li><a href="{{ urls.format('SETTING_MODE', ['friends', 'requests']) }}" title="Pending friend requests"><span class="fa fa-user-plus"></span><span class="count">{{ page.friend_req|length }}</span></a></li>
|
||||
<li><a href="{{ urls.format('SETTING_MODE', ['friends', 'requests']) }}" title="Pending friend requests"><span class="fa fa-user-plus"></span><span class="count">{{ user.friends(-1, true)|length }}</span></a></li>
|
||||
<li><a href="{{ urls.format('MESSAGES_INDEX') }}" title="View private messages"><span class="fa fa-envelope"></span><span class="count">0</span></a></li>
|
||||
</ul>
|
||||
<div class="clear"></div>
|
||||
|
@ -29,12 +29,12 @@
|
|||
it has been <b>{{ stats.lastRegDate }}</b> since the last user registered and the forum has <b>{{ stats.topicCount }} thread{% if stats.topicCount != 1 %}s{% endif %}</b> and <b>{{ stats.postCount }} post{% if stats.postCount != 1 %}s{% endif %}</b>.
|
||||
<div class="head">Online Users</div>
|
||||
{% if stats.onlineUsers %}
|
||||
All active users in the past 5 minutes:<br />
|
||||
All active users in the past {{ sakura.onlineTimeout / 60 }} minute{% if sakura.onlineTimeout != 60 %}s{% endif %}:<br />
|
||||
{% for amount,onlineUser in stats.onlineUsers %}
|
||||
<a href="{{ urls.format('USER_PROFILE', [onlineUser.id]) }}" style="font-weight: bold; color: {{ onlineUser.colour }};" class="default">{{ onlineUser.username }}</a>{% if amount != (stats.onlineUsers|length - 1) %}, {% endif %}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
There were no online users in the past 5 minutes.
|
||||
There were no online users in the past {{ sakura.onlineTimeout / 60 }} minute{% if sakura.onlineTimeout != 60 %}s{% endif %}.
|
||||
{% endif %}
|
||||
{#<div class="ad-container ad-sidebar" id="sideAd">
|
||||
<div class="head">Advertisment</div>
|
||||
|
|
|
@ -34,8 +34,8 @@
|
|||
{% if user.id == profile.id %}
|
||||
<a class="fa fa-pencil-square-o" title="Edit your profile" href="{{ urls.format('SETTING_MODE', ['general', 'profile']) }}"></a>
|
||||
{% else %}
|
||||
{% if user.checkFriends(profile.id) != 0 %}<a class="fa fa-{% if user.checkFriends(profile.id) == 2 %}heart{% else %}star{% endif %}" title="You are friends"></a>{% endif %}
|
||||
<a class="fa fa-user-{% if user.checkFriends(profile.id) == 0 %}plus{% else %}times{% endif %}" title="{% if user.checkFriends(profile.id) == 0 %}Add {{ profile.username }} as a friend{% else %}Remove friend{% endif %}" href="{% if user.checkFriends(profile.id) == 0 %}{{ urls.format('FRIEND_ADD', [profile.id, php.sessionid, php.time, sakura.currentPage]) }}{% else %}{{ urls.format('FRIEND_REMOVE', [profile.id, php.sessionid, php.time, sakura.currentPage]) }}{% endif %}" id="profileFriendToggle"></a>
|
||||
{% if user.isFriends(profile.id) != 0 %}<a class="fa fa-{% if user.isFriends(profile.id) == 2 %}heart{% else %}star{% endif %}" title="You are friends"></a>{% endif %}
|
||||
<a class="fa fa-user-{% if user.isFriends(profile.id) == 0 %}plus{% else %}times{% endif %}" title="{% if user.isFriends(profile.id) == 0 %}Add {{ profile.username }} as a friend{% else %}Remove friend{% endif %}" href="{% if user.isFriends(profile.id) == 0 %}{{ urls.format('FRIEND_ADD', [profile.id, php.sessionid, php.time, sakura.currentPage]) }}{% else %}{{ urls.format('FRIEND_REMOVE', [profile.id, php.sessionid, php.time, sakura.currentPage]) }}{% endif %}" id="profileFriendToggle"></a>
|
||||
<a class="fa fa-exclamation-circle" title="Report {{ profile.username }}" href="{{ urls.format('USER_REPORT', [profile.id]) }}"></a>
|
||||
{% endif %}
|
||||
<hr class="default" />
|
||||
|
|
|
@ -13,13 +13,13 @@ window.addEventListener("load", function() {
|
|||
{% if friends|length %}
|
||||
<div class="friends-list">
|
||||
{% for friend in friends[page.currentPage] %}
|
||||
<div class="friend-container" id="friendslist-friend-{{ friend.user.id }}">
|
||||
<a class="friends-list-data clean" href="/u/{{ friend.user.id }}">
|
||||
<img src="/a/{{ friend.user.id }}" alt="{{ friend.user.username }}" class="friends-list-avatar default-avatar-setting" style="width: 150px; height: 150px;" />
|
||||
<div class="friends-list-name" style="color: {{ friend.user.colour }};">{{ friend.user.username }}</div>
|
||||
<div class="friend-container" id="friendslist-friend-{{ friend.id }}">
|
||||
<a class="friends-list-data clean" href="/u/{{ friend.id }}">
|
||||
<img src="/a/{{ friend.id }}" alt="{{ friend.username }}" class="friends-list-avatar default-avatar-setting" style="width: 150px; height: 150px;" />
|
||||
<div class="friends-list-name" style="color: {{ friend.colour }};">{{ friend.username }}</div>
|
||||
</a>
|
||||
<div class="friends-list-actions">
|
||||
<a class="remove fill fa fa-remove" title="Remove friend" href="/friends?remove={{ friend.user.id }}&session={{ php.sessionid }}&time={{ php.time }}" id="friendslist-friend-action-remove-{{ friend.user.id }}"></a>
|
||||
<a class="remove fill fa fa-remove" title="Remove friend" href="/friends?remove={{ friend.id }}&session={{ php.sessionid }}&time={{ php.time }}" id="friendslist-friend-action-remove-{{ friend.id }}"></a>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -13,14 +13,14 @@ window.addEventListener("load", function() {
|
|||
{% if friends|length %}
|
||||
<div class="friends-list">
|
||||
{% for friend in friends[page.currentPage] %}
|
||||
<div class="friend-container" id="friend-{{ friend.user.id }}">
|
||||
<a class="friends-list-data clean" href="/u/{{ friend.user.id }}">
|
||||
<img src="/a/{{ friend.user.id }}" alt="{{ friend.user.username }}" class="friends-list-avatar default-avatar-setting" style="width: 150px; height: 150px;" />
|
||||
<div class="friends-list-name" style="color: {{ friend.user.colour }};">{{ friend.user.username }}</div>
|
||||
<div class="friend-container" id="friend-{{ friend.id }}">
|
||||
<a class="friends-list-data clean" href="/u/{{ friend.id }}">
|
||||
<img src="/a/{{ friend.id }}" alt="{{ friend.username }}" class="friends-list-avatar default-avatar-setting" style="width: 150px; height: 150px;" />
|
||||
<div class="friends-list-name" style="color: {{ friend.colour }};">{{ friend.username }}</div>
|
||||
</a>
|
||||
<div class="friends-list-actions">
|
||||
<a class="add fa fa-check" title="Add friend" href="/friends?add={{ friend.user.id }}&session={{ php.sessionid }}&time={{ php.time }}" id="friendslist-friend-action-add-{{ friend.user.id }}"></a>
|
||||
<a class="remove fa fa-remove" title="Remove friend" href="/friends?remove={{ friend.user.id }}&session={{ php.sessionid }}&time={{ php.time }}" id="friendslist-friend-action-remove-{{ friend.user.id }}"></a>
|
||||
<a class="add fa fa-check" title="Add friend" href="/friends?add={{ friend.id }}&session={{ php.sessionid }}&time={{ php.time }}" id="friendslist-friend-action-add-{{ friend.id }}"></a>
|
||||
<a class="remove fa fa-remove" title="Remove friend" href="/friends?remove={{ friend.id }}&session={{ php.sessionid }}&time={{ php.time }}" id="friendslist-friend-action-remove-{{ friend.id }}"></a>
|
||||
<div class="clear"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -49,7 +49,7 @@ if (isset($_GET['m'])) {
|
|||
$user = new User($_GET['u']);
|
||||
|
||||
// If user is deactivated use deactive avatar
|
||||
if ($user->checkIfUserHasRanks([0, 1])) {
|
||||
if ($user->hasRanks([0, 1])) {
|
||||
$serveImage = $deactiveAvatar;
|
||||
break;
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ if (isset($_GET['m'])) {
|
|||
$user = new User($_GET['u']);
|
||||
|
||||
// If user is deactivated use deactive avatar
|
||||
if ($user->checkIfUserHasRanks([0, 1])) {
|
||||
if ($user->hasRanks([0, 1])) {
|
||||
$serveImage = $noBackground;
|
||||
break;
|
||||
}
|
||||
|
@ -120,7 +120,7 @@ if (isset($_GET['m'])) {
|
|||
$user = new User($_GET['u']);
|
||||
|
||||
// If user is deactivated use deactive avatar
|
||||
if ($user->checkIfUserHasRanks([0, 1])) {
|
||||
if ($user->hasRanks([0, 1])) {
|
||||
$serveImage = $noHeader;
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -50,10 +50,6 @@ $renderData['news'] = ($forumMode ? null : (new News(Config::getConfig('site_new
|
|||
|
||||
$renderData['newsCount'] = Config::getConfig('front_page_news_posts');
|
||||
|
||||
$renderData['page'] = [
|
||||
'friend_req' => Users::getPendingFriends(),
|
||||
];
|
||||
|
||||
$renderData['board'] = [
|
||||
'forums' => ($forumMode ? Forums::getForumList() : null),
|
||||
'viewforum' => false,
|
||||
|
|
|
@ -51,7 +51,8 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
|
|||
}
|
||||
|
||||
// Check if friendOnline is set (so it doesn't tell you all your friends all online on first visit)
|
||||
$onlineNotify = isset($_SESSION['friendsOnline']) ? $_SESSION['friendsOnline'] : [];
|
||||
$onlineFriends = isset($_SESSION['friendsOnline']) ? $_SESSION['friendsOnline'] : [];
|
||||
$onlineNotify = isset($_SESSION['friendsOnline']);
|
||||
|
||||
// Populate the array
|
||||
foreach ($currentUser->friends(1) as $friend) {
|
||||
|
@ -59,12 +60,13 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
|
|||
$online = $friend->isOnline();
|
||||
|
||||
// If true check if they're already in the array
|
||||
if($online && !in_array($friend->id(), $onlineNotify)) {
|
||||
if ($online && !in_array($friend->id(), $onlineFriends)) {
|
||||
// Add user to the online array
|
||||
$_SESSION['friendsOnline'][$friend->id()] = $friend->id();
|
||||
|
||||
// Add the notification to the display array
|
||||
$notifications[time()] = [
|
||||
if($onlineNotify) {
|
||||
$notifications[] = [
|
||||
'read' => 0,
|
||||
'title' => $friend->username() . ' is online.',
|
||||
'text' => '',
|
||||
|
@ -73,12 +75,14 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
|
|||
'timeout' => 2000,
|
||||
'sound' => false,
|
||||
];
|
||||
} elseif(!$online && in_array($friend->id(), $onlineNotify)) {
|
||||
}
|
||||
} elseif (!$online && in_array($friend->id(), $onlineFriends)) {
|
||||
// Remove the person from the array
|
||||
unset($_SESSION['friendsOnline'][$friend->id()]);
|
||||
|
||||
// Add the notification to the display array
|
||||
$notifications[time()] = [
|
||||
if($onlineNotify) {
|
||||
$notifications[] = [
|
||||
'read' => 0,
|
||||
'title' => $friend->username() . ' is offline.',
|
||||
'text' => '',
|
||||
|
@ -89,6 +93,7 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
|
|||
];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set header, convert the array to json, print it and exit
|
||||
print json_encode($notifications);
|
||||
|
@ -346,32 +351,26 @@ if (isset($_REQUEST['request-notifications']) && $_REQUEST['request-notification
|
|||
|
||||
// Set the messages
|
||||
$messages = [
|
||||
|
||||
'USER_NOT_EXIST' => 'The user you tried to add doesn\'t exist.',
|
||||
'ALREADY_FRIENDS' => 'You are already friends with this person!',
|
||||
'FRIENDS' => 'You are now mutual friends!',
|
||||
'NOT_MUTUAL' => 'A friend request has been sent to this person.',
|
||||
'ALREADY_REMOVED' => 'You aren\'t friends with this person.',
|
||||
'REMOVED' => 'Removed this person from your friends list.',
|
||||
|
||||
];
|
||||
|
||||
// Notification strings
|
||||
$notifStrings = [
|
||||
|
||||
'FRIENDS' => ['%s accepted your friend request!', 'You can now do mutual friend things!'],
|
||||
'NOT_MUTUAL' => ['%s added you as a friend!', 'Click here to add them as well.'],
|
||||
'REMOVED' => ['%s removed you from their friends.', 'You can no longer do friend things now ;_;'],
|
||||
|
||||
];
|
||||
|
||||
// Add page specific things
|
||||
$renderData['page'] = [
|
||||
|
||||
'redirect' => $redirect,
|
||||
'message' => $messages[$action[1]],
|
||||
'success' => $action[0],
|
||||
|
||||
];
|
||||
|
||||
// Create a notification
|
||||
|
@ -1492,12 +1491,12 @@ if (Users::checkLogin()) {
|
|||
|
||||
// Friends
|
||||
case 'friends.listing':
|
||||
$renderData['friends'] = array_chunk(array_reverse(Users::getFriends(null, true, true)), 12, true);
|
||||
$renderData['friends'] = array_chunk(array_reverse($currentUser->friends(1)), 12, true);
|
||||
break;
|
||||
|
||||
// Pending Friend Requests
|
||||
case 'friends.requests':
|
||||
$renderData['friends'] = array_chunk(array_reverse(Users::getPendingFriends(null, true)), 12, true);
|
||||
$renderData['friends'] = array_chunk(array_reverse($currentUser->friends(-1)), 12, true);
|
||||
break;
|
||||
|
||||
// PM inbox
|
||||
|
|
|
@ -63,7 +63,7 @@ if (isset($_REQUEST['mode'])
|
|||
$total,
|
||||
$itemName,
|
||||
Config::getConfig('sitename') . ' Premium Purchase',
|
||||
'https://' . Config::getConfig('url_main') . $urls->format('SITE_PREMIUM')
|
||||
'http://' . Config::getConfig('url_main') . $urls->format('SITE_PREMIUM')
|
||||
)) {
|
||||
// Store the amount of months in the global session array
|
||||
$_SESSION['premiumMonths'] = (int) $_POST['months'];
|
||||
|
@ -119,7 +119,7 @@ if (isset($_REQUEST['mode'])
|
|||
case 'complete':
|
||||
$renderData = array_merge([
|
||||
'page' => [
|
||||
'expiration' => ($prem = Users::checkUserPremium($currentUser->id())[2]) !== null ? $prem : 0,
|
||||
'expiration' => ($prem = $currentUser->isPremium()[2]) !== null ? $prem : 0,
|
||||
],
|
||||
], $renderData);
|
||||
|
||||
|
@ -163,7 +163,7 @@ $renderData['page'] = [
|
|||
|
||||
'fail' => isset($_GET['fail']),
|
||||
'price' => Config::getConfig('premium_price_per_month'),
|
||||
'current' => $currentUser->checkPremium(),
|
||||
'current' => $currentUser->isPremium(),
|
||||
'amount_max' => Config::getConfig('premium_amount_max'),
|
||||
|
||||
];
|
||||
|
|
Reference in a new issue