relatively large commit

This commit is contained in:
flash 2015-08-09 20:26:01 +02:00
parent d6648f311c
commit 4404c6ea42
19 changed files with 431 additions and 41 deletions

View file

@ -38,7 +38,8 @@
"20150728", "20150728",
"20150730", "20150730",
"20150731", "20150731",
"20150807" "20150807",
"20150809"
] ]
@ -1633,6 +1634,35 @@
"change": "Added profile changing backend." "change": "Added profile changing backend."
} }
],
"20150809": [
{
"type": "FIX",
"change": "Fixed homepage friends link going to the wrong location."
},
{
"type": "UPD",
"change": "Redid settings frontpage."
},
{
"type": "ADD",
"change": "Added :smug: emote (thanks malloc)."
},
{
"type": "FIX",
"change": "Fixed links to GitHub links to link to their Bitbucket alternative."
},
{
"type": "ADD",
"change": "Added responsive view for notification for smaller screens."
},
{
"type": "ADD",
"change": "Added avatar uploading (background uploads soon)."
}
] ]
} }

View file

@ -774,4 +774,25 @@ class Main {
} }
// Get the byte symbol from a value
public static function getByteSymbol($bytes) {
// Return nothing if the input was 0
if(!$bytes)
return;
// Array with byte symbols
$symbols = ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB'];
// Calculate byte entity
$exp = floor(log($bytes) / log(1024));
// Format the things
$bytes = sprintf("%.2f ". $symbols[$exp], ($bytes / pow(1024, floor($exp))));
// Return the formatted string
return $bytes;
}
} }

View file

