diff --git a/_sakura/changelog.json b/_sakura/changelog.json index beeb7d2..b642d04 100644 --- a/_sakura/changelog.json +++ b/_sakura/changelog.json @@ -47,7 +47,8 @@ "20150819", "20150820", "20150821", - "20150822" + "20150822", + "20150823" ] @@ -2191,6 +2192,66 @@ "user": "Flashwave" } + ], + + "20150823": [ + + { + "type": "REM", + "change": "Removed a reference to the legacy password hashing method in Users::checkLogin().", + "user": "Flashwave" + }, + { + "type": "ADD", + "change": "Added repeated linear gradient to the JavaScript message because I could.", + "user": "Flashwave" + }, + { + "type": "FIX", + "change": "Fixed broken reference to current page variable in the logout link.", + "user": "Flashwave" + }, + { + "type": "UPD", + "change": "Rewrite settings page handling.", + "user": "Flashwave" + }, + { + "type": "UPD", + "change": "Merge messages.php and settings.php.", + "user": "Flashwave" + }, + { + "type": "ADD", + "change": "Add special cases for restricted users.", + "user": "Flashwave" + }, + { + "type": "UPD", + "change": "Restructured the startup process.", + "user": "Flashwave" + }, + { + "type": "FIX", + "change": "Fixed checkboxes not working properly in the AJAX submission function.", + "user": "Flashwave" + }, + { + "type": "ADD", + "change": "Add user controlled ability to switch to Misaki.", + "user": "Flashwave" + }, + { + "type": "FIX", + "change": "Fix profiles on Misaki.", + "user": "Flashwave" + }, + { + "type": "ADD", + "change": "Quickly backport the required templates to switch back to the Yuuno template.", + "user": "Flashwave" + } + ] } diff --git a/_sakura/components/Main.php b/_sakura/components/Main.php index d67491e..bc04ea0 100644 --- a/_sakura/components/Main.php +++ b/_sakura/components/Main.php @@ -2,7 +2,7 @@ /* * Main Class */ - + namespace Sakura; use Parsedown; @@ -10,16 +10,9 @@ use PHPMailer; class Main { - public static $_MD; // Markdown class container - public static $_MANAGE_MODE = false; // Management mode - // Constructor public static function init($config) { - // Stop the execution if the PHP Version is older than 5.4.0 - if(version_compare(phpversion(), '5.4.0', '<')) - trigger_error('Sakura requires at least PHP 5.4.0, please upgrade to a newer PHP version.'); - // Configuration Management and local configuration Configuration::init($config); @@ -32,35 +25,12 @@ class Main { // Create new session Session::init(); - // Check if management mode was requested - self::$_MANAGE_MODE = defined('SAKURA_MANAGE'); - - // Templating engine - if(!defined('SAKURA_NO_TPL')) { - - Templates::init(self::$_MANAGE_MODE ? Configuration::getConfig('manage_style') : Configuration::getConfig('site_style')); - - } - - // Assign servers file to whois class - Whois::setServers(ROOT .'_sakura/'. Configuration::getLocalConfig('data', 'whoisservers')); - - // Markdown Parser - self::initMD(); - - } - - // Initialise Parsedown - private static function initMD() { - - self::$_MD = new Parsedown(); - } // Parse markdown public static function mdParse($text) { - return self::$_MD->text($text); + return (new Parsedown())->text($text); } @@ -767,7 +737,7 @@ class Main { // Return the string return $round .' '. $times[$secs] . ($round == 1 ? '' : 's') .' ago'; - } + } } diff --git a/_sakura/components/Permissions.php b/_sakura/components/Permissions.php index e5d5d25..b61ade3 100644 --- a/_sakura/components/Permissions.php +++ b/_sakura/components/Permissions.php @@ -40,7 +40,7 @@ class Permissions { 'CHANGE_USERNAME' => 4096, // Can change their username 'CHANGE_USERTITLE' => 8192, // Can change their usertitle 'CHANGE_PASSWORD' => 16384, // Can change their password - 'CHANGE_DEFAULT_RANK' => 32768, // Can change their default rank + 'ALTER_RANKS' => 32768, // Can change their ranks 'MANAGE_SESSIONS' => 65536, // Can manage their sessions 'CREATE_REGKEYS' => 131072, // Can create registration keys 'DEACTIVATE_ACCOUNT' => 262144, // Can deactivate their account @@ -51,8 +51,8 @@ class Permissions { 'JOIN_GROUPS' => 8388608, // Can join groups 'CREATE_GROUP' => 16777216, // Can create a group 'MULTIPLE_GROUPS' => 33554432, // Can create multiple groups (requires single group perm) - 'CHANGE_NAMECOLOUR' => 67108864, // Can change their username colour - 'STATIC_PREMIUM' => 134217728 // Can change their username colour + 'CHANGE_NAMECOLOUR' => 67108864, // Can change their username colour + 'STATIC_PREMIUM' => 134217728 // User has static premium status ], diff --git a/_sakura/components/Templates.php b/_sakura/components/Templates.php index c94c23e..7b581a0 100644 --- a/_sakura/components/Templates.php +++ b/_sakura/components/Templates.php @@ -26,16 +26,22 @@ class Templates { $confPath = ROOT .'_sakura/templates/'. self::$_TPL .'/template.ini'; // Check if the configuration file exists - if(!file_exists($confPath)) + if(!file_exists($confPath)) { + trigger_error('Template configuration does not exist', E_USER_ERROR); + } + // Parse and store the configuration self::$_CFG = parse_ini_file($confPath, true); // Make sure we're not using a manage template for the main site or the other way around - if((bool)self::$_CFG['manage']['mode'] != (bool)Main::$_MANAGE_MODE) + if(defined('SAKURA_MANAGE') && (bool)self::$_CFG['manage']['mode'] != (bool)SAKURA_MANAGE) { + trigger_error('Incorrect template type', E_USER_ERROR); + } + // Start Twig self::twigLoader(); diff --git a/_sakura/components/User.php b/_sakura/components/User.php index 2191da4..1a7c5ed 100644 --- a/_sakura/components/User.php +++ b/_sakura/components/User.php @@ -134,6 +134,13 @@ class User { } + // Get all the friend of this user + public function getFriends() { + + return Users::getFriends($this->data['id']); + + } + // Check if the user is banned public function checkBan() { diff --git a/_sakura/components/Users.php b/_sakura/components/Users.php index 10a04ae..207f271 100644 --- a/_sakura/components/Users.php +++ b/_sakura/components/Users.php @@ -47,13 +47,19 @@ class Users { public static function checkLogin($uid = null, $sid = null, $bypassCookies = false) { // Set $uid and $sid if they're null - if($uid == null) + if($uid == null) { + $uid = Session::$userId; + } + // ^ - if($sid == null) + if($sid == null) { + $sid = Session::$sessionId; + } + // Check if cookie bypass is false if(!$bypassCookies) { @@ -92,10 +98,6 @@ class Users { // Update the premium meta Users::updatePremiumMeta($uid); - // Redirect people that need to change their password to the new format - if(self::getUser($uid)['password_algo'] == 'legacy' && $_SERVER['PHP_SELF'] != '/authenticate.php' && $_SERVER['PHP_SELF'] != '/imageserve.php') - header('Location: /authenticate.php?legacy=true'); - // If everything went through return true return true; diff --git a/_sakura/sakura.php b/_sakura/sakura.php index e58e712..cbd85e6 100644 --- a/_sakura/sakura.php +++ b/_sakura/sakura.php @@ -8,7 +8,7 @@ namespace Sakura; // Define Sakura version -define('SAKURA_VERSION', '20150822'); +define('SAKURA_VERSION', '20150823'); define('SAKURA_VLABEL', 'Eminence'); define('SAKURA_COLOUR', '#6C3082'); define('SAKURA_STABLE', false); @@ -22,6 +22,13 @@ error_reporting(SAKURA_STABLE ? 0 : -1); // Set internal encoding method mb_internal_encoding('utf-8'); +// Stop the execution if the PHP Version is older than 5.4.0 +if(version_compare(phpversion(), '5.4.0', '<')) { + + trigger_error('Sakura requires at least PHP 5.4.0, please upgrade to a newer PHP version.'); + +} + // Include libraries require_once ROOT .'_sakura/vendor/autoload.php'; require_once ROOT .'_sakura/components/Main.php'; @@ -53,6 +60,9 @@ set_error_handler(array('Sakura\Main', 'errorHandler')); // Initialise Main Class Main::init(ROOT .'_sakura/config/config.ini'); +// Assign servers file to whois class +Whois::setServers(ROOT .'_sakura/'. Configuration::getLocalConfig('data', 'whoisservers')); + // Start output buffering ob_start(Configuration::getConfig('use_gzip') ? 'ob_gzhandler' : null); @@ -61,6 +71,20 @@ $currentUser = new User(Session::$userId); if(!defined('SAKURA_NO_TPL')) { + // Initialise templating engine + Templates::init( + defined('SAKURA_MANAGE') ? + Configuration::getConfig('manage_style') : ( + ( + isset($currentUser->data['userData']['userOptions']['useMisaki']) && + $currentUser->data['userData']['userOptions']['useMisaki'] && + $currentUser->checkPermission('SITE', 'ALTER_PROFILE') + ) ? + 'misaki' : + Configuration::getConfig('site_style') + ) + ); + // Set base page rendering data $renderData = [ diff --git a/_sakura/templates/misaki/elements/settingsNavigation.tpl b/_sakura/templates/misaki/elements/settingsNavigation.tpl new file mode 100644 index 0000000..9c436bd --- /dev/null +++ b/_sakura/templates/misaki/elements/settingsNavigation.tpl @@ -0,0 +1 @@ +

Go to Site Options

diff --git a/_sakura/templates/misaki/errors/information.tpl b/_sakura/templates/misaki/errors/information.tpl new file mode 100644 index 0000000..d1541a8 --- /dev/null +++ b/_sakura/templates/misaki/errors/information.tpl @@ -0,0 +1,8 @@ +{% include 'global/header.tpl' %} +
+

Information

+
+ {{ page.message }} + {% if page.redirect %}
Click here if you aren't being redirected.{% endif %} +
+{% include 'global/footer.tpl' %} diff --git a/_sakura/templates/misaki/global/footer.tpl b/_sakura/templates/misaki/global/footer.tpl index 90d7df7..a9af043 100644 --- a/_sakura/templates/misaki/global/footer.tpl +++ b/_sakura/templates/misaki/global/footer.tpl @@ -4,8 +4,8 @@
-
Copyright © 2013-2015 Flashwave & Circlestorm, et al.
-
Terms of Service | Contact | FAQ | Feedback | Rules | Changelog | Status
+
Copyright © 2013-2015 Flashwave & Circlestorm, et al.
+
Terms of Service | Contact | FAQ | Feedback | Rules | Changelog | Status
diff --git a/_sakura/templates/misaki/global/header.tpl b/_sakura/templates/misaki/global/header.tpl index eb99aaa..efc411d 100644 --- a/_sakura/templates/misaki/global/header.tpl +++ b/_sakura/templates/misaki/global/header.tpl @@ -7,9 +7,26 @@ + + + {% if page.redirect %} {% endif %} + + + + + + + + + + + + + + {% if page.style %} @@ -25,6 +42,41 @@ {% endif %} +
@@ -48,15 +100,15 @@
- {% if profile.user.userData.profileBackground %} -
+ {% if php.self == '/profile.php' ? profile.data.userData.profileBackground : (user.checkPermission('SITE', 'CREATE_BACKGROUND') and user.data.userData.userOptions.profileBackgroundSiteWide and user.data.userData.profileBackground) %} +
{% endif %}
diff --git a/_sakura/templates/misaki/main/profile.tpl b/_sakura/templates/misaki/main/profile.tpl index c39ca2f..0af7de6 100644 --- a/_sakura/templates/misaki/main/profile.tpl +++ b/_sakura/templates/misaki/main/profile.tpl @@ -1,138 +1,150 @@ {% include 'global/header.tpl' %} -{% if profile.notset or profile.user.id == 0 or profile.user.password_algo == 'nologin' %} -user not found, don't forget to make this sexy -{% else %} -
-
-
-
- {{ profile.user.username }}'s Avatar -
-
- {{ profile.user.username }} -
-
- {{ profile.ranktitle }} -
-
-
-
-
Joined {{ profile.user.regdate|date("l Y-m-d H:i T") }}
-
{% if profile.user.lastdate == 0 %}User hasn't logged in yet.{% else %}Last Active {{ profile.user.lastdate|date("l Y-m-d H:i T") }}{% endif %}
-
-
+ {% if profile.checkPermission('SITE', 'DEACTIVATED') or profile.data.password_algo == 'nologin' or (profile.checkPermission('SITE', 'RESTRICTED') and (user.data.id != profile.data.id and not user.checkPermission('MANAGE', 'USE_MANAGE'))) %} +
+

user not found!

+ There are a few possible reasons for this: +
    +
  • They changed their username.
  • +
  • They may have been abyss'd.
  • +
  • You made a typo.
  • +
  • They never existed.
  • +
-
-
- {% if profile.user.rank_main > 1 %} -
-
-
    -
  • Tenshi
  • -
  • Staff
  • -
  • Developer
  • -
  • Alumnii
  • -
-
-
-
-
- {% if user.checklogin %} - {% if profile.fields %} - {% for name,field in profile.fields %} -
-
{{ field.name }}
- -
+ {% else %} +
+
+
+
+ {{ profile.data.username }}'s Avatar +
+
+ {{ profile.data.username }}
- {% endfor %} - {% else %} -
-
-
This user has not set any accounts yet.
+
+ {{ profile.userTitle }}
- {% endif %} - {% else %} -
-
-
Log in to view the full profile.
-
- {% endif %} -
-
- {% endif %} -
-
-
Account Standing
-
Deactivated - {% else %} - {% if profile.warnings %} - #F22;">Bad - {% else %} - #2F2;">Good - {% endif %} - {% endif %}
- {% if profile.warnings %} -
This user has {{ profile.warnings|length }} warning{% if profile.warnings|length != 1 %}s{% endif %}!
-
After 10 warnings a user may be permanently banned.
- {% endif %}
-
-
-
- {% if profile.user.rank_main > 1 %} -
- - -
- +
+
Joined {{ profile.data.regdate|date(sakura.dateFormat) }}
+
{% if profile.data.lastdate == 0 %}User hasn't logged in yet.{% else %}Last Active {{ profile.data.lastdate|date(sakura.dateFormat) }}{% endif %}
-
-
{{ profile.profilePage|raw }}
+
+
+ {% if not profile.checkPermission('SITE', 'DEACTIVATED') and (profile.checkPremium[0] or profile.checkPermission('MANAGE', 'USE_MANAGE')) %} +
+
+
    + {% if profile.checkPremium[0] %} +
  • Tenshi
  • + {% endif %} + {% if profile.checkPermission('MANAGE', 'USE_MANAGE') %} +
  • Staff
  • + {% endif %} + {% if false %} +
  • Developer
  • + {% endif %} + {% if false %} +
  • Alumnii
  • + {% endif %} +
+
+
+
+
+ {% if session.checkLogin %} + {% if profile.profileFields %} + {% for name,field in profile.profileFields %} +
+
{{ field.name }}
+ +
+
+ {% endfor %} + {% else %} +
+
+
This user has not set any links yet.
+
+ {% endif %} + {% else %} +
+
+
Log in to view the full profile.
+
+ {% endif %} +
+
+ {% endif %} +
+
+
Account Standing
+ {% if profile.checkPermission('SITE', 'DEACTIVATED') %} +
Deactivated
+ {% elseif profile.checkBan %} +

Banned

+ {% else %} + {% if profile.getWarnings %} +
Bad
+ {% else %} +
Good
+ {% endif %} + {% endif %} + {% if profile.getWarnings %} +
This user has {{ profile.getWarnings|length }} warning{% if profile.getWarnings|length != 1 %}s{% endif %}!
+
After 10 warnings a user may be permanently banned.
+ {% endif %} +
+
+
+ +
- {% endif %}
-
-
-
-{% if profile.user.userData.profileBackground %} - -{% endif %} -{% endif %} + {% endif %} {% include 'global/footer.tpl' %} diff --git a/_sakura/templates/misaki/main/settings.tpl b/_sakura/templates/misaki/main/settings.tpl new file mode 100644 index 0000000..ed2aa95 --- /dev/null +++ b/_sakura/templates/misaki/main/settings.tpl @@ -0,0 +1,19 @@ +{% include 'global/header.tpl' %} +
+
+ {% include 'elements/settingsNavigation.tpl' %} +
+
+
+ {{ page.title }} +
+
+ {% for descline in page.description %} +
{{ include(template_from_string(descline)) }}
+ {% endfor %} +
+ {% include 'settings/' ~ current ~ '.tpl' %} +
+
+
+{% include 'global/footer.tpl' %} diff --git a/_sakura/templates/misaki/settings/general.home.tpl b/_sakura/templates/misaki/settings/general.home.tpl new file mode 100644 index 0000000..27fb5a4 --- /dev/null +++ b/_sakura/templates/misaki/settings/general.home.tpl @@ -0,0 +1,2 @@ +

READ THIS BEFORE PUKING

+These template files were quickly thrown into place to allow switching between the development style and the stable one. You can switch in the Site Options section. diff --git a/_sakura/templates/misaki/settings/general.options.tpl b/_sakura/templates/misaki/settings/general.options.tpl new file mode 100644 index 0000000..69b96ab --- /dev/null +++ b/_sakura/templates/misaki/settings/general.options.tpl @@ -0,0 +1,26 @@ +{% if options.fields %} +
+ + + + {% for field in options.fields %} +
+
+

{{ field.name }}

+
+ {{ field.description }} +
+
+
+ +
+
+ {% endfor %} +
+ + +
+
+{% else %} +

There are currently no changeable options.

+{% endif %} diff --git a/_sakura/templates/yuuno/elements/settingsNav.tpl b/_sakura/templates/yuuno/elements/settingsNav.tpl index fa50e95..f90a2e2 100644 --- a/_sakura/templates/yuuno/elements/settingsNav.tpl +++ b/_sakura/templates/yuuno/elements/settingsNav.tpl @@ -2,40 +2,12 @@ Navigation
-
General
- Home - Edit Profile - Site Options - Groups -
Friends
- List - Requests -
Messages
- Inbox - Sent - Compose -
Notifications
- History - {% if ((user.data.userData.userPage is defined and user.checkPermission('SITE', 'CHANGE_USERPAGE')) or user.checkPermission('SITE', 'CREATE_USERPAGE')) or user.checkPermission('SITE', 'CHANGE_AVATAR') or ((user.data.userData.userPage is defined and user.checkPermission('SITE', 'CHANGE_USERPAGE')) or user.checkPermission('SITE', 'CREATE_USERPAGE')) %} -
Aesthetics
- {% if user.checkPermission('SITE', 'CHANGE_AVATAR') %} - Avatar - {% endif %} - {% if (user.data.userData.profileBackground is defined and user.checkPermission('SITE', 'CHANGE_BACKGROUND')) or user.checkPermission('SITE', 'CREATE_BACKGROUND') %} - Background - {% endif %} - {% if (user.data.userData.userPage is defined and user.checkPermission('SITE', 'CHANGE_USERPAGE')) or user.checkPermission('SITE', 'CREATE_USERPAGE') %} - Userpage - {% endif %} - {% endif %} -
Account
- E-mail Address - Username - User Title - Password - Ranks -
Danger zone
- Sessions - Registration Keys - Deactivate Account + {% for catname,category in pages %} +
{{ category.title }}
+ {% for mname,mode in category.modes %} + {% if mode.access %} + {{ mode.title }} + {% endif %} + {% endfor %} + {% endfor %}
diff --git a/_sakura/templates/yuuno/global/header.tpl b/_sakura/templates/yuuno/global/header.tpl index 529cadf..18bbd06 100644 --- a/_sakura/templates/yuuno/global/header.tpl +++ b/_sakura/templates/yuuno/global/header.tpl @@ -9,7 +9,7 @@ - + {% if page.redirect %} {% endif %} @@ -147,7 +147,7 @@ } {% endif %} - {% if php.self == '/profile.php' ? profile.data.userData.profileBackground : (user.checkPermission('SITE', 'CREATE_BACKGROUND') and user.data.userData.userOptions.profileBackgroundSiteWide == 'true' and user.data.userData.profileBackground) %} + {% if php.self == '/profile.php' ? profile.data.userData.profileBackground : (user.checkPermission('SITE', 'CREATE_BACKGROUND') and user.data.userData.userOptions.profileBackgroundSiteWide and user.data.userData.profileBackground) %} initialiseParallax('userBackground'); {% endif %} @@ -165,7 +165,9 @@ Home News Chat - Forums + {% if user.checkPermission('FORUM', 'USE_FORUM') %} + Forums + {% endif %} Search {% if session.checkLogin %} Members @@ -179,7 +181,7 @@ Messages Manage Settings - Logout + Logout {% else %} {% if sakura.lockAuth %} @@ -196,7 +198,7 @@
- {% if php.self == '/profile.php' ? profile.data.userData.profileBackground : (user.checkPermission('SITE', 'CREATE_BACKGROUND') and user.data.userData.userOptions.profileBackgroundSiteWide == 'true' and user.data.userData.profileBackground) %} + {% if php.self == '/profile.php' ? profile.data.userData.profileBackground : (user.checkPermission('SITE', 'CREATE_BACKGROUND') and user.data.userData.userOptions.profileBackgroundSiteWide and user.data.userData.profileBackground) %}
{% endif %} {% if not session.checkLogin and php.self != '/authenticate.php' %} @@ -225,11 +227,11 @@ {% if user.checkPermission('SITE', 'RESTRICTED') %}

