midday commit

This commit is contained in:
flash 2015-08-29 15:25:57 +02:00
parent df0a14de27
commit 292112b854
17 changed files with 55 additions and 21 deletions

View file

@ -51,7 +51,8 @@
"20150823",
"20150825",
"20150826",
"20150828"
"20150828",
"20150829"
]
@ -2290,6 +2291,26 @@
"user": "Flashwave"
}
],
"20150829": [
{
"type": "UPD",
"change": "Improved template error handling.",
"user": "Flashwave"
},
{
"type": "FIX",
"change": "Fixed PHP version checker not halting the script entirely.",
"user": "Flashwave"
},
{
"type": "UPD",
"change": "Make placeholder avatars different based on the templates.",
"user": "Flashwave"
}
]
}

View file

@ -57,9 +57,12 @@ class Templates {
$twigEnv = [];
// Enable caching
if(Configuration::getConfig('enable_tpl_cache'))
if(Configuration::getConfig('enable_tpl_cache')) {
$twigEnv['cache'] = ROOT .'cache';
}
// And now actually initialise the templating engine
self::$_ENG = new Twig_Environment($twigLoader, $twigEnv);
@ -71,7 +74,15 @@ class Templates {
// Render template
public static function render($file, $tags) {
return self::$_ENG->render($file, $tags);
try {
return self::$_ENG->render($file, $tags);
} catch(\Exception $e) {
trigger_error($e->getMessage(), E_USER_ERROR);
}
}

View file

@ -8,7 +8,7 @@
namespace Sakura;
// Define Sakura version
define('SAKURA_VERSION', '20150828');
define('SAKURA_VERSION', '20150829');
define('SAKURA_VLABEL', 'Eminence');
define('SAKURA_COLOUR', '#6C3082');
define('SAKURA_STABLE', false);
@ -25,7 +25,7 @@ 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.');
die('<h3>Sakura requires at least PHP 5.4.0, please upgrade to a newer PHP version.</h3>');
}
@ -69,21 +69,21 @@ ob_start(Configuration::getConfig('use_gzip') ? 'ob_gzhandler' : null);
// Create a user object for the current logged in user
$currentUser = new User(Session::$userId);
// Prepare the name of the template to load (outside of SAKURA_NO_TPL because it's used in imageserve.php)
$templateName = 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')
);
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')
)
);
Templates::init($templateName);
// Set base page rendering data
$renderData = [

View file

@ -70,7 +70,7 @@
// Space for things that need to happen onload
window.addEventListener("load", function() {
{% 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) %}
{% if php.self == '/profile.php' ? (profile.data.userData.profileBackground and not profile.data.userData.userOptions.disableProfileParallax) : (user.checkPermission('SITE', 'CREATE_BACKGROUND') and user.data.userData.userOptions.profileBackgroundSiteWide and user.data.userData.profileBackground and not user.data.userData.userOptions.disableProfileParallax) %}
initialiseParallax('userBackground');
{% endif %}

View file

Before

Width:  |  Height:  |  Size: 16 KiB

After

Width:  |  Height:  |  Size: 16 KiB

View file

Before

Width:  |  Height:  |  Size: 26 KiB

After

Width:  |  Height:  |  Size: 26 KiB

View file

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

View file

Before

Width:  |  Height:  |  Size: 114 KiB

After

Width:  |  Height:  |  Size: 114 KiB

View file

Before

Width:  |  Height:  |  Size: 223 KiB

After

Width:  |  Height:  |  Size: 223 KiB

View file

Before

Width:  |  Height:  |  Size: 35 KiB

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 114 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 KiB

View file

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 71 KiB

View file

@ -25,14 +25,16 @@ if(isset($_GET['m'])) {
case 'avatar':
// Set paths
$noAvatar = ROOT . Configuration::getConfig('no_avatar_img');
$deactiveAvatar = ROOT . Configuration::getConfig('deactivated_avatar_img');
$bannedAvatar = ROOT . Configuration::getConfig('banned_avatar_img');
$noAvatar = ROOT . str_replace('{{ TPL }}', $templateName, Configuration::getConfig('no_avatar_img'));
$deactiveAvatar = ROOT . str_replace('{{ TPL }}', $templateName, Configuration::getConfig('deactivated_avatar_img'));
$bannedAvatar = ROOT . str_replace('{{ TPL }}', $templateName, Configuration::getConfig('banned_avatar_img'));
// If ?u= isn't set or if it isn't numeric
if(!isset($_GET['u']) || !is_numeric($_GET['u']) || $_GET['u'] == 0) {
$serveImage = $noAvatar;
break;
}
// Get user data