@ -894,13 +894,13 @@ class Users {
} }
// Updating the profile data of a user // Updating the profile data of a user
public static function updateUserProfileFields($id, $data) { public static function updateUserDataField($id, $data) {
// We retrieve the current content from the database // We retrieve the current content from the database
$current = self::getUser($id)['userData']; $current = self::getUser($id)['userData'];
// Merge the arrays // Merge the arrays
$data = array_merge($current, ['profileFields' => $data]); $data = array_merge($current, $data);
// Encode the json // Encode the json
$data = json_encode($data); $data = json_encode($data);
@ -1322,7 +1322,7 @@ class Users {
} }
// Get friends // Get friends
public static function getFriends($uid = null, $timestamps = false, $getData = false) { public static function getFriends($uid = null, $timestamps = false, $getData = false, $checkOnline = false) {
// Assign $uid // Assign $uid
if(!$uid) if(!$uid)
@ -1349,6 +1349,18 @@ class Users {
} }
// Check who is online and who isn't
if($checkOnline) {
// Check each user
foreach($friends as $key => $friend) {
$friends[self::checkUserOnline($getData ? $friend['user']['id'] : $friend) ? 'online' : 'offline'][] = $friend;
}
}
// Return formatted array // Return formatted array
return $friends; return $friends;

View file

@ -8,7 +8,7 @@
namespace Sakura; namespace Sakura;
// Define Sakura version // Define Sakura version
define('SAKURA_VERSION', '20150731'); define('SAKURA_VERSION', '20150809');
define('SAKURA_VLABEL', 'Eminence'); define('SAKURA_VLABEL', 'Eminence');
define('SAKURA_COLOUR', '#6C3082'); define('SAKURA_COLOUR', '#6C3082');
define('SAKURA_STABLE', false); define('SAKURA_STABLE', false);

View file

@ -68,7 +68,7 @@
<div class="error"> <div class="error">
{{ error }} {{ error }}
</div> </div>
<p>If you have an account on <a href="https://github.com/" target="_blank">GitHub</a> please go to the <a href="https://github.com/circlestorm/Sakura/issues" target="_blank">issues section</a> and report the error listed above (do a check to see if it hasn't been reported yet as well).</p> <p>If you have an account on <a href="https://bitbucket.org/" target="_blank">BitBucket</a> please go to the <a href="https://bitbucket.org/circlestorm/sakura/issues" target="_blank">issues section</a> and report the error listed above (do a check to see if it hasn't been reported yet as well).</p>
</div> </div>
<div class="contact"> <div class="contact">
Contact the System Operator at <a href="mailto:me@flash.moe">me@flash.moe</a> or check our <a href="http://status.flashii.net/" target="_blank">Status Page</a> and <a href="http://twitter.com/_flashii" target="_blank">Twitter Account</a> to see if anything is going on. Contact the System Operator at <a href="mailto:me@flash.moe">me@flash.moe</a> or check our <a href="http://status.flashii.net/" target="_blank">Status Page</a> and <a href="http://twitter.com/_flashii" target="_blank">Twitter Account</a> to see if anything is going on.

View file

@ -2,7 +2,7 @@
<div class="head">Hi, {{ user.data.username }}!</div> <div class="head">Hi, {{ user.data.username }}!</div>
<a href="//{{ sakura.urls.main }}/settings/avatar"><img src="//{{ sakura.urls.main }}/a/{{ user.data.id }}" class="default-avatar-setting homepage-menu-avatar" /></a> <a href="//{{ sakura.urls.main }}/settings/avatar"><img src="//{{ sakura.urls.main }}/a/{{ user.data.id }}" class="default-avatar-setting homepage-menu-avatar" /></a>
<ul class="panelQuickLinks"> <ul class="panelQuickLinks">
<li><a href="//{{ sakura.urls.main }}/friends" title="Pending friend requests"><span class="fa fa-user-plus"></span><span class="count">{{ page.friend_req|length }}</span></a></li> <li><a href="//{{ sakura.urls.main }}/settings/friendrequests" title="Pending friend requests"><span class="fa fa-user-plus"></span><span class="count">{{ page.friend_req|length }}</span></a></li>
<li><a href="//{{ sakura.urls.main }}/messages" title="View private messages"><span class="fa fa-envelope"></span><span class="count">0</span></a></li> <li><a href="//{{ sakura.urls.main }}/messages" title="View private messages"><span class="fa fa-envelope"></span><span class="count">0</span></a></li>
</ul> </ul>
<div class="clear"></div> <div class="clear"></div>

View file

@ -7,7 +7,7 @@
<a href="/settings/profile">Edit Profile</a> <a href="/settings/profile">Edit Profile</a>
<a href="/settings/groups">Groups</a> <a href="/settings/groups">Groups</a>
<div>Friends</div> <div>Friends</div>
<a href="/settings/friends">List</a> <a href="/settings/friendlisting">List</a>
<a href="/settings/friendrequests">Requests</a> <a href="/settings/friendrequests">Requests</a>
<div>Messages</div> <div>Messages</div>
<a href="/messages/inbox">Inbox</a> <a href="/messages/inbox">Inbox</a>
@ -18,7 +18,7 @@
<div>Aesthetics</div> <div>Aesthetics</div>
<a href="/settings/avatar">Avatar</a> <a href="/settings/avatar">Avatar</a>
<a href="/settings/background">Background</a> <a href="/settings/background">Background</a>
<a href="/settings/page">Profile Page</a> <a href="/settings/userpage">Profile Page</a>
<div>Account</div> <div>Account</div>
<a href="/settings/email">E-mail Address</a> <a href="/settings/email">E-mail Address</a>
<a href="/settings/username">Username</a> <a href="/settings/username">Username</a>

View file

@ -18,7 +18,7 @@
<li><a href="https://twitter.com/_flashii" target="_blank" title="Follow us on Twitter for news messages that are too short for the news page">Twitter</a></li> <li><a href="https://twitter.com/_flashii" target="_blank" title="Follow us on Twitter for news messages that are too short for the news page">Twitter</a></li>
<li><a href="https://youtube.com/user/flashiinet" target="_blank" title="Our YouTube page where stuff barely ever gets uploaded, mainly used to archive community creations">YouTube</a></li> <li><a href="https://youtube.com/user/flashiinet" target="_blank" title="Our YouTube page where stuff barely ever gets uploaded, mainly used to archive community creations">YouTube</a></li>
<li><a href="//steamcommunity.com/groups/flashiinet" target="_blank" title="Our Steam group, play games with other members on the site">Steam</a></li> <li><a href="//steamcommunity.com/groups/flashiinet" target="_blank" title="Our Steam group, play games with other members on the site">Steam</a></li>
<li><a href="https://github.com/circlestorm" target="_blank" title="Our Open Source repository thing">Github</a></li> <li><a href="https://bitbucket.org/circlestorm" target="_blank" title="Our Open Source repository thing">BitBucket</a></li>
</ul> </ul>
<ul class="ftsection"> <ul class="ftsection">
<li class="fthead">Information</li> <li class="fthead">Information</li>

View file

@ -15,10 +15,10 @@
<div class="content profile"> <div class="content profile">
<div class="{% if profile.profilePage|length > 1 %}content-right {% endif %}content-column"> <div class="{% if profile.profilePage|length > 1 %}content-right {% endif %}content-column">
<div style="text-align: center;"> <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 %};" /> <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 %};" /><br />
<br /><span style="font-size: .8em;">{{ profile.ranktitle }}</span> {% if profile.user.rank_main > 1 and profile.ban_check|length < 1 %}
<span style="font-size: .8em;">{{ profile.ranktitle }}</span>
<h1 style="color: {{ profile.colour }}; text-shadow: 0 0 7px #888; padding: 0 0 2px;">{{ profile.user.username }}</h1> <h1 style="color: {{ profile.colour }}; text-shadow: 0 0 7px #888; padding: 0 0 2px;">{{ profile.user.username }}</h1>
{% if profile.user.rank_main > 1 %}
{% if profile.is_premium %}<img src="//{{ sakura.urls.content }}/images/tenshi.png" alt="Tenshi" /> {% endif %}<img src="//{{ sakura.urls.content }}/images/flags/{% if profile.user.country|lower == 'eu' %}europeanunion{% else %}{{ profile.user.country|lower }}{% endif %}.png" alt="{{ profile.user.country }}" /> <span style="font-size: .9em; line-height: 11px;">{{ profile.country }}</span> {% if profile.is_premium %}<img src="//{{ sakura.urls.content }}/images/tenshi.png" alt="Tenshi" /> {% endif %}<img src="//{{ sakura.urls.content }}/images/flags/{% if profile.user.country|lower == 'eu' %}europeanunion{% else %}{{ profile.user.country|lower }}{% endif %}.png" alt="{{ profile.user.country }}" /> <span style="font-size: .9em; line-height: 11px;">{{ profile.country }}</span>
{% if user.checklogin %} {% if user.checklogin %}
<div class="user-actions"> <div class="user-actions">
@ -68,17 +68,21 @@
<b>Log in to view the full profile!</b> <b>Log in to view the full profile!</b>
{% endif %} {% endif %}
{% endif %} {% endif %}
{% else %}
<h1 style="color: #222; text-shadow: 0 0 7px #888; padding: 0 0 2px;">{{ profile.user.username }}</h1>
{% endif %} {% endif %}
<hr class="default" /> <hr class="default" />
<b>Account Standing</b> <b>Account Standing</b>
{% if profile.user.rank_main < 2 %} {% if profile.user.rank_main < 2 %}
<h2 style="color: #888; text-shadow: 0 0 7px #888; margin-top: 0;">Deactivated</h2> <h2 style="color: #888; text-shadow: 0 0 7px #888; margin-top: 0;">Deactivated</h2>
{% elseif profile.ban_check %}
<h2 style="color: #222; text-shadow: 0 0 7px #222; margin-top: 0;">Banned</h2>
{% else %} {% else %}
{% if profile.warnings %} {% if profile.warnings %}
<h2 style="color: red; text-shadow: 0 0 7px #888; margin-top: 0;">Bad</h2> <h2 style="color: red; text-shadow: 0 0 7px #888; margin-top: 0;">Bad</h2>
<span style="font-size: 10px; line-height: 10px;">This user has <b>{{ profile.warnings|length }} warning{% if profile.warnings|length != 1 %}s{% endif %}</b>.<br />After 5 to 10 warnings (depending on what they are for) this user may be permanently banned.</span> <span style="font-size: 10px; line-height: 10px;">This user has <b>{{ profile.warnings|length }} warning{% if profile.warnings|length != 1 %}s{% endif %}</b>.<br />After 5 to 10 warnings (depending on what they are for) this user may be permanently banned.</span>
{% else %} {% else %}
<h2 style="color: green; text-shadow: 0 0 7px #888; margin-top: 0;">Good</h2> <h2 style="color: green; text-shadow: 0 0 7px #888; margin-top: 0;">Good</h2>
{% endif %} {% endif %}
{% endif %} {% endif %}
</div> </div>

View file

@ -9,13 +9,13 @@
</div> </div>
<div class="settings-explanation"> <div class="settings-explanation">
<div>Your avatar which is displayed all over the site and on your profile.</div> <div>Your avatar which is displayed all over the site and on your profile.</div>
<div>Maximum image size is 500x500, minimum image size is 20x20, maximum file size is 10 MB.</div> <div>Maximum image size is {{ avatar.max_width }}x{{ avatar.max_height }}, minimum image size is {{ avatar.min_width }}x{{ avatar.min_height }}, maximum file size is {{ avatar.max_size_view }}.</div>
</div> </div>
<form enctype="multipart/form-data" method="post" action="{{ setting.action }}"> <form enctype="multipart/form-data" method="post" action="{{ setting.action }}">
<input type="hidden" name="sessid" value="{{ php.session }}" /> <input type="hidden" name="sessid" value="{{ php.sessionid }}" />
<input type="hidden" name="timestamp" value="{{ php.time }}" /> <input type="hidden" name="timestamp" value="{{ php.time }}" />
<input type="hidden" name="mode" value="avatar" /> <input type="hidden" name="mode" value="avatar" />
<input type="hidden" name="MAX_FILE_SIZE" value="10000000" /> <input type="hidden" name="MAX_FILE_SIZE" value="{{ avatar.max_size }}" />
<div style="text-align: center;"> <div style="text-align: center;">
<div> <div>
<img src="/a/{{ user.data.id }}" alt="Your Avatar" class="default-avatar-setting" /> <img src="/a/{{ user.data.id }}" alt="Your Avatar" class="default-avatar-setting" />

View file

@ -10,8 +10,52 @@
<div class="settings-explanation"> <div class="settings-explanation">
Welcome to the Settings Panel. From here you can monitor, view and update your profile and preferences. Welcome to the Settings Panel. From here you can monitor, view and update your profile and preferences.
</div> </div>
<h1 class="stylised" style="line-height: 1.8em; text-align: center;">Select an option from the menu on the right!</h1> <div style="margin: 5px;">
<h3 style="text-align: center;">Some parts may require you to click a confirmation code sent to you in an e-mail, this is to ensure the security of your identity on the site.</h3> <h1 class="stylised">Common Tasks</h1>
<h2>Profile</h2>
<ul>
<li><a href="/settings/avatar" class="default">Change Avatar</a></li>
<li><a href="/settings/userpage" class="default">Change Userpage</a></li>
<li><a href="/settings/signature" class="default">Change Signature</a></li>
<li><a href="/settings/profile" class="default">Change Profile Details</a></li>
</ul>
<h2>Messaging</h2>
<ul>
<li><a href="/messages/index" class="default">View Inbox</a></li>
<li><a href="/messages/compose" class="default">Send PM</a></li>
</ul>
<h2>Account</h2>
<ul>
<li><a href="/settings/sessions" class="default">Manage Active Sessions</a></li>
<li><a href="/settings/password" class="default">Change Password</a></li>
</ul>
<br />
<h1 class="stylised">Personal Statistics</h1>
<ul>
<li>You joined on <b>{{ user.data.regdate|date(sakura.date_format) }}</b>.</li>
<li>You have made <b>{{ settings.forum_stats.posts }} forum post{% if settings.forum_stats.posts != 1 %}s{% endif %}</b> and started <b>{{ settings.forum_stats.topics }} forum thread{% if settings.forum_stats.topics != 1 %}s{% endif %}</b>.</li>
<li>You have <b>x</b> warnings.</li>
<li>You have <b>{{ settings.friends|length - (settings.friends.online ? 1 : 0) - (settings.friends.offline ? 1 : 0) }} friend{% if settings.friends|length - (settings.friends.online ? 1 : 0) - (settings.friends.offline ? 1 : 0) != 1 %}s{% endif %}</b>.</li>
</ul>
<br />
<h1 class="stylised"><a class="clean" href="/settings/friendlisting">Friends</a></h1>
<h2 style="color: #080;">Online</h2>
{% if settings.friends.online %}
{% for key,friend in settings.friends.online %}
<a href="/u/{{ friend.user.username }}" class="default" style="color: {% if friend.user.name_colour %}{{ friend.user.name_colour }}{% else %}{{ friend.rank.colour }}{% endif %}">{{ friend.user.username }}</a>{% if key + 1 != settings.friends.online|length %},{% endif %}
{% endfor %}
{% else %}
<h4>No friends are online.</h4>
{% endif %}
<h2 style="color: #800;">Offline</h2>
{% if settings.friends.offline %}
{% for key,friend in settings.friends.offline %}
<a href="/u/{{ friend.user.username }}" class="default" style="color: {% if friend.user.name_colour %}{{ friend.user.name_colour }}{% else %}{{ friend.rank.colour }}{% endif %}">{{ friend.user.username }}</a>{% if key + 1 != settings.friends.offline|length %},{% endif %}
{% endfor %}
{% else %}
<h4>No friends are offline.</h4>
{% endif %}
</div>
</div> </div>
<div class="clear"></div> <div class="clear"></div>
</div> </div>

View file

@ -949,9 +949,10 @@ a.gotop.exit {
font-family: "SegoeUI", "Segoe UI", sans-serif; font-family: "SegoeUI", "Segoe UI", sans-serif;
overflow-y: auto; overflow-y: auto;
overflow-x: hidden; overflow-x: hidden;
max-height: 510px; max-height: 100%;
max-width: 600px; max-width: 600px;
text-align: right; text-align: right;
pointer-events: none;
} }
#notifications > div { #notifications > div {
@ -967,6 +968,7 @@ a.gotop.exit {
margin: 5px; margin: 5px;
position: relative; position: relative;
box-shadow: 0 0 4px rgba(0, 0, 0, .9); box-shadow: 0 0 4px rgba(0, 0, 0, .9);
pointer-events: auto;
} }
#notifications > .notification-enter { #notifications > .notification-enter {
@ -1036,6 +1038,80 @@ a.gotop.exit {
display: block; display: block;
} }
@media (max-width: 600px) {
#notifications {
top: 0px;
right: 0px;
left: 0px;
bottom: none;
max-width: 100%;
height: auto;
width: auto;
}
#notifications > div {
height: 40px;
width: 100%;
background: rgba(113, 74, 150, 1);
border: 0;
margin: 0 !important;
box-shadow: 0 0 0;
float: left;
}
#notifications > div > .notification-icon {
width: 40px;
height: 40px;
text-align: center;
}
#notifications > div > .notification-icon > img {
max-height: 40px;
max-width: 40px;
}
#notifications > div > .notification-icon > .font-icon {
margin: .34em 0;
font-size: 2em;
}
#notifications > div > .notification-content {
max-width: 100%;
min-width: 0;
width: auto;
border-left: 0;
height: 40px;
margin: 0;
padding-left: 4px;
display: inline-block;
}
#notifications > div > .notification-content > .notification-title {
font-weight: 700;
font-size: 1em;
margin: 0;
}
#notifications > div > .notification-close {
height: 40px;
width: 40px;
margin: 0;
padding: 0;
border: 0;
line-height: 1.5em;
text-align: center;
margin-right: 4px;
display: block;
}
#notifications > div > .notification-close:after {
clear: both !important;
float: none;
}
}
/* /*
* Private Messages Styling * Private Messages Styling
*/ */
@ -1204,6 +1280,10 @@ a.gotop.exit {
/* /*
* Settings page styling * Settings page styling
*/ */
.settings ul > li {
margin-left: 2em;
list-style: square;
}
.settings .right-menu-nav > div { .settings .right-menu-nav > div {
background: #C2AFFE; background: #C2AFFE;
padding: 4px; padding: 4px;

View file

@ -230,9 +230,6 @@ function notifyRequest(session) {
"sound": false "sound": false
}); });
// ...and log an error message to to console..
console.log('[SAKURA NOTIFICATION DEBUG] Invalid return type.');
// ...then prevent the function from contiuing // ...then prevent the function from contiuing
return; return;
@ -256,9 +253,6 @@ function notifyRequest(session) {
"sound": false "sound": false
}); });
// ...and log a thing to the JavaScript console
console.log('[SAKURA NOTIFICATION DEBUG] HTTP return wasn\'t 200.');
} }
} }