Your account is current in restricted mode!

-
A staff member has set your account to restricted mode most likely due to violation of the rules. You will temporarily not be able to use public features of the site. If you think this is a mistake please get in touch with one of our staff members.
+
A staff member has set your account to restricted mode most likely due to violation of the rules. While restricted you won't be able to use most public features of the site. If you think this is a mistake please get in touch with one of our staff members.
{% endif %}
- +
{% endfor %} diff --git a/_sakura/templates/yuuno/settings/general.profile.tpl b/_sakura/templates/yuuno/settings/general.profile.tpl new file mode 100644 index 0000000..5ed0fe9 --- /dev/null +++ b/_sakura/templates/yuuno/settings/general.profile.tpl @@ -0,0 +1,46 @@ +{% if profile.fields %} +
+ + + + {% for field in profile.fields %} +
+
+

{{ field.name }}

+
+
+ +
+ {% if field.addit %} + {% for id,addit in field.addit %} +
+ + +
+ {% endfor %} + {% endif %} +
+ {% endfor %} +
+ + +
+
+ +{% else %} +

There are no changeable profile fields.

+{% endif %} diff --git a/_sakura/templates/yuuno/settings/messages.compose.tpl b/_sakura/templates/yuuno/settings/messages.compose.tpl new file mode 100644 index 0000000..e69de29 diff --git a/_sakura/templates/yuuno/settings/messages.inbox.tpl b/_sakura/templates/yuuno/settings/messages.inbox.tpl new file mode 100644 index 0000000..3414cd0 --- /dev/null +++ b/_sakura/templates/yuuno/settings/messages.inbox.tpl @@ -0,0 +1,23 @@ +{% if messages|length %} + + + + + + + + + + {% for message in messages %} + + + + + + {% endfor %} + +
FromSubjectSent on
{{ message.data.from.user.username }}{{ message.subject }}{{ message.time|date(sakura.dateFormat) }}
+{% else %} +

