Bug fixes
This commit is contained in:
parent
710d7d3c67
commit
bb481498be
|
@ -8,3 +8,4 @@ bl-plugins/discovery
|
||||||
bl-kernel/bludit.pro.php
|
bl-kernel/bludit.pro.php
|
||||||
bl-themes/docs
|
bl-themes/docs
|
||||||
bl-themes/docsx
|
bl-themes/docsx
|
||||||
|
bl-themes/mediumish
|
|
@ -4,7 +4,7 @@
|
||||||
// Check role
|
// Check role
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
checkRole(array('admin', 'moderator'));
|
checkRole(array('admin', 'editor'));
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Functions
|
// Functions
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
// Check role
|
// Check role
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
if (!checkRole(array('admin','moderator'), false)) {
|
if (!checkRole(array('admin','editor'), false)) {
|
||||||
try {
|
try {
|
||||||
$pageKey = isset($_POST['key']) ? $_POST['key'] : $layout['parameters'];
|
$pageKey = isset($_POST['key']) ? $_POST['key'] : $layout['parameters'];
|
||||||
$page = new PageX($pageKey);
|
$page = new PageX($pageKey);
|
||||||
|
|
|
@ -31,6 +31,7 @@ function checkLogin($args)
|
||||||
Redirect::home();
|
Redirect::home();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Other user without the role reader redirect to dashboard
|
||||||
Redirect::page('dashboard');
|
Redirect::page('dashboard');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -40,7 +41,6 @@ function checkLogin($args)
|
||||||
|
|
||||||
// Create alert
|
// Create alert
|
||||||
Alert::set($Language->g('Username or password incorrect'), ALERT_STATUS_FAIL);
|
Alert::set($Language->g('Username or password incorrect'), ALERT_STATUS_FAIL);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@
|
||||||
// Check role
|
// Check role
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
checkRole(array('admin', 'moderator', 'editor'));
|
checkRole(array('admin', 'editor'));
|
||||||
|
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
// Functions
|
// Functions
|
||||||
|
|
|
@ -16,6 +16,13 @@
|
||||||
<a class="nav-link" href="<?php echo HTML_PATH_ADMIN_ROOT.'new-content' ?>"><span class="oi oi-plus"></span><?php $L->p('New content') ?></a>
|
<a class="nav-link" href="<?php echo HTML_PATH_ADMIN_ROOT.'new-content' ?>"><span class="oi oi-plus"></span><?php $L->p('New content') ?></a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
|
<?php if (checkRole(array('editor'),false)): ?>
|
||||||
|
|
||||||
|
<li class="nav-item">
|
||||||
|
<a class="nav-link" href="<?php echo HTML_PATH_ADMIN_ROOT.'content' ?>"><span class="oi oi-layers"></span><?php $L->p('Content') ?></a>
|
||||||
|
</li>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php if (checkRole(array('admin'),false)): ?>
|
<?php if (checkRole(array('admin'),false)): ?>
|
||||||
|
|
||||||
<li class="nav-item mt-3">
|
<li class="nav-item mt-3">
|
||||||
|
@ -24,6 +31,7 @@
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="<?php echo HTML_PATH_ADMIN_ROOT.'content' ?>"><?php $L->p('Content') ?></a>
|
<a class="nav-link" href="<?php echo HTML_PATH_ADMIN_ROOT.'content' ?>"><?php $L->p('Content') ?></a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link" href="<?php echo HTML_PATH_ADMIN_ROOT.'categories' ?>"><?php $L->p('Categories') ?></a>
|
<a class="nav-link" href="<?php echo HTML_PATH_ADMIN_ROOT.'categories' ?>"><?php $L->p('Categories') ?></a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -57,7 +65,6 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
|
|
||||||
<li class="nav-item mt-5">
|
<li class="nav-item mt-5">
|
||||||
|
|
|
@ -57,9 +57,9 @@ function table($type) {
|
||||||
<table class="table mt-3">
|
<table class="table mt-3">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="border-0" scope="col">'.$Language->g('Title').'</th>
|
<th style="font-size: 0.8em;" class="border-0 text-uppercase text-muted" scope="col">'.$Language->g('Title').'</th>
|
||||||
<th class="border-0 d-none d-lg-table-cell" scope="col">'.$Language->g('URL').'</th>
|
<th style="font-size: 0.8em;" class="border-0 d-none d-lg-table-cell text-uppercase text-muted" scope="col">'.$Language->g('URL').'</th>
|
||||||
<th class="border-0 text-center d-none d-sm-table-cell" scope="col">'.( ((ORDER_BY=='position') || ($type!='published'))?$Language->g('Position'):$Language->g('Creation date')).'</th>
|
<th style="font-size: 0.8em;" class="border-0 text-center d-none d-sm-table-cell text-uppercase text-muted" scope="col">Actions</th>
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
|
@ -111,16 +111,24 @@ function table($type) {
|
||||||
try {
|
try {
|
||||||
$page = new PageX($pageKey);
|
$page = new PageX($pageKey);
|
||||||
echo '<tr>';
|
echo '<tr>';
|
||||||
echo '<td>
|
echo '<td class="pt-3">
|
||||||
<a href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'">'
|
<div>
|
||||||
.($page->title()?$page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ')
|
<a style="font-size: 1.1em" href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'">'
|
||||||
.'</a>
|
.($page->title()?$page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ')
|
||||||
|
.'</a>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<p style="font-size: 0.8em" class="m-0 text-uppercase text-muted">'.( ((ORDER_BY=='position') || ($type!='published'))?'Position: '.$page->position():$page->relativeTime() ).'</p>
|
||||||
|
</div>
|
||||||
</td>';
|
</td>';
|
||||||
|
|
||||||
$friendlyURL = Text::isEmpty($url->filters('page')) ? '/'.$page->key() : '/'.$url->filters('page').'/'.$page->key();
|
$friendlyURL = Text::isEmpty($url->filters('page')) ? '/'.$page->key() : '/'.$url->filters('page').'/'.$page->key();
|
||||||
echo '<td class="d-none d-lg-table-cell"><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
|
echo '<td class="pt-3 d-none d-lg-table-cell"><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
|
||||||
|
|
||||||
echo '<td class="text-center d-none d-sm-table-cell">'.( ((ORDER_BY=='position') || ($type!='published'))?$page->position():$page->dateRaw(ADMIN_PANEL_DATE_FORMAT) ).'</td>';
|
echo '<td class="pt-3 text-center d-none d-sm-table-cell">'.PHP_EOL;
|
||||||
|
echo '<a type="button" class="btn btn-secondary btn-sm" href="'.HTML_PATH_ADMIN_ROOT.'edit-content/'.$page->key().'">Edit</a>'.PHP_EOL;
|
||||||
|
echo '<button type="button" class="btn btn-secondary btn-sm deletePageButton" data-toggle="modal" data-target="#jsdeletePageModal" data-key="'.$page->key().'"><span class="oi oi-trash"></span> Delete</button>'.PHP_EOL;
|
||||||
|
echo '</td>';
|
||||||
|
|
||||||
echo '</tr>';
|
echo '</tr>';
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
|
@ -160,6 +168,7 @@ function table($type) {
|
||||||
<div class="tab-pane show active" id="pages" role="tabpanel">
|
<div class="tab-pane show active" id="pages" role="tabpanel">
|
||||||
<?php table('published'); ?>
|
<?php table('published'); ?>
|
||||||
|
|
||||||
|
<?php if (Paginator::amountOfPages() > 1): ?>
|
||||||
<!-- Paginator -->
|
<!-- Paginator -->
|
||||||
<nav class="paginator">
|
<nav class="paginator">
|
||||||
<ul class="pagination flex-wrap justify-content-center">
|
<ul class="pagination flex-wrap justify-content-center">
|
||||||
|
@ -186,6 +195,7 @@ function table($type) {
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- TABS STATIC -->
|
<!-- TABS STATIC -->
|
||||||
|
@ -208,3 +218,49 @@ function table($type) {
|
||||||
<?php table('draft'); ?>
|
<?php table('draft'); ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<!-- Modal for delete page -->
|
||||||
|
<?php echo Bootstrap::modal(array(
|
||||||
|
'modalId'=>'jsdeletePageModal',
|
||||||
|
'modalTitle'=>'Delete content',
|
||||||
|
'modalText'=>'Are you sure you ?',
|
||||||
|
'buttonPrimary'=>'Delete',
|
||||||
|
'buttonPrimaryClass'=>'deletePageModalAcceptButton',
|
||||||
|
'buttonSecondary'=>'Cancel',
|
||||||
|
'buttonSecondaryClass'=>''
|
||||||
|
));
|
||||||
|
?>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function() {
|
||||||
|
var key = false;
|
||||||
|
|
||||||
|
// Button for delete a page in the table
|
||||||
|
$(".deletePageButton").on("click", function() {
|
||||||
|
key = $(this).data('key');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Event from button accept from the modal
|
||||||
|
$(".deletePageModalAcceptButton").on("click", function() {
|
||||||
|
|
||||||
|
var form = jQuery('<form>', {
|
||||||
|
'action': HTML_PATH_ADMIN_ROOT+'edit-content/'+key,
|
||||||
|
'method': 'post',
|
||||||
|
'target': '_top'
|
||||||
|
}).append(jQuery('<input>', {
|
||||||
|
'type': 'hidden',
|
||||||
|
'name': 'tokenCSRF',
|
||||||
|
'value': tokenCSRF
|
||||||
|
}).append(jQuery('<input>', {
|
||||||
|
'type': 'hidden',
|
||||||
|
'name': 'key',
|
||||||
|
'value': key
|
||||||
|
}).append(jQuery('<input>', {
|
||||||
|
'type': 'hidden',
|
||||||
|
'name': 'type',
|
||||||
|
'value': 'delete'
|
||||||
|
}))));
|
||||||
|
|
||||||
|
form.hide().appendTo("body").submit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -138,10 +138,20 @@
|
||||||
<button type="button" class="jsbuttonSave btn btn-primary btn-sm"><?php echo ($page->draft()?$L->g('Publish'):$L->g('Update')) ?></button>
|
<button type="button" class="jsbuttonSave btn btn-primary btn-sm"><?php echo ($page->draft()?$L->g('Publish'):$L->g('Update')) ?></button>
|
||||||
<button type="button" class="jsbuttonDraft btn btn-secondary btn-sm"><?php echo $L->g('Save as draft') ?></button>
|
<button type="button" class="jsbuttonDraft btn btn-secondary btn-sm"><?php echo $L->g('Save as draft') ?></button>
|
||||||
</div>
|
</div>
|
||||||
<h4 class="mt-4 mb-4 font-weight-normal">Cover Image</h4>
|
<h4 class="mt-4 mb-4 font-weight-normal">General</h4>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
// Username
|
||||||
|
echo Bootstrap::formInputText(array(
|
||||||
|
'name'=>'',
|
||||||
|
'label'=>'User',
|
||||||
|
'placeholder'=>'',
|
||||||
|
'value'=>$page->username(),
|
||||||
|
'tip'=>'',
|
||||||
|
'disabled'=>true
|
||||||
|
));
|
||||||
|
|
||||||
// Date
|
// Date
|
||||||
echo Bootstrap::formInputText(array(
|
echo Bootstrap::formInputText(array(
|
||||||
'name'=>'date',
|
'name'=>'date',
|
||||||
|
|
|
@ -1,9 +1,19 @@
|
||||||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||||
|
|
||||||
echo Bootstrap::pageTitle(array('title'=>$L->g('Edit user'), 'icon'=>'person'));
|
|
||||||
|
|
||||||
echo Bootstrap::formOpen(array());
|
echo Bootstrap::formOpen(array());
|
||||||
|
|
||||||
|
echo '
|
||||||
|
<div>
|
||||||
|
<div class="float-right">
|
||||||
|
<button type="submit" class="btn btn-primary btn-sm" name="save">'.$L->g('Save').'</button>
|
||||||
|
<a class="btn btn-secondary btn-sm" href="'.HTML_PATH_ADMIN_ROOT.'users" role="button">'.$L->g('Cancel').'</a>
|
||||||
|
</div>
|
||||||
|
<h2 class="mt-0 mb-3">
|
||||||
|
<span class="oi oi-person" style="font-size: 0.7em;"></span> Edit user
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
';
|
||||||
|
|
||||||
echo Bootstrap::formInputHidden(array(
|
echo Bootstrap::formInputHidden(array(
|
||||||
'name'=>'tokenCSRF',
|
'name'=>'tokenCSRF',
|
||||||
'value'=>$security->getTokenCSRF()
|
'value'=>$security->getTokenCSRF()
|
||||||
|
@ -28,7 +38,7 @@ echo Bootstrap::formOpen(array());
|
||||||
echo Bootstrap::formSelect(array(
|
echo Bootstrap::formSelect(array(
|
||||||
'name'=>'role',
|
'name'=>'role',
|
||||||
'label'=>$L->g('Role'),
|
'label'=>$L->g('Role'),
|
||||||
'options'=>array('reader'=>$L->g('Reader'), 'editor'=>$L->g('Editor'), 'moderator'=>$L->g('Moderator'), 'admin'=>$L->g('Administrator')),
|
'options'=>array('reader'=>$L->g('Reader'), 'editor'=>$L->g('Editor'), 'admin'=>$L->g('Administrator')),
|
||||||
'selected'=>$user->role(),
|
'selected'=>$user->role(),
|
||||||
'class'=>'',
|
'class'=>'',
|
||||||
'tip'=>''
|
'tip'=>''
|
||||||
|
@ -46,6 +56,15 @@ echo Bootstrap::formOpen(array());
|
||||||
|
|
||||||
echo Bootstrap::formTitle(array('title'=>$L->g('Profile')));
|
echo Bootstrap::formTitle(array('title'=>$L->g('Profile')));
|
||||||
|
|
||||||
|
echo Bootstrap::formInputText(array(
|
||||||
|
'name'=>'nickname',
|
||||||
|
'label'=>$L->g('Nickname'),
|
||||||
|
'value'=>$user->nickname(),
|
||||||
|
'class'=>'',
|
||||||
|
'placeholder'=>'',
|
||||||
|
'tip'=>'The nickname is almost used in the themes to display the author of the content'
|
||||||
|
));
|
||||||
|
|
||||||
echo Bootstrap::formInputText(array(
|
echo Bootstrap::formInputText(array(
|
||||||
'name'=>'firstName',
|
'name'=>'firstName',
|
||||||
'label'=>$L->g('First Name'),
|
'label'=>$L->g('First Name'),
|
||||||
|
|
|
@ -41,7 +41,7 @@ echo Bootstrap::formOpen(array());
|
||||||
echo Bootstrap::formSelect(array(
|
echo Bootstrap::formSelect(array(
|
||||||
'name'=>'role',
|
'name'=>'role',
|
||||||
'label'=>$L->g('Role'),
|
'label'=>$L->g('Role'),
|
||||||
'options'=>array('reader'=>$L->g('Reader'), 'editor'=>$L->g('Editor'), 'moderator'=>$L->g('Moderator'), 'admin'=>$L->g('Administrator')),
|
'options'=>array('reader'=>$L->g('Reader'), 'editor'=>$L->g('Editor'), 'admin'=>$L->g('Administrator')),
|
||||||
'selected'=>'reader',
|
'selected'=>'reader',
|
||||||
'class'=>'',
|
'class'=>'',
|
||||||
'tip'=>''
|
'tip'=>''
|
||||||
|
|
|
@ -36,8 +36,6 @@ foreach ($list as $username) {
|
||||||
echo '<td>'.($user->enabled()?'<b>'.$L->g('Enabled').'</b>':$L->g('Disabled')).'</td>';
|
echo '<td>'.($user->enabled()?'<b>'.$L->g('Enabled').'</b>':$L->g('Disabled')).'</td>';
|
||||||
if ($user->role()=='admin') {
|
if ($user->role()=='admin') {
|
||||||
echo '<td>'.$L->g('Administrator').'</td>';
|
echo '<td>'.$L->g('Administrator').'</td>';
|
||||||
} elseif ($user->role()=='moderator') {
|
|
||||||
echo '<td>'.$L->g('Moderator').'</td>';
|
|
||||||
} elseif ($user->role()=='editor') {
|
} elseif ($user->role()=='editor') {
|
||||||
echo '<td>'.$L->g('Editor').'</td>';
|
echo '<td>'.$L->g('Editor').'</td>';
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -21,4 +21,4 @@ exit (json_encode(array(
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
|
@ -16,15 +16,15 @@
|
||||||
// POST Method
|
// POST Method
|
||||||
// ============================================================================
|
// ============================================================================
|
||||||
|
|
||||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
|
||||||
{
|
|
||||||
$token = isset($_POST['tokenCSRF']) ? Sanitize::html($_POST['tokenCSRF']) : false;
|
$token = isset($_POST['tokenCSRF']) ? Sanitize::html($_POST['tokenCSRF']) : false;
|
||||||
if( !$security->validateTokenCSRF($token) ) {
|
if (!$security->validateTokenCSRF($token)) {
|
||||||
Log::set(__FILE__.LOG_SEP.'Error occurred when trying to validate the tokenCSRF. Token CSRF ID: '.$token);
|
Log::set(__FILE__.LOG_SEP.'Error occurred when trying to validate the tokenCSRF.', ALERT_STATUS_FAIL);
|
||||||
|
Log::set(__FILE__.LOG_SEP.'Token via POST ['.$token.']', ALERT_STATUS_FAIL);
|
||||||
|
|
||||||
Session::destroy();
|
Session::destroy();
|
||||||
Redirect::page('login');
|
Redirect::page('login');
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
unset( $_POST['tokenCSRF'] );
|
unset( $_POST['tokenCSRF'] );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,9 @@ class dbPages extends dbJSON {
|
||||||
|
|
||||||
// Check values on args and set default values if not exists
|
// Check values on args and set default values if not exists
|
||||||
foreach ($this->dbFields as $field=>$value) {
|
foreach ($this->dbFields as $field=>$value) {
|
||||||
if (isset($args[$field])) {
|
if ($field=='tags') {
|
||||||
|
$finalValue = $this->generateTags($args['tags']);
|
||||||
|
} elseif (isset($args[$field])) {
|
||||||
// Sanitize if will be stored on database
|
// Sanitize if will be stored on database
|
||||||
$finalValue = Sanitize::html($args[$field]);
|
$finalValue = Sanitize::html($args[$field]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -100,11 +102,6 @@ class dbPages extends dbJSON {
|
||||||
$row['uuid'] = $this->generateUUID();
|
$row['uuid'] = $this->generateUUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tags
|
|
||||||
if (!empty($row['tags'])) {
|
|
||||||
$row['tags'] = $this->generateTags($args['tags']);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Validate date
|
// Validate date
|
||||||
if (!Valid::date($row['date'], DB_DATE_FORMAT)) {
|
if (!Valid::date($row['date'], DB_DATE_FORMAT)) {
|
||||||
$row['date'] = Date::current(DB_DATE_FORMAT);
|
$row['date'] = Date::current(DB_DATE_FORMAT);
|
||||||
|
@ -150,7 +147,9 @@ class dbPages extends dbJSON {
|
||||||
|
|
||||||
// Check values on args or set default values
|
// Check values on args or set default values
|
||||||
foreach ($this->dbFields as $field=>$value) {
|
foreach ($this->dbFields as $field=>$value) {
|
||||||
if (isset($args[$field])) {
|
if ($field=='tags') {
|
||||||
|
$finalValue = $this->generateTags($args['tags']);
|
||||||
|
} elseif (isset($args[$field])) {
|
||||||
// Sanitize if will be stored on database
|
// Sanitize if will be stored on database
|
||||||
$finalValue = Sanitize::html($args[$field]);
|
$finalValue = Sanitize::html($args[$field]);
|
||||||
} else {
|
} else {
|
||||||
|
@ -794,23 +793,17 @@ class dbPages extends dbJSON {
|
||||||
public function generateTags($tags)
|
public function generateTags($tags)
|
||||||
{
|
{
|
||||||
$tmp = array();
|
$tmp = array();
|
||||||
|
|
||||||
$tags = trim($tags);
|
$tags = trim($tags);
|
||||||
|
if (empty($tags)) {
|
||||||
if(empty($tags)) {
|
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make array
|
|
||||||
$tags = explode(',', $tags);
|
$tags = explode(',', $tags);
|
||||||
|
foreach ($tags as $tag) {
|
||||||
foreach($tags as $tag)
|
|
||||||
{
|
|
||||||
$tag = trim($tag);
|
$tag = trim($tag);
|
||||||
$tagKey = Text::cleanUrl($tag);
|
$tagKey = Text::cleanUrl($tag);
|
||||||
$tmp[$tagKey] = $tag;
|
$tmp[$tagKey] = $tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tmp;
|
return $tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,8 @@ class dbUsers extends dbJSON {
|
||||||
public $dbFields = array(
|
public $dbFields = array(
|
||||||
'firstName'=>'',
|
'firstName'=>'',
|
||||||
'lastName'=>'',
|
'lastName'=>'',
|
||||||
'role'=>'editor', // admin, moderator, editor, reader
|
'nickname'=>'',
|
||||||
|
'role'=>'editor', // admin, editor, reader
|
||||||
'password'=>'',
|
'password'=>'',
|
||||||
'salt'=>'!Pink Floyd!Welcome to the machine!',
|
'salt'=>'!Pink Floyd!Welcome to the machine!',
|
||||||
'email'=>'',
|
'email'=>'',
|
||||||
|
|
|
@ -4,8 +4,11 @@ class Log {
|
||||||
|
|
||||||
public static function set($text, $type=LOG_TYPE_INFO)
|
public static function set($text, $type=LOG_TYPE_INFO)
|
||||||
{
|
{
|
||||||
$messageType = 0;
|
if (!DEBUG_MODE) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$messageType = 0;
|
||||||
if (is_array($text) ) {
|
if (is_array($text) ) {
|
||||||
error_log('------------------------', $messageType);
|
error_log('------------------------', $messageType);
|
||||||
error_log('Array', $messageType);
|
error_log('Array', $messageType);
|
||||||
|
|
|
@ -137,6 +137,11 @@ class Theme {
|
||||||
return '<meta name="viewport" content="'.$content.'">'.PHP_EOL;
|
return '<meta name="viewport" content="'.$content.'">'.PHP_EOL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function src($file, $base=DOMAIN_THEME)
|
||||||
|
{
|
||||||
|
return $base.$file;
|
||||||
|
}
|
||||||
|
|
||||||
public static function css($files, $base=DOMAIN_THEME)
|
public static function css($files, $base=DOMAIN_THEME)
|
||||||
{
|
{
|
||||||
if( !is_array($files) ) {
|
if( !is_array($files) ) {
|
||||||
|
|
|
@ -20,7 +20,7 @@ class bluditAjax {
|
||||||
title: title,
|
title: title,
|
||||||
content: content
|
content: content
|
||||||
},
|
},
|
||||||
url: "<?php echo HTML_PATH_ADMIN_ROOT ?>ajax/save-as-draft"
|
url: HTML_PATH_ADMIN_ROOT+"ajax/save-as-draft"
|
||||||
});
|
});
|
||||||
|
|
||||||
ajaxRequest.done(function (response, textStatus, jqXHR) {
|
ajaxRequest.done(function (response, textStatus, jqXHR) {
|
||||||
|
@ -52,7 +52,7 @@ class bluditAjax {
|
||||||
data: {
|
data: {
|
||||||
tokenCSRF: tokenCSRF // token from env variables
|
tokenCSRF: tokenCSRF // token from env variables
|
||||||
},
|
},
|
||||||
url: "<?php echo HTML_PATH_ADMIN_ROOT ?>ajax/user-logged"
|
url: HTML_PATH_ADMIN_ROOT+"ajax/user-logged"
|
||||||
});
|
});
|
||||||
|
|
||||||
ajaxRequest.done(function (response, textStatus, jqXHR) {
|
ajaxRequest.done(function (response, textStatus, jqXHR) {
|
||||||
|
@ -82,7 +82,7 @@ class bluditAjax {
|
||||||
parentKey: parentKey,
|
parentKey: parentKey,
|
||||||
currentKey: currentKey
|
currentKey: currentKey
|
||||||
},
|
},
|
||||||
url: "<?php echo HTML_PATH_ADMIN_ROOT.'ajax/generate-slug' ?>"
|
url: HTML_PATH_ADMIN_ROOT+"ajax/generate-slug"
|
||||||
});
|
});
|
||||||
|
|
||||||
ajaxRequest.done(function (response, textStatus, jqXHR) {
|
ajaxRequest.done(function (response, textStatus, jqXHR) {
|
||||||
|
|
|
@ -44,7 +44,7 @@ class Login {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Log::set(__METHOD__.LOG_SEP.'FingerPrint are differents. Current fingerPrint: '.Session::get('fingerPrint').' !== Current fingerPrint: '.$this->fingerPrint());
|
Log::set(__METHOD__.LOG_SEP.'FingerPrint are differents. ['.Session::get('fingerPrint').'] != ['.$this->fingerPrint().']');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,7 +56,7 @@ class Login {
|
||||||
Session::set('fingerPrint', $this->fingerPrint());
|
Session::set('fingerPrint', $this->fingerPrint());
|
||||||
Session::set('sessionTime', time());
|
Session::set('sessionTime', time());
|
||||||
|
|
||||||
Log::set(__METHOD__.LOG_SEP.'User logged, fingerprint: '.$this->fingerPrint());
|
Log::set(__METHOD__.LOG_SEP.'User logged, fingerprint ['.$this->fingerPrint().']');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setRememberMe($username)
|
public function setRememberMe($username)
|
||||||
|
@ -113,7 +113,7 @@ class Login {
|
||||||
$passwordHash = $this->dbUsers->generatePasswordHash($password, $user->salt());
|
$passwordHash = $this->dbUsers->generatePasswordHash($password, $user->salt());
|
||||||
if ($passwordHash===$user->password()) {
|
if ($passwordHash===$user->password()) {
|
||||||
$this->setLogin($username, $user->role());
|
$this->setLogin($username, $user->role());
|
||||||
Log::set(__METHOD__.LOG_SEP.'User logged succeeded by username and password - Username: '.$username);
|
Log::set(__METHOD__.LOG_SEP.'User logged succeeded by username and password - Username ['.$username.']');
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -205,12 +205,19 @@ class PageX {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the user object
|
// Returns the user object or passing the method returns the object User method
|
||||||
public function user()
|
public function user($method=false)
|
||||||
{
|
{
|
||||||
global $dbUsers;
|
|
||||||
$username = $this->username();
|
$username = $this->username();
|
||||||
return $dbUsers->getUser($username);
|
try {
|
||||||
|
$user = new User($username);
|
||||||
|
if ($method) {
|
||||||
|
return $user->{$method}();
|
||||||
|
}
|
||||||
|
return $user;
|
||||||
|
} catch (Exception $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function template()
|
public function template()
|
||||||
|
@ -226,23 +233,22 @@ class PageX {
|
||||||
|
|
||||||
// Returns the tags separated by comma
|
// Returns the tags separated by comma
|
||||||
// (boolean) $returnsArray, TRUE to get the tags as an array, FALSE to get the tags separeted by comma
|
// (boolean) $returnsArray, TRUE to get the tags as an array, FALSE to get the tags separeted by comma
|
||||||
|
// The tags in array format returns array( tagKey => tagName )
|
||||||
public function tags($returnsArray=false)
|
public function tags($returnsArray=false)
|
||||||
{
|
{
|
||||||
$tags = $this->getValue('tags');
|
$tags = $this->getValue('tags');
|
||||||
|
if ($returnsArray) {
|
||||||
if($returnsArray) {
|
if (empty($tags)) {
|
||||||
if($tags==false) {
|
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
return $tags;
|
return $tags;
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
if($tags==false) {
|
if (empty($tags)) {
|
||||||
return false;
|
return '';
|
||||||
}
|
|
||||||
// Return string with tags separeted by comma.
|
|
||||||
return implode(', ', $tags);
|
|
||||||
}
|
}
|
||||||
|
// Return string with tags separeted by comma.
|
||||||
|
return implode(', ', $tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function json($returnsArray=false)
|
public function json($returnsArray=false)
|
||||||
|
|
|
@ -22,7 +22,7 @@ class Security extends dbJSON
|
||||||
{
|
{
|
||||||
$token = sha1( uniqid().time() );
|
$token = sha1( uniqid().time() );
|
||||||
Session::set('tokenCSRF', $token);
|
Session::set('tokenCSRF', $token);
|
||||||
Log::set('New Token CSRF: '.$token);
|
Log::set(__METHOD__.LOG_SEP.'New Token CSRF ['.$token.']');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate the token
|
// Validate the token
|
||||||
|
|
|
@ -118,15 +118,13 @@ class Url
|
||||||
return $this->uri;
|
return $this->uri;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the filter used
|
// Return the filter filter by type
|
||||||
public function filters($type, $trim=true)
|
public function filters($type, $trim=true)
|
||||||
{
|
{
|
||||||
$filter = $this->filters[$type];
|
$filter = $this->filters[$type];
|
||||||
|
if ($trim) {
|
||||||
if($trim) {
|
|
||||||
$filter = trim($filter, '/');
|
$filter = trim($filter, '/');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $filter;
|
return $filter;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,11 @@ class User {
|
||||||
return $this->getValue('username');
|
return $this->getValue('username');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function nickname()
|
||||||
|
{
|
||||||
|
return $this->getValue('nickname');
|
||||||
|
}
|
||||||
|
|
||||||
public function firstName()
|
public function firstName()
|
||||||
{
|
{
|
||||||
return $this->getValue('firstName');
|
return $this->getValue('firstName');
|
||||||
|
|
Loading…
Reference in New Issue