Binary file not shown.

After

Width:  |  Height:  |  Size: 506 B

View file

@ -45,7 +45,7 @@ if(isset($_GET['m'])) {
} }
// Check if user is banned // Check if user is banned
if(false) { // [Flashwave 2015-04-27] Banning isn't implemented yet if(Bans::checkBan($_GET['u'])) {
$serveImage = $bannedAvatar; $serveImage = $bannedAvatar;
break; break;
} }
@ -80,7 +80,7 @@ if(isset($_GET['m'])) {
} }
// Check if user is banned // Check if user is banned
if(false) { // [Flashwave 2015-04-27] Banning isn't implemented yet if(Bans::checkBan($_GET['u'])) {
$serveImage = $noBackground; $serveImage = $noBackground;
break; break;
} }
@ -115,7 +115,7 @@ if(isset($_GET['m'])) {
} }
// Check if user is banned // Check if user is banned
if(false) { // [Flashwave 2015-04-27] Banning isn't implemented yet if(Bans::checkBan($_GET['u'])) {
$serveImage = $noHeader; $serveImage = $noHeader;
break; break;
} }

View file

@ -25,7 +25,8 @@ if(isset($_GET['u'])) {
'fields' => Users::getUserProfileFields($_PROFILE_USER_DATA['userData'], true), 'fields' => Users::getUserProfileFields($_PROFILE_USER_DATA['userData'], true),
'warnings' => Users::getWarnings($_PROFILE_USER_DATA['id']), 'warnings' => Users::getWarnings($_PROFILE_USER_DATA['id']),
'friend' => Users::checkFriend($_PROFILE_USER_DATA['id']), 'friend' => Users::checkFriend($_PROFILE_USER_DATA['id']),
'forum_stats' => Forum::getUserStats($_PROFILE_USER_DATA['id']) 'forum_stats' => Forum::getUserStats($_PROFILE_USER_DATA['id']),
'ban_check' => Bans::checkBan($_PROFILE_USER_DATA['id'])
]; ];
$renderData['page'] = [ $renderData['page'] = [

View file

@ -203,7 +203,6 @@ if(isset($_REQUEST['request-notifications']) && $_REQUEST['request-notifications
} elseif(isset($_POST['submit']) && isset($_POST['submit'])) { } elseif(isset($_POST['submit']) && isset($_POST['submit'])) {
// Continue
$continue = true; $continue = true;
// Check if the user is logged in // Check if the user is logged in
@ -216,8 +215,7 @@ if(isset($_REQUEST['request-notifications']) && $_REQUEST['request-notifications
'success' => 0 'success' => 0
]; ];
// Break break;
$continue = false;
} }
@ -231,8 +229,7 @@ if(isset($_REQUEST['request-notifications']) && $_REQUEST['request-notifications
'success' => 0 'success' => 0
]; ];
// Break break;
$continue = false;
} }
@ -242,6 +239,193 @@ if(isset($_REQUEST['request-notifications']) && $_REQUEST['request-notifications
// Switch to the correct mode // Switch to the correct mode
switch($_POST['mode']) { switch($_POST['mode']) {
// Avatar
case 'avatar':
// Set path variables
$filepath = ROOT .'content/images/user/';
$filename = $filepath .'avatar_'. Session::$userId;
// Check if $_FILES is set
if(!isset($_FILES['avatar']) && empty($_FILES['avatar'])) {
// Set render data
$renderData['page'] = [
'title' => 'Avatar',
'redirect' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/settings',
'message' => 'No file was uploaded.',
'success' => 0
];
break;
}
// Check if the upload went properly
if($_FILES['avatar']['error'] !== UPLOAD_ERR_OK) {
// Get the error in text
switch($_FILES['avatar']['error']) {
case UPLOAD_ERR_INI_SIZE:
case UPLOAD_ERR_FORM_SIZE:
$msg = 'The uploaded file exceeds the maximum filesize!';
break;
case UPLOAD_ERR_PARTIAL:
case UPLOAD_ERR_NO_FILE:
$msg = 'The upload was interrupted!';
break;
case UPLOAD_ERR_NO_TMP_DIR:
case UPLOAD_ERR_CANT_WRITE:
$msg = 'Unable to save file to temporary location, contact the administrator!';
break;
case UPLOAD_ERR_EXTENSION:
default:
$msg = 'An unknown exception occurred!';
break;
}
// Set render data
$renderData['page'] = [
'title' => 'Avatar',
'redirect' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/settings',
'message' => $msg,
'success' => 0
];
break;
}
// Get the meta data
$metadata = getimagesize($_FILES['avatar']['tmp_name']);
// Check if the image is actually an image
if($metadata == false) {
// Set render data
$renderData['page'] = [
'title' => 'Avatar',
'redirect' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/settings',
'message' => 'Uploaded file is not an image.',
'success' => 0
];
break;
}
// Check if the image is an allowed filetype
if((($metadata[2] !== IMAGETYPE_GIF) && ($metadata[2] !== IMAGETYPE_JPEG) && ($metadata[2] !== IMAGETYPE_PNG))) {
// Set render data
$renderData['page'] = [
'title' => 'Avatar',
'redirect' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/settings',
'message' => 'This filetype is not allowed.',
'success' => 0
];
break;
}
// Check if the image is too large
if(($metadata[0] > Configuration::getConfig('avatar_max_width') || $metadata[1] > Configuration::getConfig('avatar_max_height'))) {
// Set render data
$renderData['page'] = [
'title' => 'Avatar',
'redirect' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/settings',
'message' => 'The resolution of this picture is too big.',
'success' => 0
];
break;
}
// Check if the image is too small
if(($metadata[0] < Configuration::getConfig('avatar_min_width') || $metadata[1] < Configuration::getConfig('avatar_min_height'))) {
// Set render data
$renderData['page'] = [
'title' => 'Avatar',
'redirect' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/settings',
'message' => 'The resolution of this picture is too small.',
'success' => 0
];
break;
}
// Check if the file is too large
if((filesize($_FILES['avatar']['tmp_name']) > Configuration::getConfig('avatar_max_fsize'))) {
// Set render data
$renderData['page'] = [
'title' => 'Avatar',
'redirect' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/settings',
'message' => 'The filesize of this picture is too large.',
'success' => 0
];
break;
}
// Append extension to filename
$filename .= image_type_to_extension($metadata[2]);
if(!move_uploaded_file($_FILES['avatar']['tmp_name'], $filename)) {
// Set render data
$renderData['page'] = [
'title' => 'Avatar',
'redirect' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/settings',
'message' => 'Something went wrong, please try again.',
'success' => 0
];
}
// Update database
Users::updateUserDataField(Session::$userId, ['userAvatar' => basename($filename)]);
// Set render data
$renderData['page'] = [
'title' => 'Avatar',
'redirect' => isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : '/settings',
'message' => 'Updated your avatar!',
'success' => 1
];
break;
// Profile // Profile
case 'profile': case 'profile':
@ -282,7 +466,7 @@ if(isset($_REQUEST['request-notifications']) && $_REQUEST['request-notifications
} }
// Update database // Update database
Users::updateUserProfileFields(Session::$userId, $store); Users::updateUserDataField(Session::$userId, ['profileFields' => $store]);
// Set render data // Set render data
$renderData['page'] = [ $renderData['page'] = [
@ -338,12 +522,12 @@ if(Users::checkLogin()) {
'home' => ['General', 'Home'], 'home' => ['General', 'Home'],
'profile' => ['General', 'Edit Profile'], 'profile' => ['General', 'Edit Profile'],
'groups' => ['General', 'Groups'], 'groups' => ['General', 'Groups'],
'friends' => ['Friends', 'List'], 'friendlisting' => ['Friends', 'List'],
'friendrequests' => ['Friends', 'Requests'], 'friendrequests' => ['Friends', 'Requests'],
'notifications' => ['Notifications', 'History'], 'notifications' => ['Notifications', 'History'],
'avatar' => ['Aesthetics', 'Avatar'], 'avatar' => ['Aesthetics', 'Avatar'],
'background' => ['Aesthetics', 'Background'], 'background' => ['Aesthetics', 'Background'],
'page' => ['Aesthetics', 'Profile Page'], 'userpage' => ['Aesthetics', 'Userpage'],
'email' => ['Account', 'E-mail Address'], 'email' => ['Account', 'E-mail Address'],
'username' => ['Account', 'Username'], 'username' => ['Account', 'Username'],
'usertitle' => ['Account', 'User Title'], 'usertitle' => ['Account', 'User Title'],
@ -367,6 +551,26 @@ if(Users::checkLogin()) {
// Section specific // Section specific
switch($currentPage) { switch($currentPage) {
// Homepage
case 'home':
$renderData['settings'] = [
'friends' => Users::getFriends(null, true, true, true),
'forum_stats' => Forum::getUserStats(Session::$userId)
];
break;
// Avatar sizes
case 'avatar':
$renderData['avatar'] = [
'max_width' => Configuration::getConfig('avatar_max_width'),
'max_height' => Configuration::getConfig('avatar_max_height'),
'min_width' => Configuration::getConfig('avatar_min_width'),
'min_height' => Configuration::getConfig('avatar_min_height'),
'max_size' => Configuration::getConfig('avatar_max_fsize'),
'max_size_view' => Main::getByteSymbol(Configuration::getConfig('avatar_max_fsize'))
];
break;
// Profile // Profile
case 'profile': case 'profile':
$renderData['profile'] = [ $renderData['profile'] = [
@ -376,7 +580,7 @@ if(Users::checkLogin()) {
break; break;
// Friends // Friends
case 'friends': case 'friendlisting':
$renderData['friends'] = array_chunk(array_reverse(Users::getFriends(null, true, true)), 12, true); $renderData['friends'] = array_chunk(array_reverse(Users::getFriends(null, true, true)), 12, true);
break; break;