Nothing to view!

+{% endif %} +

Click Compose in the menu on the right side to write a new message!

diff --git a/_sakura/templates/yuuno/settings/messages.sent.tpl b/_sakura/templates/yuuno/settings/messages.sent.tpl new file mode 100644 index 0000000..e69de29 diff --git a/_sakura/templates/yuuno/settings/notfound.tpl b/_sakura/templates/yuuno/settings/notfound.tpl deleted file mode 100644 index cfb0ada..0000000 --- a/_sakura/templates/yuuno/settings/notfound.tpl +++ /dev/null @@ -1 +0,0 @@ -

Could not find what you were looking for.

diff --git a/_sakura/templates/yuuno/settings/notifications.tpl b/_sakura/templates/yuuno/settings/notifications.history.tpl similarity index 80% rename from _sakura/templates/yuuno/settings/notifications.tpl rename to _sakura/templates/yuuno/settings/notifications.history.tpl index 5197740..0e8663a 100644 --- a/_sakura/templates/yuuno/settings/notifications.tpl +++ b/_sakura/templates/yuuno/settings/notifications.history.tpl @@ -30,13 +30,13 @@
diff --git a/_sakura/templates/yuuno/settings/profile.tpl b/_sakura/templates/yuuno/settings/profile.tpl deleted file mode 100644 index 9196c45..0000000 --- a/_sakura/templates/yuuno/settings/profile.tpl +++ /dev/null @@ -1,42 +0,0 @@ -
- - - - {% for field in profile.fields %} -
-
-

