Bug fixes, timezone and user permissions

This commit is contained in:
dignajar 2015-10-25 22:11:46 -03:00
parent c08a6303f9
commit 0fb1525f29
5 changed files with 64 additions and 8 deletions

View File

@ -0,0 +1,26 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
// ============================================================================
// Check role
// ============================================================================
if($Login->role()!=='admin') {
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
Redirect::page('admin', 'dashboard');
}
// ============================================================================
// Functions
// ============================================================================
// ============================================================================
// Main before POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
// ============================================================================
// Main after POST
// ============================================================================

View File

@ -63,11 +63,14 @@ $(document).ready(function() {
<ul class="uk-nav uk-nav-navbar"> <ul class="uk-nav uk-nav-navbar">
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-posts' ?>"><i class="uk-icon-folder-o"></i> <?php $L->p('Posts') ?></a></li> <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-posts' ?>"><i class="uk-icon-folder-o"></i> <?php $L->p('Posts') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-pages' ?>"><i class="uk-icon-folder-o"></i> <?php $L->p('Pages') ?></a></li> <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-pages' ?>"><i class="uk-icon-folder-o"></i> <?php $L->p('Pages') ?></a></li>
<?php if($Login->role() == 'admin') { ?>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>"><i class="uk-icon-users"></i> <?php $L->p('Users') ?></a></li> <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>"><i class="uk-icon-users"></i> <?php $L->p('Users') ?></a></li>
<?php } ?>
</ul> </ul>
</div> </div>
</li> </li>
<?php if($Login->role() == 'admin') { ?>
<li class="uk-parent" data-uk-dropdown> <li class="uk-parent" data-uk-dropdown>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-general' ?>"><i class="uk-icon-cog"></i> <?php $L->p('Settings') ?> ▾</a> <a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-general' ?>"><i class="uk-icon-cog"></i> <?php $L->p('Settings') ?> ▾</a>
<div class="uk-dropdown uk-dropdown-navbar"> <div class="uk-dropdown uk-dropdown-navbar">
@ -83,12 +86,14 @@ $(document).ready(function() {
</ul> </ul>
</div> </div>
</li> </li>
<?php } ?>
</ul> </ul>
<div class="uk-navbar-flip uk-hidden-small"> <div class="uk-navbar-flip uk-hidden-small">
<ul class="uk-navbar-nav"> <ul class="uk-navbar-nav">
<li class="uk-parent" data-uk-dropdown> <li class="uk-parent" data-uk-dropdown>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'edit-user/'.$Login->username() ?>"><i class="uk-icon-user"></i> Admin </a> <a href="<?php echo HTML_PATH_ADMIN_ROOT.'edit-user/'.$Login->username() ?>"><i class="uk-icon-user"></i> <?php echo $Login->username() ?> ▾</a>
<div class="uk-dropdown uk-dropdown-navbar"> <div class="uk-dropdown uk-dropdown-navbar">
<ul class="uk-nav uk-nav-navbar"> <ul class="uk-nav uk-nav-navbar">
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'edit-user/'.$Login->username() ?>"><?php $L->p('Profile') ?></a></li> <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'edit-user/'.$Login->username() ?>"><?php $L->p('Profile') ?></a></li>
@ -115,6 +120,7 @@ $(document).ready(function() {
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><?php $L->p('New page') ?></a></li> <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><?php $L->p('New page') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-posts' ?>"><?php $L->p('Manage posts') ?></a></li> <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-posts' ?>"><?php $L->p('Manage posts') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-pages' ?>"><?php $L->p('Manage pages') ?></a></li> <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-pages' ?>"><?php $L->p('Manage pages') ?></a></li>
<?php if($Login->role() == 'admin') { ?>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>"><?php $L->p('Manage users') ?></a></li> <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>"><?php $L->p('Manage users') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-general' ?>"><?php $L->p('General settings') ?></a></li> <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-general' ?>"><?php $L->p('General settings') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-advanced' ?>"><?php $L->p('Advanced settings') ?></a></li> <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-advanced' ?>"><?php $L->p('Advanced settings') ?></a></li>
@ -122,6 +128,7 @@ $(document).ready(function() {
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'plugins' ?>"><?php $L->p('Plugins') ?></a></li> <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'plugins' ?>"><?php $L->p('Plugins') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'themes' ?>"><?php $L->p('Themes') ?></a></li> <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'themes' ?>"><?php $L->p('Themes') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'about' ?>"><?php $L->p('About') ?></a></li> <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'about' ?>"><?php $L->p('About') ?></a></li>
<?php } ?>
</ul> </ul>
</div> </div>
</div> </div>

View File

@ -32,6 +32,8 @@
<div class="uk-width-medium-1-3"> <div class="uk-width-medium-1-3">
<?php if($Login->role() == 'admin') { ?>
<div class="uk-panel"> <div class="uk-panel">
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'add-user' ?>"><i class="uk-icon-user-plus"></i> <?php $L->p('Add a new user') ?></a></h4> <h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'add-user' ?>"><i class="uk-icon-user-plus"></i> <?php $L->p('Add a new user') ?></a></h4>
<p><?php $L->p('Invite a friend to collaborate on your website') ?></p> <p><?php $L->p('Invite a friend to collaborate on your website') ?></p>
@ -42,6 +44,15 @@
<p><?php $L->p('Change your language and region settings') ?></p> <p><?php $L->p('Change your language and region settings') ?></p>
</div> </div>
<?php } else { ?>
<div class="uk-panel">
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'edit-user/'.$Login->username() ?>"><i class="uk-icon-user"></i> <?php $L->p('Profile') ?></a></h4>
<p><?php $L->p('View and edit your profile') ?></p>
</div>
<?php } ?>
</div> </div>
</div> </div>

View File

@ -60,7 +60,7 @@ if(MB_STRING)
mb_http_output(CHARSET); mb_http_output(CHARSET);
} }
// PHP Classes // --- PHP Classes ---
include(PATH_HELPERS.'sanitize.class.php'); include(PATH_HELPERS.'sanitize.class.php');
include(PATH_HELPERS.'valid.class.php'); include(PATH_HELPERS.'valid.class.php');
include(PATH_HELPERS.'text.class.php'); include(PATH_HELPERS.'text.class.php');
@ -69,6 +69,8 @@ include(PATH_KERNEL.'dblanguage.class.php');
include(PATH_HELPERS.'log.class.php'); include(PATH_HELPERS.'log.class.php');
include(PATH_HELPERS.'date.class.php'); include(PATH_HELPERS.'date.class.php');
// --- LANGUAGE ---
// Try to detect language from HTTP // Try to detect language from HTTP
$explode = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']); $explode = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$localeFromHTTP = empty($explode[0])?'en_US':str_replace('-', '_', $explode[0]); $localeFromHTTP = empty($explode[0])?'en_US':str_replace('-', '_', $explode[0]);
@ -79,19 +81,24 @@ if(isset($_GET['language'])) {
$Language = new dbLanguage($localeFromHTTP); $Language = new dbLanguage($localeFromHTTP);
// Timezone // --- LOCALE ---
setlocale(LC_ALL, $localeFromHTTP);
// --- TIMEZONE ---
// Check if timezone is defined in php.ini
$iniDate = ini_get('date.timezone'); $iniDate = ini_get('date.timezone');
if(empty($iniDate)) { if(empty($iniDate)) {
// Timezone not defined in php.ini, then UTC as default.
date_default_timezone_set('UTC'); date_default_timezone_set('UTC');
} }
// Locales
setlocale(LC_ALL, $localeFromHTTP);
// ============================================================================ // ============================================================================
// FUNCTIONS // FUNCTIONS
// ============================================================================ // ============================================================================
// Returns an array with all languages
function getLanguageList() function getLanguageList()
{ {
$files = glob(PATH_LANGUAGES.'*.json'); $files = glob(PATH_LANGUAGES.'*.json');
@ -132,6 +139,7 @@ function checkSystem()
$phpModules = get_loaded_extensions(); $phpModules = get_loaded_extensions();
} }
// If the php version is less than 5.3, then don't check others requirements.
if(!version_compare(phpversion(), '5.3', '>=')) if(!version_compare(phpversion(), '5.3', '>='))
{ {
$errorText = 'Current PHP version '.phpversion().', you need > 5.3. (ERR_202)'; $errorText = 'Current PHP version '.phpversion().', you need > 5.3. (ERR_202)';
@ -187,13 +195,15 @@ function checkSystem()
return $stdOut; return $stdOut;
} }
// Finish with the installation.
function install($adminPassword, $email, $timezoneOffset) function install($adminPassword, $email, $timezoneOffset)
{ {
global $Language; global $Language;
$stdOut = array(); $stdOut = array();
$timezone = timezone_name_from_abbr("", $timezoneOffset, 0); $timezone = timezone_name_from_abbr('', $timezoneOffset, 1);
if($timezone === false) { $timezone = timezone_name_from_abbr('', $timezoneOffset, 0); } // Workaround bug #44780
date_default_timezone_set($timezone); date_default_timezone_set($timezone);
@ -408,6 +418,7 @@ Content:
return true; return true;
} }
// Check form's parameters and finish Bludit installation.
function checkPOST($args) function checkPOST($args)
{ {
global $Language; global $Language;

View File

@ -195,5 +195,6 @@
"edit-or-remove-your-blogs-posts": "Edit or remove your blog's posts.", "edit-or-remove-your-blogs-posts": "Edit or remove your blog's posts.",
"general-settings": "General settings", "general-settings": "General settings",
"advanced-settings": "Advanced settings", "advanced-settings": "Advanced settings",
"manage-users": "Manage users" "manage-users": "Manage users",
"view-and-edit-your-profile": "View and edit your profile."
} }