{{ field.name }}

-
-
- -
- {% if field.addit %} - {% for id,addit in field.addit %} -
- - -
- {% endfor %} - {% endif %} -
- {% endfor %} -
- - -
-
- diff --git a/main/.htaccess b/main/.htaccess index 1cbbe6e..df442ed 100644 --- a/main/.htaccess +++ b/main/.htaccess @@ -35,13 +35,14 @@ RewriteRule ^news.xml$ news.php?xml [L,QSA] # Settings RewriteRule ^settings/?$ settings.php [L,QSA] -RewriteRule ^settings/([a-z]+)/?$ settings.php?mode=$1 [L,QSA] -RewriteRule ^settings/([a-z]+)/p([0-9]+)/?$ settings.php?mode=$1&page=$2 [L,QSA] +RewriteRule ^settings/([a-z]+)/?$ settings.php?cat=$1 [L,QSA] +RewriteRule ^settings/([a-z]+)/([a-z]+)/?$ settings.php?cat=$1&mode=$2 [L,QSA] +RewriteRule ^settings/([a-z]+)/([a-z]+)/p([0-9]+)/?$ settings.php?cat=$1&mode=$2&page=$3 [L,QSA] RewriteRule ^friends/?$ settings.php?friend-action=true [L,QSA] # Private Messages -RewriteRule ^messages/?$ messages.php [L,QSA] -RewriteRule ^messages/([a-z]+)/?$ messages.php?mode=$1 [L,QSA] +RewriteRule ^messages/?$ settings.php?cat=messages [L,QSA] +RewriteRule ^messages/([a-z]+)/?$ settings.php?cat=messages&mode=$1 [L,QSA] # Members RewriteRule ^members/?$ members.php [L,QSA] diff --git a/main/404.php b/main/404.php index 4667d25..17082d6 100644 --- a/main/404.php +++ b/main/404.php @@ -9,5 +9,8 @@ namespace Sakura; // Include components require_once str_replace(basename(__DIR__), '', dirname(__FILE__)) .'_sakura/sakura.php'; +// Set 404 header +header('HTTP/1.0 404 Not Found'); + // Print page contents print Templates::render('errors/http404.tpl', $renderData); diff --git a/main/content/data/misaki/css/misaki.css b/main/content/data/misaki/css/misaki.css index b689c40..3a98078 100644 --- a/main/content/data/misaki/css/misaki.css +++ b/main/content/data/misaki/css/misaki.css @@ -367,6 +367,18 @@ a:active { /* * Profiles */ +.userNotFound { + margin: 10px 14px; + font-family: "Exo2-0-LightItalic", sans-serif; + font-size: 1.5em; + line-height: 1.3em; +} + +.userNotFound > ul { + padding-left: 18px; + list-style: square; +} + .profile { text-shadow: 1px 1px 2px rgba(0, 0, 0, .75); font-family: "Exo2-0-LightItalic", sans-serif; @@ -578,6 +590,19 @@ a:active { line-height: 1em; } +/* + * User Background + */ +#userBackground { + position: fixed; + top: 0; + bottom: 0; + left: 0; + right: 0; + z-index: -1; + background: no-repeat center center / cover transparent; +} + /* * Homepage */ diff --git a/main/content/data/yuuno/js/yuuno.js b/main/content/data/yuuno/js/yuuno.js index b7de644..e9abf50 100644 --- a/main/content/data/yuuno/js/yuuno.js +++ b/main/content/data/yuuno/js/yuuno.js @@ -488,7 +488,7 @@ function formToObject(formId) { if(typeof children[i] == 'object') { - requestParts[children[i].name] = ((typeof children[i].type !== "undefined" && children[i].type.toLowerCase() == "checkbox") ? children[i].checked : children[i].value); + requestParts[children[i].name] = ((typeof children[i].type !== "undefined" && children[i].type.toLowerCase() == "checkbox") ? (children[i].checked ? 1 : 0) : children[i].value); } diff --git a/main/messages.php b/main/messages.php deleted file mode 100644 index 8c1dba5..0000000 --- a/main/messages.php +++ /dev/null @@ -1,22 +0,0 @@ - 'Inbox' - -]; - -$renderData['messages'] = Users::getPrivateMessages(); - -// Print page contents -print Templates::render('main/messages.tpl', $renderData); diff --git a/main/profile.php b/main/profile.php index 3685e67..b8cdd96 100644 --- a/main/profile.php +++ b/main/profile.php @@ -19,7 +19,7 @@ $renderData['profile'] = $profile; // Set proper page title $renderData['page']['title'] = ( - $profile->data['id'] < 1 || $profile->data['password_algo'] == 'nologin' + $profile->checkPermission('SITE', 'DEACTIVATED') || $profile->data['password_algo'] == 'nologin' || ($profile->checkPermission('SITE', 'RESTRICTED') && ($profile->data['id'] != $currentUser->data['id'] && !$currentUser->checkPermission('MANAGE', 'USE_MANAGE'))) ? 'User not found!' : 'Profile of '. $profile->data['username'] diff --git a/main/settings.php b/main/settings.php index 17ab701..4c3683f 100644 --- a/main/settings.php +++ b/main/settings.php @@ -322,9 +322,6 @@ if(isset($_REQUEST['request-notifications']) && $_REQUEST['request-notifications } - if(empty($_FILES[$mode])) - die('yes'); - // Check if the upload went properly if($_FILES[$mode]['error'] !== UPLOAD_ERR_OK && $_FILES[$mode]['error'] !== UPLOAD_ERR_NO_FILE) { @@ -537,9 +534,12 @@ if(isset($_REQUEST['request-notifications']) && $_REQUEST['request-notifications foreach($field['additional'] as $addKey => $addVal) { // Skip if the value is empty - if(!isset($_POST['profile_additional_'. $addKey]) || empty($_POST['profile_additional_'. $addKey])) + if(!isset($_POST['profile_additional_'. $addKey]) || empty($_POST['profile_additional_'. $addKey])) { + continue; + } + // Add to the array $store[$addKey] = $_POST['profile_additional_'. $addKey]; @@ -574,20 +574,16 @@ if(isset($_REQUEST['request-notifications']) && $_REQUEST['request-notifications // Go over each field foreach($fields as $field) { - // Add to the store array - if(isset($_POST['option_'. $field['id']]) && !empty($_POST['option_'. $field['id']])) { + // Make sure the user has sufficient permissions to complete this action + if(!$currentUser->checkPermission('SITE', $field['require_perm'])) { - // Make sure the user has sufficient permissions to complete this action - if(!$currentUser->checkPermission('SITE', $field['require_perm'])) { - - continue; - - } - - $store[$field['id']] = $_POST['option_'. $field['id']]; + $store[$field['id']] = false; + continue; } + $store[$field['id']] = isset($_POST['option_'. $field['id']]) && !empty($_POST['option_'. $field['id']]) ? $_POST['option_'. $field['id']] : null; + } // Update database @@ -666,73 +662,358 @@ if(Users::checkLogin()) { // Settings page list $pages = [ - 'home' => ['General', 'Home', ['Welcome to the Settings Panel. From here you can monitor, view and update your profile and preferences.']], - 'profile' => ['General', 'Edit Profile', ['These are the external account links etc. on your profile, shouldn\'t need any additional explanation for this one.']], - 'options' => ['General', 'Site Options', ['These are a few personalisation options for the site while you\'re logged in.']], - 'groups' => ['General', 'Groups', ['{{ user.colour }}']], - 'friendlisting' => ['Friends', 'List', ['Manage your friends.']], - 'friendrequests' => ['Friends', 'Requests', ['Handle friend requests.']], - 'notifications' => ['Notifications', 'History', ['This is the history of notifications that have been sent to you.']], - 'avatar' => ['Aesthetics', 'Avatar', ['Your avatar which is displayed all over the site and on your profile.', '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 }}.']], - 'background' => ['Aesthetics', 'Background', ['The background that is displayed on your profile.', 'Maximum image size is {{ background.max_width }}x{{ background.max_height }}, minimum image size is {{ background.min_width }}x{{ background.min_height }}, maximum file size is {{ background.max_size_view }}.']], - 'userpage' => ['Aesthetics', 'Userpage', ['The custom text that is displayed on your profile.', 'Click here if you don\'t know how to markdown!']], - 'email' => ['Account', 'E-mail Address', ['You e-mail address is used for password recovery and stuff like that, we won\'t spam you ;).']], - 'username' => ['Account', 'Username', ['Probably the biggest part of your identity on a site.', 'You can only change this once every 30 days so choose wisely.']], - 'usertitle' => ['Account', 'User Title', ['That little piece of text displayed under your username on your profile.']], - 'password' => ['Account', 'Password', ['Used to authenticate with the site and certain related services.']], - 'ranks' => ['Account', 'Ranks', ['Manage what ranks you\'re in and what is set as your main rank. Your main rank is highlighted. You get the permissions of all of the ranks you\'re in combined.']], - 'sessions' => ['Danger zone', 'Sessions', ['Session keys are a way of identifying yourself with the system without keeping your password in memory.', 'If someone finds one of your session keys they could possibly compromise your account, if you see any sessions here that shouldn\'t be here hit the Kill button to kill the selected session.', 'If you get logged out after clicking one you\'ve most likely killed your current session, to make it easier to avoid this from happening your current session is highlighted.']], - 'regkeys' => ['Danger zone', 'Registration Keys', ['Sometimes we activate the registration key system which means that users can only register using your "referer" keys, this means we can keep unwanted people from registering.', 'Each user can generate 5 of these keys, bans and deactivates render these keys useless.']], - 'deactivate' => ['Danger zone', 'Deactivate Account', ['You can deactivate your account here if you want to leave :(.']], - 'notfound' => ['Settings', '404', ['This is an error.']] + 'general' => [ + + 'title' => 'General', + + 'modes' => [ + + 'home' => [ + + 'title' => 'Home', + 'description' => [ + + 'Welcome to the Settings Panel. From here you can monitor, view and update your profile and preferences.' + + ], + 'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED') + + ], + 'profile' => [ + + 'title' => 'Edit Profile', + 'description' => [ + + 'These are the external account links etc. on your profile, shouldn\'t need any additional explanation for this one.' + + ], + 'access' => $currentUser->checkPermission('SITE', 'ALTER_PROFILE') + + ], + 'options' => [ + + 'title' => 'Site Options', + 'description' => [ + + 'These are a few personalisation options for the site while you\'re logged in.' + + ], + 'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED') + + ], + 'groups' => [ + + 'title' => 'Groups', + 'description' => [ + + '{{ user.colour }}' + + ], + 'access' => $currentUser->checkPermission('SITE', 'JOIN_GROUPS') + + ] + + ] + + ], + 'friends' => [ + + 'title' => 'Friends', + + 'modes' => [ + + 'listing' => [ + + 'title' => 'Listing', + 'description' => [ + + 'Manage your friends.' + + ], + 'access' => $currentUser->checkPermission('SITE', 'MANAGE_FRIENDS') + + ], + 'requests' => [ + + 'title' => 'Requests', + 'description' => [ + + 'Handle friend requests.' + + ], + 'access' => $currentUser->checkPermission('SITE', 'MANAGE_FRIENDS') + + ] + + ] + + ], + 'messages' => [ + + 'title' => 'Messages', + + 'modes' => [ + + 'inbox' => [ + + 'title' => 'Inbox', + 'description' => [ + + 'The list of messages you\'ve received.' + + ], + 'access' => $currentUser->checkPermission('SITE', 'USE_MESSAGES') + + ], + 'sent' => [ + + 'title' => 'Sent', + 'description' => [ + + 'The list of messages you\'ve sent to other users.' + + ], + 'access' => $currentUser->checkPermission('SITE', 'USE_MESSAGES') + + ], + 'compose' => [ + + 'title' => 'Compose', + 'description' => [ + + 'Write a new message.' + + ], + 'access' => $currentUser->checkPermission('SITE', 'SEND_MESSAGES') + + ] + + ] + + ], + 'notifications' => [ + + 'title' => 'Notifications', + + 'modes' => [ + + 'history' => [ + + 'title' => 'History', + 'description' => [ + + 'The history of notifications that have been sent to you.' + + ], + 'access' => !$currentUser->checkPermission('SITE', 'DEACTIVATED') + + ] + + ] + + ], + 'appearance' => [ + + 'title' => 'Appearance', + + 'modes' => [ + + 'avatar' => [ + + 'title' => 'Avatar', + 'description' => [ + + 'Your avatar which is displayed all over the site and on your profile.', + '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 }}.' + + + ], + 'access' => $currentUser->checkPermission('SITE', 'CHANGE_AVATAR') + + ], + 'background' => [ + + 'title' => 'Background', + 'description' => [ + + 'The background that is displayed on your profile.', + 'Maximum image size is {{ background.max_width }}x{{ background.max_height }}, minimum image size is {{ background.min_width }}x{{ background.min_height }}, maximum file size is {{ background.max_size_view }}.' + + ], + 'access' => (isset($currentUser->data['userData']['profileBackground']) && $currentUser->checkPermission('SITE', 'CHANGE_BACKGROUND')) || $currentUser->checkPermission('SITE', 'CREATE_BACKGROUND') + + ], + 'userpage' => [ + + 'title' => 'Userpage', + 'description' => [ + + 'The custom text that is displayed on your profile.' + + ], + 'access' => (isset($currentUser->data['userData']['userPage']) && $currentUser->checkPermission('SITE', 'CHANGE_USERPAGE')) || $currentUser->checkPermission('SITE', 'CREATE_USERPAGE') + + ] + + ] + + ], + 'account' => [ + + 'title' => 'Account', + + 'modes' => [ + + 'email' => [ + + 'title' => 'E-mail Address', + 'description' => [ + + 'You e-mail address is used for password recovery and stuff like that, we won\'t spam you ;).' + + ], + 'access' => $currentUser->checkPermission('SITE', 'CHANGE_EMAIL') + + ], + 'username' => [ + + 'title' => 'Username', + 'description' => [ + + 'Probably the biggest part of your identity on a site.', + 'You can only change this once every 30 days so choose wisely.' + + ], + 'access' => $currentUser->checkPermission('SITE', 'CHANGE_USERNAME') + + ], + 'usertitle' => [ + + 'title' => 'Username', + 'description' => [ + + 'That little piece of text displayed under your username on your profile.' + + ], + 'access' => $currentUser->checkPermission('SITE', 'CHANGE_USERTITLE') + + ], + 'password' => [ + + 'title' => 'Password', + 'description' => [ + + 'Used to authenticate with the site and certain related services.' + + ], + 'access' => $currentUser->checkPermission('SITE', 'CHANGE_PASSWORD') + + ], + 'ranks' => [ + + 'title' => 'Ranks', + 'description' => [ + + 'Manage what ranks you\'re in and what is set as your main rank. Your main rank is highlighted. You get the permissions of all of the ranks you\'re in combined.' + + ], + 'access' => $currentUser->checkPermission('SITE', 'ALTER_RANKS') + + ] + + ] + + ], + 'advanced' => [ + + 'title' => 'Advanced', + + 'modes' => [ + + 'sessions' => [ + + 'title' => 'Sessions', + 'description' => [ + + 'Session keys are a way of identifying yourself with the system without keeping your password in memory.', + 'If someone finds one of your session keys they could possibly compromise your account, if you see any sessions here that shouldn\'t be here hit the Kill button to kill the selected session.', + 'If you get logged out after clicking one you\'ve most likely killed your current session, to make it easier to avoid this from happening your current session is highlighted.' + + ], + 'access' => $currentUser->checkPermission('SITE', 'MANAGE_SESSIONS') + + ], + 'registrationkeys' => [ + + 'title' => 'Registration Keys', + 'description' => [ + + 'Sometimes we activate the registration key system which means that users can only register using your "referer" keys, this means we can keep unwanted people from registering.', + 'Each user can generate 5 of these keys, bans and deactivates render these keys useless.' + + ], + 'access' => $currentUser->checkPermission('SITE', 'CREATE_REGKEYS') + + ], + 'deactivate' => [ + + 'title' => 'Deactivate Account', + 'description' => [ + + 'You can deactivate your account here if you want to leave :(.' + + ], + 'access' => $currentUser->checkPermission('SITE', 'DEACTIVATE_ACCOUNT') + + ] + + ] + + ] ]; // Current settings page - $currentPage = isset($_GET['mode']) ? (array_key_exists($_GET['mode'], $pages) ? $_GET['mode'] : 'notfound') : 'home'; + $category = isset($_GET['cat']) ? (array_key_exists($_GET['cat'], $pages) ? $_GET['cat'] : false) : array_keys($pages)[0]; + $mode = isset($_GET['mode']) && $category ? (array_key_exists($_GET['mode'], $pages[$category]['modes']) ? $_GET['mode'] : false) : array_keys($pages[array_keys($pages)[0]]['modes'])[0]; + + // Not found + if(!$category || empty($category) || !$mode || empty($mode) || !$pages[$category]['modes'][$mode]['access']) { + + header('HTTP/1.0 404 Not Found'); + print Templates::render('errors/http404.tpl', $renderData); + exit; + + } // Render data - $renderData['current'] = $currentPage; + $renderData['current'] = $category .'.'. $mode; + + // Settings pages + $renderData['pages'] = $pages; + + // Page data $renderData['page'] = [ - 'title' => $pages[$currentPage][0] .' / '. $pages[$currentPage][1], + 'title' => $pages[$category]['title'] .' / '. $pages[$category]['modes'][$mode]['title'], 'currentPage' => isset($_GET['page']) && ($_GET['page'] - 1) >= 0 ? $_GET['page'] - 1 : 0, - 'description' => $pages[$currentPage][2] + 'description' => $pages[$category]['modes'][$mode]['description'] ]; + // Section specific - switch($currentPage) { + switch($category .'.'. $mode) { // Homepage - case 'home': + case 'general.home': $renderData['settings'] = [ 'friends' => Users::getFriends(null, true, true, true) ]; break; - // Avatar and background sizes - case 'avatar': - case 'background': - $renderData[$currentPage] = [ - - 'max_width' => Configuration::getConfig($currentPage .'_max_width'), - 'max_height' => Configuration::getConfig($currentPage .'_max_height'), - 'min_width' => Configuration::getConfig($currentPage .'_min_width'), - 'min_height' => Configuration::getConfig($currentPage .'_min_height'), - 'max_size' => Configuration::getConfig($currentPage .'_max_fsize'), - 'max_size_view' => Main::getByteSymbol(Configuration::getConfig($currentPage .'_max_fsize')) - - ]; - break; - // Profile - case 'userpage': - - break; - - // Profile - case 'profile': + case 'general.profile': $renderData['profile'] = [ 'user' => $currentUser->profileFields(), @@ -742,7 +1023,7 @@ if(Users::checkLogin()) { break; // Options - case 'options': + case 'general.options': $renderData['options'] = [ 'user' => $currentUser->optionFields(), @@ -752,20 +1033,45 @@ if(Users::checkLogin()) { break; // Friends - case 'friendlisting': + case 'friends.listing': $renderData['friends'] = array_chunk(array_reverse(Users::getFriends(null, true, true)), 12, true); break; // Pending Friend Requests - case 'friendrequests': + case 'friends.requests': $renderData['friends'] = array_chunk(array_reverse(Users::getPendingFriends(null, true)), 12, true); break; + // PM inbox + case 'messages.inbox': + $renderData['messages'] = Users::getPrivateMessages(); + break; + // Notification history - case 'notifications': + case 'notifications.history': $renderData['notifs'] = array_chunk(array_reverse(Users::getNotifications(null, 0, false, true)), 10, true); break; + // Avatar and background sizes + case 'appearance.avatar': + case 'appearance.background': + $renderData[$mode] = [ + + 'max_width' => Configuration::getConfig($mode .'_max_width'), + 'max_height' => Configuration::getConfig($mode .'_max_height'), + 'min_width' => Configuration::getConfig($mode .'_min_width'), + 'min_height' => Configuration::getConfig($mode .'_min_height'), + 'max_size' => Configuration::getConfig($mode .'_max_fsize'), + 'max_size_view' => Main::getByteSymbol(Configuration::getConfig($mode .'_max_fsize')) + + ]; + break; + + // Profile + case 'appearance.userpage': + + break; + } // Print page contents