Merge pull request #2 from dignajar/bluditv2

Bluditv2
This commit is contained in:
Edi 2017-07-10 22:52:39 +02:00 committed by GitHub
commit 5af87f14ad
375 changed files with 43701 additions and 2390 deletions

4
.gitignore vendored
View File

@ -1,3 +1,5 @@
.DS_Store .DS_Store
bl-content/* bl-content/*
bl-plugins/timemachine bl-plugins/timemachine
bl-plugins/remote-content
bl-kernel/bludit.pro.php

View File

@ -24,7 +24,7 @@ class dbList extends dbJSON
parent::__construct($file); parent::__construct($file);
} }
private function getList($key, $amountOfItems, $pageNumber) public function getList($key, $pageNumber, $amountOfItems)
{ {
if( !isset($this->db[$key]) ) { if( !isset($this->db[$key]) ) {
Log::set(__METHOD__.LOG_SEP.'Error key does not exist '.$key); Log::set(__METHOD__.LOG_SEP.'Error key does not exist '.$key);
@ -33,8 +33,11 @@ class dbList extends dbJSON
$list = $this->db[$key]['list']; $list = $this->db[$key]['list'];
// The first page number is 1, so the real is 0
$realPageNumber = $pageNumber - 1;
$total = count($list); $total = count($list);
$init = (int) $amountOfItems * $pageNumber; $init = (int) $amountOfItems * $realPageNumber;
$end = (int) min( ($init + $amountOfItems - 1), $total ); $end = (int) min( ($init + $amountOfItems - 1), $total );
$outrange = $init<0 ? true : $init>$end; $outrange = $init<0 ? true : $init>$end;
@ -62,6 +65,8 @@ class dbList extends dbJSON
$this->db[$key]['name'] = $name; $this->db[$key]['name'] = $name;
$this->db[$key]['list'] = array(); $this->db[$key]['list'] = array();
$this->sortAlphanumeric();
$this->save(); $this->save();
return $key; return $key;
@ -90,10 +95,18 @@ class dbList extends dbJSON
unset( $this->db[$oldKey] ); unset( $this->db[$oldKey] );
} }
$this->sortAlphanumeric();
$this->save(); $this->save();
return $newKey; return $newKey;
} }
// Sort the categories by "Natural order"
private function sortAlphanumeric()
{
// Sort key alphanumeric strings, a01, a10, b10, c02
return ksort($this->db);
}
// Returns the name associated to the key, FALSE if the key doesn't exist // Returns the name associated to the key, FALSE if the key doesn't exist
public function getName($key) public function getName($key)
{ {
@ -105,18 +118,13 @@ class dbList extends dbJSON
} }
// Returns an array with key=>name of the list // Returns an array with key=>name of the list
public function getKeyNameArray($sortAlphanumeric=true) public function getKeyNameArray()
{ {
$tmp = array(); $tmp = array();
foreach($this->db as $key=>$fields) { foreach($this->db as $key=>$fields) {
$tmp[$key] = $fields['name']; $tmp[$key] = $fields['name'];
} }
// Sort alphanumeric strings, a01, a10, a11, a20
if($sortAlphanumeric) {
natcasesort($tmp);
}
return $tmp; return $tmp;
} }

View File

@ -2,25 +2,34 @@
class Plugin { class Plugin {
// (string) Plugin's directory name // (string) directory name, just the name
// Ex: sitemap
public $directoryName; public $directoryName;
// (string) Database path and filename // (string) Absoulute database filename and path
// Ex: /www/bludit/bl-content/plugins/sitemap/db.php
public $filenameDb; public $filenameDb;
// (string) Absoulute metadata filename and path
// Ex: /www/bludit/bl-plugins/sitemap/metadata.json
public $filenameMetadata; public $filenameMetadata;
// (array) Plugin metadata
// Ex: array('author'=>'',...., 'notes'=>'')
public $metadata;
// (string) Class name
// Ex: pluginSitemap
public $className;
// (array) Database unserialized // (array) Database unserialized
public $db; public $db;
// (array) Database fields, only for initialize. // (array) Database fields, only for initialize
public $dbFields; public $dbFields;
// (string) Plugin's class name. // (boolean) Enable or disable default Save and Cancel button on plugin settings
public $className; public $formButtons;
// (array) Plugin's information.
public $metadata;
function __construct() function __construct()
{ {
@ -34,10 +43,12 @@ class Plugin {
// Class Name // Class Name
$this->className = $reflector->getName(); $this->className = $reflector->getName();
// Initialize dbFields from the children. $this->formButtons = true;
// Call the method init() from the children
$this->init(); $this->init();
// Init empty database // Init empty database with default values
$this->db = $this->dbFields; $this->db = $this->dbFields;
$this->filenameDb = PATH_PLUGINS_DATABASES.$this->directoryName.DS.'db.php'; $this->filenameDb = PATH_PLUGINS_DATABASES.$this->directoryName.DS.'db.php';
@ -47,14 +58,37 @@ class Plugin {
$metadataString = file_get_contents($this->filenameMetadata); $metadataString = file_get_contents($this->filenameMetadata);
$this->metadata = json_decode($metadataString, true); $this->metadata = json_decode($metadataString, true);
// If the plugin is installed then get the database. // If the plugin is installed then get the database
if($this->installed()) if($this->installed()) {
{
$Tmp = new dbJSON($this->filenameDb); $Tmp = new dbJSON($this->filenameDb);
$this->db = $Tmp->db; $this->db = $Tmp->db;
} }
} }
// DEPRECATED
// 2017-06-19
public function setDb($args)
{
foreach($this->dbFields as $key=>$value) {
if( isset($args[$key]) ) {
$value = Sanitize::html( $args[$key] );
if($value==='false') { $value = false; }
elseif($value==='true') { $value = true; }
settype($value, gettype($this->dbFields[$key]));
$this->db[$key] = $value;
}
}
$this->save();
}
public function save()
{
$tmp = new dbJSON($this->filenameDb);
$tmp->db = $this->db;
$tmp->save();
}
public function htmlPath() public function htmlPath()
{ {
return HTML_PATH_PLUGINS.$this->directoryName.'/'; return HTML_PATH_PLUGINS.$this->directoryName.'/';
@ -70,22 +104,41 @@ class Plugin {
return PATH_PLUGINS_DATABASES.$this->directoryName.DS; return PATH_PLUGINS_DATABASES.$this->directoryName.DS;
} }
// Returns the item from plugin-data. // Returns the value of the key from the metadata of the plugin, FALSE if the key doen't exit
public function getMetadata($key) public function getMetadata($key)
{ {
if(isset($this->metadata[$key])) { if(isset($this->metadata[$key])) {
return $this->metadata[$key]; return $this->metadata[$key];
} }
return ''; return false;
} }
// Set a key / value on the metadata of the plugin
public function setMetadata($key, $value) public function setMetadata($key, $value)
{ {
$this->metadata[$key] = $value; $this->metadata[$key] = $value;
return true; return true;
} }
// Returns the value of the field from the database
// (string) $field
// (boolean) $html, TRUE returns the value sanitized, FALSE unsanitized
public function getValue($field, $html=true)
{
if( isset($this->db[$field]) ) {
if($html) {
return $this->db[$field];
}
else {
return Sanitize::htmlDecode($this->db[$field]);
}
}
return false;
}
// DEPRECATED
// 2017-06-16
public function getDbField($key, $html=true) public function getDbField($key, $html=true)
{ {
if(isset($this->db[$key])) { if(isset($this->db[$key])) {
@ -103,33 +156,6 @@ class Plugin {
return ''; return '';
} }
public function setDb($args)
{
$tmp = $this->db;
foreach($this->dbFields as $key=>$value)
{
if(isset($args[$key]))
{
// Sanitize value
$tmpValue = Sanitize::html( $args[$key] );
// Set type
settype($tmpValue, gettype($value));
// Set value
$tmp[$key] = $tmpValue;
}
}
$this->db = $tmp;
// Save db on file
$Tmp = new dbJSON($this->filenameDb);
$Tmp->db = $tmp;
$Tmp->save();
}
public function name() public function name()
{ {
return $this->getMetadata('name'); return $this->getMetadata('name');
@ -170,11 +196,22 @@ class Plugin {
return $this->className; return $this->className;
} }
public function formButtons()
{
return $this->formButtons;
}
public function isCompatible() public function isCompatible()
{ {
$explode = explode(',', $this->getMetadata('compatible')); $bluditRoot = explode('.', BLUDIT_VERSION);
$compatible = explode(',', $this->getMetadata('compatible'));
return in_array(BLUDIT_VERSION, $explode); foreach( $compatible as $version ) {
$root = explode('.', $version);
if( $root[0]==$bluditRoot[0] && $root[1]==$bluditRoot[1] ) {
return true;
}
}
return false;
} }
public function directoryName() public function directoryName()
@ -201,14 +238,8 @@ class Plugin {
public function uninstall() public function uninstall()
{ {
// Delete all files. $path = PATH_PLUGINS_DATABASES.$this->directoryName;
$files = Filesystem::listFiles( $this->phpPathDB() ); return Filesystem::deleteRecursive($path);
foreach($files as $file) {
unlink($file);
}
// Delete the directory.
rmdir(PATH_PLUGINS_DATABASES.$this->directoryName);
} }
public function installed() public function installed()
@ -216,10 +247,57 @@ class Plugin {
return file_exists($this->filenameDb); return file_exists($this->filenameDb);
} }
public function workspace()
{
return PATH_PLUGINS_DATABASES.$this->directoryName.DS;
}
public function init() public function init()
{ {
// This method is used on childre classes. // This method is used on childre classes.
// The user can define your own dbFields. // The user can define his own field of the database
}
public function post()
{
$args = $_POST;
foreach($this->dbFields as $key=>$value) {
if( isset($args[$key]) ) {
$value = Sanitize::html( $args[$key] );
if($value==='false') { $value = false; }
elseif($value==='true') { $value = true; }
settype($value, gettype($this->dbFields[$key]));
$this->db[$key] = $value;
}
}
return $this->save();
}
// Returns the parameters after the URI, FALSE if the URI doesn't match with the webhook
// Example: https://www.mybludit.com/api/foo/bar
public function webhook($URI=false, $returnsAfterURI=false)
{
global $Url;
if(empty($URI)) {
return false;
}
// Check URI start with the webhook
$startString = HTML_PATH_ROOT.$URI;
$URI = $Url->uri();
$length = mb_strlen($startString, CHARSET);
if( mb_substr($URI, 0, $length)!=$startString ) {
return false;
}
if($returnsAfterURI) {
return mb_substr($URI, $length);
}
Log::set(__METHOD__.LOG_SEP.'Webhook requested.');
return true;
} }
} }

View File

@ -13,59 +13,6 @@ if($Login->role()!=='admin') {
// Functions // Functions
// ============================================================================ // ============================================================================
function addUser($args)
{
global $dbUsers;
global $Language;
// Check empty username
if( Text::isEmpty($args['new_username']) )
{
Alert::set($Language->g('username-field-is-empty'), ALERT_STATUS_FAIL);
return false;
}
// Check already exist username
if( $dbUsers->userExists($args['new_username']) )
{
Alert::set($Language->g('username-already-exists'), ALERT_STATUS_FAIL);
return false;
}
// Password length
if( strlen($args['new_password']) < 6 )
{
Alert::set($Language->g('Password must be at least 6 characters long'), ALERT_STATUS_FAIL);
return false;
}
// Check new password and confirm password are equal
if( $args['new_password'] != $args['confirm_password'] )
{
Alert::set($Language->g('The password and confirmation password do not match'), ALERT_STATUS_FAIL);
return false;
}
// Filter form fields
$tmp = array();
$tmp['username'] = $args['new_username'];
$tmp['password'] = $args['new_password'];
$tmp['role'] = $args['role'];
$tmp['email'] = $args['email'];
// Add the user to the database
if( $dbUsers->add($tmp) )
{
Alert::set($Language->g('user-has-been-added-successfully'), ALERT_STATUS_OK);
return true;
}
else
{
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the account.');
return false;
}
}
// ============================================================================ // ============================================================================
// Main before POST // Main before POST
// ============================================================================ // ============================================================================
@ -76,8 +23,8 @@ function addUser($args)
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{ {
if( addUser($_POST) ) { if( createUser($_POST) ) {
Redirect::page('admin', 'users'); Redirect::page('users');
} }
} }

View File

@ -6,7 +6,7 @@
if($Login->role()!=='admin') { if($Login->role()!=='admin') {
Alert::set($Language->g('you-do-not-have-sufficient-permissions')); Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
Redirect::page('admin', 'dashboard'); Redirect::page('dashboard');
} }
// ============================================================================ // ============================================================================
@ -16,24 +16,20 @@ if($Login->role()!=='admin') {
// ============================================================================ // ============================================================================
// Main before POST // Main before POST
// ============================================================================ // ============================================================================
$_Plugin = false; $plugin = false;
$pluginClassName = $layout['parameters']; $pluginClassName = $layout['parameters'];
foreach($plugins['all'] as $P) // Check if the plugin exists
{ if( isset($plugins['all'][$pluginClassName]) ) {
if($P->className()==$pluginClassName) { $plugin = $plugins['all'][$pluginClassName];
$_Plugin = $P;
}
} }
else {
// Check if the plugin exists. Redirect::page('plugins');
if($_Plugin===false) {
Redirect::page('admin', 'plugins');
} }
// Check if the plugin has the method form() // Check if the plugin has the method form()
if(!method_exists($_Plugin, 'form')) { if( !method_exists($plugin, 'form') ) {
Redirect::page('admin', 'plugins'); Redirect::page('plugins');
} }
// ============================================================================ // ============================================================================
@ -42,11 +38,22 @@ if(!method_exists($_Plugin, 'form')) {
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{ {
$_Plugin->setDb($_POST); // Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'plugin-configured',
'notes'=>$plugin->name()
));
Theme::plugins('afterFormSave'); // Call the method post of the plugin
if( $plugin->post() ) {
Alert::set($Language->g('the-changes-have-been-saved')); // Create an alert
Alert::set( $Language->g('The changes have been saved') );
Redirect::page('configure-plugin/'.$plugin->className());
}
else {
// Create an alert
Alert::set( $Language->g('Complete all fields') );
}
} }
// ============================================================================ // ============================================================================

View File

@ -7,35 +7,33 @@
// ============================================================================ // ============================================================================
// Functions // Functions
// ============================================================================ // ============================================================================
function addPost($args)
{
global $dbPosts;
global $Language;
// Add the page, if the $key is FALSE the creation of the post failure. function printTable($title, $array) {
$key = $dbPosts->add($args); echo '<h2>'.$title.'</h2>';
echo '
<table class="uk-table uk-table-striped">
<thead>
<tr>
<th class="uk-width-1-5"></th>
<th class="uk-width-3-5"></th>
</tr>
</thead>
<tbody>
';
if($key) { foreach($array as $key=>$value) {
// Reindex tags, this function is in 70.posts.php if($value===false) { $value = 'false'; }
reIndexTagsPosts(); elseif($value===true) { $value = 'true'; }
echo '<tr>';
// Re index categories echo '<td>'.$key.'</td>';
//reIndexCategoriesPosts(); echo '<td>'.Sanitize::html($value).'</td>';
echo '</tr>';
// Call the plugins after post creation
Theme::plugins('afterPostCreate');
// Alert for the user
Alert::set($Language->g('Post added successfully'));
Redirect::page('admin', 'manage-posts');
}
else {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the post.');
Log::set(__METHOD__.LOG_SEP.'Cleaning database...');
$dbPosts->delete($key);
} }
return false; echo '
</tbody>
</table>
';
} }
// ============================================================================ // ============================================================================
@ -46,11 +44,6 @@ function addPost($args)
// POST Method // POST Method
// ============================================================================ // ============================================================================
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{
addPost($_POST);
}
// ============================================================================ // ============================================================================
// Main after POST // Main after POST
// ============================================================================ // ============================================================================

View File

@ -32,6 +32,12 @@ function edit($oldCategoryKey, $newCategory)
Alert::set($Language->g('The changes have been saved')); Alert::set($Language->g('The changes have been saved'));
} }
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'category-edited',
'notes'=>$newCategory
));
Redirect::page('categories'); Redirect::page('categories');
} }
@ -40,9 +46,19 @@ function delete($categoryKey)
global $Language; global $Language;
global $dbCategories; global $dbCategories;
// Remove the category by key
$dbCategories->remove($categoryKey); $dbCategories->remove($categoryKey);
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'category-deleted',
'notes'=>$categoryKey
));
// Create an alert
Alert::set($Language->g('The changes have been saved')); Alert::set($Language->g('The changes have been saved'));
// Redirect
Redirect::page('categories'); Redirect::page('categories');
} }

View File

@ -8,57 +8,6 @@
// Functions // Functions
// ============================================================================ // ============================================================================
function editPage($args)
{
global $dbPages;
global $Language;
if(!isset($args['parent'])) {
$args['parent'] = NO_PARENT_CHAR;
}
// Add the page, if the $key is FALSE the creation of the post failure.
$key = $dbPages->edit($args);
if($key)
{
$dbPages->regenerateCli();
// Re index categories
//reIndexCategoriesPages();
// Call the plugins after page created.
Theme::plugins('afterPageModify');
// Alert the user
Alert::set($Language->g('The changes have been saved'));
Redirect::page('admin', 'edit-page/'.$args['slug']);
}
else
{
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to edit the page.');
}
}
function deletePage($key)
{
global $dbPages;
global $Language;
if( $dbPages->delete($key) )
{
// Call the plugins after post created.
Theme::plugins('afterPageDelete');
Alert::set($Language->g('The page has been deleted successfully'));
Redirect::page('admin', 'manage-pages');
}
else
{
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the page.');
}
}
// ============================================================================ // ============================================================================
// Main before POST // Main before POST
// ============================================================================ // ============================================================================
@ -70,11 +19,20 @@ function deletePage($key)
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{ {
if( isset($_POST['delete-page']) ) { if( isset($_POST['delete-page']) ) {
deletePage($_POST['key']); if( deletePage($_POST['key']) ) {
Alert::set( $Language->g('The changes have been saved') );
Redirect::page('pages');
}
} }
else { else {
editPage($_POST); $key = editPage($_POST);
if( $key!==false ) {
Alert::set( $Language->g('The changes have been saved') );
Redirect::page('edit-page/'.$key);
}
} }
Redirect::page('pages');
} }
// ============================================================================ // ============================================================================
@ -86,4 +44,6 @@ if( !$dbPages->exists($layout['parameters']) ) {
Redirect::page('pages'); Redirect::page('pages');
} }
$page = $pagesKey[$layout['parameters']]; $page = $pagesByKey[$layout['parameters']];
$layout['title'] .= ' - '.$Language->g('Edit Content');

View File

@ -1,94 +0,0 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
// ============================================================================
// Check role
// ============================================================================
// ============================================================================
// Functions
// ============================================================================
function editPost($args)
{
global $dbPosts;
global $Language;
// Add the page, if the $key is FALSE the creation of the post failure.
$key = $dbPosts->edit($args);
if($key)
{
// Reindex tags, this function is in 70.posts.php
reIndexTagsPosts();
// Re index categories
//reIndexCategoriesPosts();
// Call the plugins after post created.
Theme::plugins('afterPostModify');
// Alert the user
Alert::set($Language->g('The changes have been saved'));
Redirect::page('admin', 'edit-post/'.$args['slug']);
}
else
{
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to edit the post.');
}
return false;
}
function deletePost($key)
{
global $dbPosts;
global $Language;
if( $dbPosts->delete($key) )
{
// Reindex tags, this function is in 70.posts.php
reIndexTagsPosts();
// Call the plugins after post created.
Theme::plugins('afterPostDelete');
Alert::set($Language->g('The post has been deleted successfully'));
Redirect::page('admin', 'manage-posts');
}
else
{
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the post.');
}
}
// ============================================================================
// Main before POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{
if( isset($_POST['delete-post']) ) {
deletePost($_POST['key']);
}
else {
editPost($_POST);
}
}
// ============================================================================
// Main after POST
// ============================================================================
if(!$dbPosts->postExists($layout['parameters']))
{
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the post: '.$layout['parameters']);
Redirect::page('admin', 'manage-posts');
}
$_Post = buildPost($layout['parameters']);
$layout['title'] .= ' - '.$Language->g('Edit post').' - '.$_Post->title();

View File

@ -4,70 +4,6 @@
// Functions // Functions
// ============================================================================ // ============================================================================
function disableUser($username) {
global $dbUsers;
global $Language;
global $Login;
// The editors can't disable users
if($Login->role()!=='admin') {
return false;
}
if( $dbUsers->disableUser($username) ) {
Alert::set($Language->g('The changes have been saved'));
}
else {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to edit the user.');
}
}
function editUser($args)
{
global $dbUsers;
global $Language;
if( $dbUsers->set($args) ) {
Alert::set($Language->g('The changes have been saved'));
}
else {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to edit the user.');
}
}
function deleteUser($args, $deleteContent=false)
{
global $dbUsers;
global $dbPosts;
global $Language;
global $Login;
// The user admin cannot be deleted.
if($args['username']=='admin') {
return false;
}
// The editors cannot delete users.
if($Login->role()!=='admin') {
return false;
}
if($deleteContent) {
$dbPosts->deletePostsByUser($args['username']);
}
else {
$dbPosts->linkPostsToUser($args['username'], 'admin');
}
if( $dbUsers->delete($args['username']) ) {
Alert::set($Language->g('User deleted'));
}
else {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the user.');
}
}
// ============================================================================ // ============================================================================
// Main before POST // Main before POST
// ============================================================================ // ============================================================================
@ -78,18 +14,17 @@ function deleteUser($args, $deleteContent=false)
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{ {
// Prevent editors to administrate other users. // Prevent non-administrators to change other users
if($Login->role()!=='admin') if($Login->role()!=='admin') {
{
$_POST['username'] = $Login->username(); $_POST['username'] = $Login->username();
unset($_POST['role']); unset($_POST['role']);
} }
if(isset($_POST['delete-user-all'])) { if(isset($_POST['delete-user-all'])) {
deleteUser($_POST, true); deleteUser($_POST, $deleteContent=true);
} }
elseif(isset($_POST['delete-user-associate'])) { elseif(isset($_POST['delete-user-associate'])) {
deleteUser($_POST, false); deleteUser($_POST, $deleteContent=false);
} }
elseif(isset($_POST['disable-user'])) { elseif(isset($_POST['disable-user'])) {
disableUser($_POST['username']); disableUser($_POST['username']);
@ -97,19 +32,22 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
else { else {
editUser($_POST); editUser($_POST);
} }
Alert::set($Language->g('The changes have been saved'));
} }
// ============================================================================ // ============================================================================
// Main after POST // Main after POST
// ============================================================================ // ============================================================================
// Prevent non-administrators to change other users
if($Login->role()!=='admin') { if($Login->role()!=='admin') {
$layout['parameters'] = $Login->username(); $layout['parameters'] = $Login->username();
} }
$_User = $dbUsers->getUser($layout['parameters']); $User = $dbUsers->getUser($layout['parameters']);
// If the user doesn't exist, redirect to the users list. // If the user doesn't exist, redirect to the users list.
if($_User===false) { if($User===false) {
Redirect::page('admin', 'users'); Redirect::page('users');
} }

View File

@ -6,7 +6,7 @@
if($Login->role()!=='admin') { if($Login->role()!=='admin') {
Alert::set($Language->g('you-do-not-have-sufficient-permissions')); Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
Redirect::page('admin', 'dashboard'); Redirect::page('dashboard');
} }
// ============================================================================ // ============================================================================
@ -26,11 +26,27 @@ if($Login->role()!=='admin') {
// ============================================================================ // ============================================================================
$pluginClassName = $layout['parameters']; $pluginClassName = $layout['parameters'];
foreach($plugins['all'] as $P) // Check if the plugin exists
{ if( isset($plugins['all'][$pluginClassName]) ) {
if($P->className()==$pluginClassName) { $plugin = $plugins['all'][$pluginClassName];
$P->install();
// Plugins for Bludit PRO
$blackList = array('pluginTimeMachine', 'pluginRemoteContent');
if( in_array($pluginClassName, $blackList) && !defined('BLUDIT_PRO') ) {
Redirect::page('plugins');
}
// Install plugin
if( $plugin->install() ) {
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'plugin-installed',
'notes'=>$plugin->name()
));
// Create an alert
Alert::set($Language->g('Plugin installed'));
} }
} }
Redirect::page('admin', 'plugins'); Redirect::page('plugins');

View File

@ -6,7 +6,7 @@
if($Login->role()!=='admin') { if($Login->role()!=='admin') {
Alert::set($Language->g('you-do-not-have-sufficient-permissions')); Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
Redirect::page('admin', 'dashboard'); Redirect::page('dashboard');
} }
// ============================================================================ // ============================================================================
@ -26,14 +26,19 @@ if($Login->role()!=='admin') {
// ============================================================================ // ============================================================================
$themeDirname = $layout['parameters']; $themeDirname = $layout['parameters'];
if( Sanitize::pathFile(PATH_THEMES.$themeDirname) ) if( Sanitize::pathFile(PATH_THEMES.$themeDirname) ) {
{ // Set the theme
$Site->set(array('theme'=>$themeDirname)); $Site->set(array('theme'=>$themeDirname));
Alert::set($Language->g('The changes have been saved'));
} // Add to syslog
else $Syslog->add(array(
{ 'dictionaryKey'=>'new-theme-configured',
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to install the theme: '.$themeDirname); 'notes'=>$themeDirname
));
// Create an alert
Alert::set( $Language->g('The changes have been saved') );
} }
Redirect::page('admin', 'themes'); // Redirect
Redirect::page('themes');

View File

@ -30,7 +30,7 @@ function checkPost($args)
if($username!=false) if($username!=false)
{ {
// Generate the token and the token expiration date. // Generate the token and the token expiration date.
$token = $dbUsers->generateTokenEmail($username); $token = $dbUsers->setTokenEmail($username);
// ---- EMAIL ---- // ---- EMAIL ----
$link = $Site->url().'admin/login-email?tokenEmail='.$token.'&username='.$username; $link = $Site->url().'admin/login-email?tokenEmail='.$token.'&username='.$username;

View File

@ -20,17 +20,17 @@ function checkPost($args)
} }
// Verify User sanitize the input // Verify User sanitize the input
if( $Login->verifyUser($_POST['username'], $_POST['password']) ) if( $Login->verifyUser($_POST['username'], $_POST['password']) ) {
{
// Renew the token. This token will be the same inside the session for multiple forms. // Renew the token. This token will be the same inside the session for multiple forms.
$Security->generateTokenCSRF(); $Security->generateTokenCSRF();
Redirect::page('dashboard');
Redirect::page('admin', 'dashboard');
return true; return true;
} }
// Bruteforce protection, add IP to blacklist. // Bruteforce protection, add IP to blacklist.
$Security->addLoginFail(); $Security->addLoginFail();
// Create alert
Alert::set($Language->g('Username or password incorrect')); Alert::set($Language->g('Username or password incorrect'));
return false; return false;

View File

@ -17,6 +17,7 @@ function add($category)
{ {
global $dbCategories; global $dbCategories;
global $Language; global $Language;
global $Syslog;
if( Text::isEmpty($category) ) { if( Text::isEmpty($category) ) {
Alert::set($Language->g('Category name is empty'), ALERT_STATUS_FAIL); Alert::set($Language->g('Category name is empty'), ALERT_STATUS_FAIL);
@ -24,8 +25,17 @@ function add($category)
} }
if( $dbCategories->add($category) ) { if( $dbCategories->add($category) ) {
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'new-category-created',
'notes'=>$category
));
// Create an alert
Alert::set($Language->g('Category added'), ALERT_STATUS_OK); Alert::set($Language->g('Category added'), ALERT_STATUS_OK);
return true;
// Redirect
Redirect::page('categories');
} }
else { else {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the category.'); Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the category.');
@ -43,9 +53,7 @@ function add($category)
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{ {
if( add($_POST['category']) ) { add($_POST['category']);
Redirect::page('categories');
}
} }
// ============================================================================ // ============================================================================

View File

@ -8,48 +8,6 @@
// Functions // Functions
// ============================================================================ // ============================================================================
function addPage($args)
{
global $dbPages;
global $Language;
global $Syslog;
// Add the page, if the $key is FALSE the creation of the post failure.
$key = $dbPages->add($args);
if($key) {
// Re-index categories
reindexCategories();
// Re-index tags
reindextags();
// Call the plugins after page created
Theme::plugins('afterPageCreate');
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'new-page-created',
'notes'=>$args['title']
));
// Create an alert
Alert::set( $Language->g('Page added successfully') );
// Redirect
Redirect::page('pages');
return true;
}
else {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the page');
Log::set(__METHOD__.LOG_SEP.'Cleaning database...');
$dbPages->delete($key);
}
return false;
}
// ============================================================================ // ============================================================================
// Main before POST // Main before POST
// ============================================================================ // ============================================================================
@ -60,7 +18,11 @@ function addPage($args)
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{ {
addPage($_POST); if( createPage($_POST)!==false ) {
Alert::set( $Language->g('Page added successfully') );
}
Redirect::page('pages');
} }
// ============================================================================ // ============================================================================

View File

@ -6,7 +6,7 @@
if($Login->role()!=='admin') { if($Login->role()!=='admin') {
Alert::set($Language->g('you-do-not-have-sufficient-permissions')); Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
Redirect::page('admin', 'dashboard'); Redirect::page('dashboard');
} }
// ============================================================================ // ============================================================================

View File

@ -17,26 +17,53 @@ function setSettings($args)
{ {
global $Site; global $Site;
global $Language; global $Language;
global $Syslog;
global $dbPages;
// Add slash at the begin and end. // Add slash at the begin and end
// This fields are in the settings->advanced mode
$args['url'] = Text::addSlashes($args['url'],false,true);
$args['uriPage'] = Text::addSlashes($args['uriPage']); $args['uriPage'] = Text::addSlashes($args['uriPage']);
$args['uriTag'] = Text::addSlashes($args['uriTag']); $args['uriTag'] = Text::addSlashes($args['uriTag']);
$args['uriCategory'] = Text::addSlashes($args['uriCategory']); $args['uriCategory'] = Text::addSlashes($args['uriCategory']);
if(($args['uriPost']==$args['uriPage']) || ($args['uriPost']==$args['uriTag']) || ($args['uriPage']==$args['uriTag']) ) if( ($args['uriPage']==$args['uriTag']) ||
{ ($args['uriPage']==$args['uriCategory']) ||
($args['uriTag']==$args['uriCategory'])
) {
$args = array(); $args = array();
} }
if( $Site->set($args) ) { if( $Site->set($args) ) {
Alert::set($Language->g('the-changes-have-been-saved')); // Add to syslog
} $Syslog->add(array(
else { 'dictionaryKey'=>'changes-on-settings',
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the settings.'); 'notes'=>''
));
// Check actual order by, if different than the new settings sort pages
if( $Site->orderBy()!=ORDER_BY ) {
if( $Site->orderBy()=='date' ) {
$dbPages->sortByDate();
}
else {
$dbPages->sortByPosition();
}
// Save database state
$dbPages->save();
// Re-index categories
reindexCategories();
// Re-index tags
reindextags();
}
// Create an alert
Alert::set( $Language->g('The changes have been saved') );
} }
// Redirect
Redirect::page('settings-advanced');
return true; return true;
} }
@ -51,7 +78,6 @@ function setSettings($args)
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{ {
setSettings($_POST); setSettings($_POST);
Redirect::page('admin', $layout['controller']);
} }
// ============================================================================ // ============================================================================

View File

@ -46,9 +46,6 @@ function setSettings($args)
// Redirect // Redirect
Redirect::page('settings-general'); Redirect::page('settings-general');
} }
else {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the settings.');
}
return true; return true;
} }

View File

@ -18,25 +18,18 @@ function setSettings($args)
global $Site; global $Site;
global $Language; global $Language;
// Add slash at the begin and end.
// This fields are in the settings->advanced mode
if(isset($args['form-advanced'])) {
$args['url'] = Text::addSlashes($args['url'],false,true);
$args['uriPost'] = Text::addSlashes($args['uriPost']);
$args['uriPage'] = Text::addSlashes($args['uriPage']);
$args['uriTag'] = Text::addSlashes($args['uriTag']);
if(($args['uriPost']==$args['uriPage']) || ($args['uriPost']==$args['uriTag']) || ($args['uriPage']==$args['uriTag']) )
{
$args = array();
}
}
if( $Site->set($args) ) { if( $Site->set($args) ) {
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'changes-on-settings',
'notes'=>''
));
// Create alert
Alert::set($Language->g('the-changes-have-been-saved')); Alert::set($Language->g('the-changes-have-been-saved'));
}
else { // Redirect
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the settings.'); Redirect::page('settings-regional');
} }
return true; return true;
@ -53,7 +46,6 @@ function setSettings($args)
if( $_SERVER['REQUEST_METHOD'] == 'POST' ) if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{ {
setSettings($_POST); setSettings($_POST);
Redirect::page('admin', $layout['controller']);
} }
// ============================================================================ // ============================================================================

View File

@ -1,80 +0,0 @@
<?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
// ============================================================================
function setSettings($args)
{
global $Site;
global $Language;
// Add slash at the begin and end.
// This fields are in the settings->advanced mode
if(isset($args['form-advanced'])) {
$args['url'] = Text::addSlashes($args['url'],false,true);
$args['uriPost'] = Text::addSlashes($args['uriPost']);
$args['uriPage'] = Text::addSlashes($args['uriPage']);
$args['uriTag'] = Text::addSlashes($args['uriTag']);
if(($args['uriPost']==$args['uriPage']) || ($args['uriPost']==$args['uriTag']) || ($args['uriPage']==$args['uriTag']) )
{
$args = array();
}
}
if( $Site->set($args) ) {
Alert::set($Language->g('the-changes-have-been-saved'));
}
else {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the settings.');
}
return true;
}
// ============================================================================
// Main after POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
{
setSettings($_POST);
Redirect::page('admin', $layout['controller']);
}
// ============================================================================
// Main after POST
// ============================================================================
// Default home page
$_homePageList = array(''=>$Language->g('Show blog'));
foreach($pagesParents as $parentKey=>$pageList)
{
foreach($pageList as $Page)
{
if($parentKey!==NO_PARENT_CHAR) {
$parentTitle = $pages[$Page->parentKey()]->title().'->';
}
else {
$parentTitle = '';
}
if($Page->published()) {
$_homePageList[$Page->key()] = $Language->g('Page').': '.$parentTitle.$Page->title();
}
}
}

View File

@ -6,7 +6,7 @@
if($Login->role()!=='admin') { if($Login->role()!=='admin') {
Alert::set($Language->g('you-do-not-have-sufficient-permissions')); Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
Redirect::page('admin', 'dashboard'); Redirect::page('dashboard');
} }
// ============================================================================ // ============================================================================

View File

@ -6,7 +6,7 @@
if($Login->role()!=='admin') { if($Login->role()!=='admin') {
Alert::set($Language->g('you-do-not-have-sufficient-permissions')); Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
Redirect::page('admin', 'dashboard'); Redirect::page('dashboard');
} }
// ============================================================================ // ============================================================================
@ -29,4 +29,4 @@ $pluginClassName = $layout['parameters'];
$Plugin = new $pluginClassName; $Plugin = new $pluginClassName;
$Plugin->uninstall(); $Plugin->uninstall();
Redirect::page('admin', 'plugins'); Redirect::page('plugins');

View File

@ -8,6 +8,7 @@ function setPassword($username, $new_password, $confirm_password)
{ {
global $dbUsers; global $dbUsers;
global $Language; global $Language;
global $Syslog;
// Password length // Password length
if( strlen($new_password) < 6 ) if( strlen($new_password) < 6 )
@ -20,6 +21,11 @@ function setPassword($username, $new_password, $confirm_password)
{ {
if( $dbUsers->setPassword($username, $new_password) ) { if( $dbUsers->setPassword($username, $new_password) ) {
Alert::set($Language->g('The changes have been saved'), ALERT_STATUS_OK); Alert::set($Language->g('The changes have been saved'), ALERT_STATUS_OK);
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'user-password-changed',
'notes'=>$username
));
return true; return true;
} }
else { else {
@ -51,7 +57,7 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
} }
if( setPassword($_POST['username'], $_POST['new_password'], $_POST['confirm_password']) ) { if( setPassword($_POST['username'], $_POST['new_password'], $_POST['confirm_password']) ) {
Redirect::page('admin', 'users'); Redirect::page('users');
} }
} }
@ -67,7 +73,7 @@ $_user = $dbUsers->getDb($layout['parameters']);
// If the user doesn't exist, redirect to the users list. // If the user doesn't exist, redirect to the users list.
if($_user===false) { if($_user===false) {
Redirect::page('admin', 'users'); Redirect::page('users');
} }
$_user['username'] = $layout['parameters']; $_user['username'] = $layout['parameters'];

View File

@ -6,7 +6,7 @@
if($Login->role()!=='admin') { if($Login->role()!=='admin') {
Alert::set($Language->g('you-do-not-have-sufficient-permissions')); Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
Redirect::page('admin', 'dashboard'); Redirect::page('dashboard');
} }
// ============================================================================ // ============================================================================

View File

@ -11,6 +11,9 @@
} }
.label-draft, .label-draft,
.label-fixed,
.label-sticky,
.label-scheduled,
.label-empty-title, .label-empty-title,
.label-time { .label-time {
background: #A979D1 none repeat scroll 0 0; background: #A979D1 none repeat scroll 0 0;
@ -24,6 +27,14 @@
font-size: 0.8em; font-size: 0.8em;
} }
.label-fixed {
background: #7BD179;
}
.label-scheduled {
background: #7BD179;
}
.label-empty-title { .label-empty-title {
background: #53D192; background: #53D192;
} }
@ -87,14 +98,20 @@ body {
max-width: 1800px; max-width: 1800px;
} }
#bl-navbar img.logo {
height: 25px;
margin-bottom: 8px;
margin-left: 22px;
margin-right: 0px;
}
#bl-navbar a { #bl-navbar a {
color: #fff; color: #fff;
} }
#bl-navbar a.bl-brand { #bl-navbar span.bl-brand {
font-size: 20px; font-size: 15px;
line-height: 60px; line-height: 35px;
margin: 0 0 0 35px;
text-transform: uppercase; text-transform: uppercase;
color: #fff; color: #fff;
} }
@ -105,7 +122,7 @@ body {
#bl-navbar .bl-navbar-right { #bl-navbar .bl-navbar-right {
float: right; float: right;
line-height: 60px; line-height: 35px;
margin: 0 35px 0 0; margin: 0 35px 0 0;
} }
@ -196,6 +213,10 @@ div.dashboard-links h4 {
margin-bottom: -8px !important; margin-bottom: -8px !important;
} }
#dashboard-panel .notification-date {
font-size: 0.8em;
}
/* FORM /* FORM
---------------------------------------------------------------- */ ---------------------------------------------------------------- */
@ -622,82 +643,98 @@ div.plugin-links > span.separator {
list-style-type: none; list-style-type: none;
margin: 15px 0; margin: 15px 0;
padding: 0; padding: 0;
font-size: 0.9em; font-size: 1em;
text-align: center; text-align: center;
} }
#paginator li.next {
margin-left: 1em;
}
#paginator li.previous {
margin-right: 1em;
}
#paginator a { #paginator a {
color: #2672ec; color: #2672ec;
} }
#paginator li { #paginator li {
display: inline; display: inline;
float: none !important; margin: 0 5px;
} }
#paginator li.left {
margin-right: 10px;
}
#paginator li.list {
background: #e0e0e0;
color: #747474;
padding: 2px 11px;
margin: 0px 15px;
}
#paginator li.right {
margin-left: 10px;
}
#paginator li.next {
margin-right: 1em;
}
#paginator li.previous {
margin-left: 1em;
}
/* ----------- PLUGINS FORM ----------- */ /* ----------- PLUGINS FORM ----------- */
#jsformplugin div { #jsformplugin div {
margin-bottom: 1.1em; margin-bottom: 15px;
display: table;
width: 100%;
} }
#jsformplugin label { #jsformplugin button[type=submit] {
margin: 0 0 5px 0 !important; margin-left: 200px;
border-radius: 2px;
padding: 1px 20px;
border: 0;
box-shadow: inset 0 0 5px rgba(0,0,0,.05);
text-shadow: 0 -1px 0 rgba(0,0,0,.1);
line-height: 28px;
min-height: 30px;
font-size: 1rem;
cursor: pointer;
}
#jsformplugin button[type=submit].blue {
background: #007add !important;
color: #fff;
}
#jsformplugin button[type=submit].small {
font-size: 0.9em;
min-height: 20px;
}
#jsformplugin > div > label,
#jsformplugin > div > input[type=text],
#jsformplugin > div > input[type=checkbox],
#jsformplugin > div > textarea,
#jsformplugin > div > select {
display: table-cell;
}
#jsformplugin > div > span.tip {
color: #999;
margin-top: 5px;
font-size: 0.9em;
display: block; display: block;
} }
#jsformplugin div.tip { #jsformplugin > div > label {
font-size: 0.9em; width: 200px;
color: #AAAAAA;
} }
#jsformplugin textarea { #jsformplugin > div > textarea,
min-width: 400px; #jsformplugin > div > input[type=text] {
width: 60%; width: 50%;
}
#jsformplugin > div > select {
width: 35%;
}
#jsformplugin > div > textarea {
min-height: 100px; min-height: 100px;
} }
#jsformplugin input[type=text] { @media (max-width: 960px) {
min-width: 400px;
width: 60%;
height: 37px;
}
#jsformplugin input[type="checkbox"] { #jsformplugin div {
vertical-align: middle; display: block;
margin-left: 0px; }
margin-right: 10px;
}
#jsformplugin label.forCheckbox { #jsformplugin button[type=submit] {
margin-left: 3px; margin: 0;
margin-bottom: 0px !important; }
display: inline-block;
}
#jsformplugin p {
margin-bottom: 0;
} }

View File

@ -1,2 +1,2 @@
/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ /*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
.uk-form-file{display:inline-block;vertical-align:middle;position:relative;overflow:hidden}.uk-form-file input[type=file]{position:absolute;top:0;z-index:1;width:100%;opacity:0;cursor:pointer;left:0;font-size:500px} .uk-form-file{display:inline-block;vertical-align:middle;position:relative;overflow:hidden}.uk-form-file input[type=file]{position:absolute;top:0;z-index:1;width:100%;opacity:0;cursor:pointer;left:0;font-size:500px}

View File

@ -1,2 +1,2 @@
/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ /*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
.uk-placeholder{margin-bottom:15px;padding:15px;border:1px dashed #ddd;background:#fafafa;color:#444}*+.uk-placeholder{margin-top:15px}.uk-placeholder>:last-child{margin-bottom:0}.uk-placeholder-large{padding-top:80px;padding-bottom:80px} .uk-placeholder{margin-bottom:15px;padding:15px;border:1px dashed #ddd;background:#fafafa;color:#444}*+.uk-placeholder{margin-top:15px}.uk-placeholder>:last-child{margin-bottom:0}.uk-placeholder-large{padding-top:80px;padding-bottom:80px}

View File

@ -1,2 +1,2 @@
/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ /*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
.uk-progress{box-sizing:border-box;height:20px;margin-bottom:15px;background:#f5f5f5;overflow:hidden;line-height:20px;box-shadow:inset 0 0 0 1px rgba(0,0,0,.06);border-radius:4px}*+.uk-progress{margin-top:15px}.uk-progress-bar{width:0;height:100%;background:#00a8e6;float:left;-webkit-transition:width .6s ease;transition:width .6s ease;font-size:12px;color:#fff;text-align:center;box-shadow:inset 0 0 5px rgba(0,0,0,.05);text-shadow:0 -1px 0 rgba(0,0,0,.1)}.uk-progress-mini{height:6px}.uk-progress-small{height:12px}.uk-progress-success .uk-progress-bar{background-color:#8cc14c}.uk-progress-warning .uk-progress-bar{background-color:#faa732}.uk-progress-danger .uk-progress-bar{background-color:#da314b}.uk-progress-striped .uk-progress-bar{background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-size:30px 30px}.uk-progress-striped.uk-active .uk-progress-bar{-webkit-animation:uk-progress-bar-stripes 2s linear infinite;animation:uk-progress-bar-stripes 2s linear infinite}@-webkit-keyframes uk-progress-bar-stripes{0%{background-position:0 0}100%{background-position:30px 0}}@keyframes uk-progress-bar-stripes{0%{background-position:0 0}100%{background-position:30px 0}}.uk-progress-mini,.uk-progress-small{border-radius:500px} .uk-progress{box-sizing:border-box;height:20px;margin-bottom:15px;background:#f5f5f5;overflow:hidden;line-height:20px;box-shadow:inset 0 0 0 1px rgba(0,0,0,.06);border-radius:4px}*+.uk-progress{margin-top:15px}.uk-progress-bar{width:0;height:100%;background:#00a8e6;float:left;-webkit-transition:width .6s ease;transition:width .6s ease;font-size:12px;color:#fff;text-align:center;box-shadow:inset 0 0 5px rgba(0,0,0,.05);text-shadow:0 -1px 0 rgba(0,0,0,.1)}.uk-progress-mini{height:6px}.uk-progress-small{height:12px}.uk-progress-success .uk-progress-bar{background-color:#8cc14c}.uk-progress-warning .uk-progress-bar{background-color:#faa732}.uk-progress-danger .uk-progress-bar{background-color:#da314b}.uk-progress-striped .uk-progress-bar{background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-size:30px 30px}.uk-progress-striped.uk-active .uk-progress-bar{-webkit-animation:uk-progress-bar-stripes 2s linear infinite;animation:uk-progress-bar-stripes 2s linear infinite}@-webkit-keyframes uk-progress-bar-stripes{0%{background-position:0 0}100%{background-position:30px 0}}@keyframes uk-progress-bar-stripes{0%{background-position:0 0}100%{background-position:30px 0}}.uk-progress-mini,.uk-progress-small{border-radius:500px}

4
bl-kernel/admin/themes/default/css/uikit/uikit.almost-flat.min.css vendored Normal file → Executable file

File diff suppressed because one or more lines are too long

2
bl-kernel/admin/themes/default/css/uikit/upload.almost-flat.min.css vendored Normal file → Executable file
View File

@ -1,2 +1,2 @@
/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ /*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
.uk-dragover{box-shadow:0 0 20px rgba(100,100,100,.3)} .uk-dragover{box-shadow:0 0 20px rgba(100,100,100,.3)}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1005 B

After

Width:  |  Height:  |  Size: 1.0 KiB

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<svg viewBox="0 0 500 500" xmlns="http://www.w3.org/2000/svg">
<defs>
<pattern id="pattern-0" x="0" y="0" width="20" height="20" patternUnits="userSpaceOnUse" viewBox="0 0 100 100">
<path d="M 0 0 L 50 0 L 50 100 L 0 100 Z" style="fill: black;"/>
</pattern>
</defs>
<path style="fill: rgb(255, 255, 255); stroke: rgb(0, 0, 0); stroke-miterlimit: 4; stroke-dasharray: none; stroke-width: 24.1239;" d="M 145.686 14.63 C 141.613 8.89 130.833 68.155 113.248 128.344 C 108.415 144.89 115.288 161.582 117.782 176.059 C 121.971 183.412 126.134 194.145 129.663 207.523 C 130.852 212.029 131.89 216.619 132.816 221.212 C 123.039 245.985 117.522 274.055 117.522 303.808 C 117.522 331.213 122.224 357.181 130.601 380.471 C 146.382 392.392 161.695 409.741 174.269 431.302 C 180.153 441.39 185.014 451.718 188.888 461.98 C 209.024 476.655 232.243 485.043 256.97 485.043 C 280.324 485.043 302.327 477.571 321.665 464.381 C 325.671 453.331 330.362 441.894 337.169 431.302 C 350.642 410.34 367.256 390.2 384.224 378 C 395.979 359.286 397.512 331.335 396.418 303.808 C 395.283 275.244 391.314 248.191 382.244 224.145 C 383.028 218.304 384.004 212.46 385.214 206.717 C 388.261 192.245 392.179 180.77 396.288 173.244 C 397.911 159.088 403.396 142.737 398.19 126.913 C 377.42 63.769 380.058 117.247 374.011 122.306 C 366.364 128.705 325.935 65.939 327.529 128.344 C 327.702 135.15 328.069 141.8 328.596 148.266 C 307.662 131.942 282.324 152.098 256.136 152.098 C 229.291 152.098 205.058 132.425 183.779 149.512 C 184.059 142.203 184.108 134.65 183.911 126.913 C 182.317 64.508 171.016 50.32 145.686 14.63 Z" id="path2987"/>
<path id="path3763" d="M 256.314 390.825 C 246.312 390.825 223.405 410.421 223.405 423.826 C 223.405 427.497 224.537 430.973 226.554 434.092 C 230.352 435.689 234.037 438.012 237.065 440.902 C 238.481 442.253 239.65 443.635 240.582 445.009 C 245.429 446.974 251.018 448.098 256.97 448.098 C 262.593 448.098 267.889 447.097 272.542 445.33 C 273.509 443.851 274.748 442.358 276.274 440.902 C 279.518 437.806 283.517 435.361 287.6 433.762 C 289.485 430.731 290.537 427.367 290.537 423.826 C 290.537 410.421 266.971 390.825 256.314 390.825 Z" style="fill: rgb(0, 0, 0); stroke: rgb(0, 0, 0); stroke-miterlimit: 4; stroke-dasharray: none; stroke-width: 24.1239;"/>
<path style="fill: rgb(0, 0, 0); stroke: rgb(0, 0, 0); stroke-linecap: butt; stroke-linejoin: miter; stroke-miterlimit: 4; stroke-dasharray: none; stroke-width: 24.1239;" d="M 228.658 314.39 C 264.037 255.967 201.722 177.034 170.636 242.749 C 156.716 272.177 189.433 341.163 228.658 314.39 Z" id="path3779"/>
<path style="fill: rgb(0, 0, 0); stroke: rgb(0, 0, 0); stroke-miterlimit: 4; stroke-width: 18;" d="M 323.461 270.414 C 323.461 276.224 318.143 280.937 311.582 280.937 C 305.022 280.937 299.702 276.224 299.702 270.414 C 299.702 264.6 305.022 259.888 311.582 259.888 C 318.143 259.888 323.461 264.6 323.461 270.414 Z" id="path3785"/>
<path style="stroke: rgb(0, 0, 0); stroke-miterlimit: 4; fill: rgb(255, 255, 255); stroke-width: 24.1239;" d="M 232.976 268.819 C 232.976 284.42 220.013 297.069 204.021 297.069 C 188.032 297.069 175.068 284.42 175.068 268.819 C 175.068 253.21 188.032 240.565 204.021 240.565 C 220.013 240.565 232.976 253.21 232.976 268.819 Z" id="path-1"/>
</svg>

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -8,7 +8,7 @@
<title><?php echo $layout['title'] ?></title> <title><?php echo $layout['title'] ?></title>
<!-- Favicon --> <!-- Favicon -->
<link rel="shortcut icon" type="image/x-icon" href="<?php echo HTML_PATH_ADMIN_THEME.'img/favicon.png' ?>"> <link rel="shortcut icon" type="image/x-icon" href="<?php echo HTML_PATH_ADMIN_THEME.'img/favicon.png?version='.BLUDIT_VERSION ?>">
<!-- CSS --> <!-- CSS -->
<link rel="stylesheet" type="text/css" href="<?php echo HTML_PATH_ADMIN_THEME.'css/uikit/uikit.almost-flat.min.css?version='.BLUDIT_VERSION ?>"> <link rel="stylesheet" type="text/css" href="<?php echo HTML_PATH_ADMIN_THEME.'css/uikit/uikit.almost-flat.min.css?version='.BLUDIT_VERSION ?>">
@ -57,16 +57,14 @@ $(document).ready(function() {
<div class="uk-offcanvas-bar"> <div class="uk-offcanvas-bar">
<ul class="uk-nav uk-nav-offcanvas"> <ul class="uk-nav uk-nav-offcanvas">
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'dashboard' ?>"><?php $L->p('Dashboard') ?></a></li> <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'dashboard' ?>"><?php $L->p('Dashboard') ?></a></li>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-post' ?>"><?php $L->p('New post') ?></a></li> <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><?php $L->p('New content') ?></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-pages' ?>"><?php $L->p('Manage content') ?></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>
<?php if($Login->role() == 'admin') { ?> <?php if($Login->role() == 'admin') { ?>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'categories' ?>"><?php $L->p('Manage categories') ?></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.'users' ?>"><?php $L->p('Manage users') ?></a></li>
<!-- <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'categories' ?>"><?php $L->p('Manage categories') ?></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>
<li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-regional' ?>"><?php $L->p('Language and timezone') ?></a></li> <li><a href="<?php echo HTML_PATH_ADMIN_ROOT.'settings-regional' ?>"><?php $L->p('Language') ?></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.'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>
@ -77,7 +75,8 @@ $(document).ready(function() {
<div class="bl-navbar-bg"> <div class="bl-navbar-bg">
<nav id="bl-navbar"> <nav id="bl-navbar">
<a href="" class="bl-brand">BLUDIT</a> <img id="bludit-logo" class="logo" src="<?php echo HTML_PATH_ADMIN_THEME ?>img/logo.svg" />
<span class="bl-brand">BLUDIT</span>
<div class="bl-navbar-right"> <div class="bl-navbar-right">
<?php $L->p('Welcome') ?> <?php echo $Login->username() ?> - <?php $L->p('Welcome') ?> <?php echo $Login->username() ?> -
@ -103,12 +102,12 @@ $(document).ready(function() {
<li class="uk-nav-header"><?php $L->p('Publish') ?></li> <li class="uk-nav-header"><?php $L->p('Publish') ?></li>
<li <?php echo ($layout['view']=='new-page')?'class="uk-active"':'' ?>> <li <?php echo ($layout['view']=='new-page')?'class="uk-active"':'' ?>>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><?php $L->p('New page') ?></a> <a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><?php $L->p('New content') ?></a>
</li> </li>
<li class="uk-nav-header"><?php $L->p('Manage') ?></li> <li class="uk-nav-header"><?php $L->p('Manage') ?></li>
<li <?php echo ($layout['view']=='manage-pages')?'class="uk-active"':'' ?>> <li <?php echo ($layout['view']=='manage-pages')?'class="uk-active"':'' ?>>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'pages' ?>"><?php $L->p('Pages') ?></a> <a href="<?php echo HTML_PATH_ADMIN_ROOT.'pages' ?>"><?php $L->p('Content') ?></a>
</li> </li>
<li <?php echo ($layout['view']=='categories')?'class="uk-active"':'' ?>> <li <?php echo ($layout['view']=='categories')?'class="uk-active"':'' ?>>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'categories' ?>"><?php $L->p('Categories') ?></a> <a href="<?php echo HTML_PATH_ADMIN_ROOT.'categories' ?>"><?php $L->p('Categories') ?></a>
@ -149,20 +148,6 @@ $(document).ready(function() {
?> ?>
</div> </div>
<?php
if( AUTO_SCROLL ) {
?>
<script>
// Auto scroll
$(document).ready(function () {
$('html, body').animate({
scrollTop: $('#bl-view').offset().top
}, 'slow');
});
</script>
<?php
}
?>
</div> </div>
<!-- Javascript --> <!-- Javascript -->

6
bl-kernel/admin/themes/default/js/uikit/uikit.min.js vendored Normal file → Executable file

File diff suppressed because one or more lines are too long

4
bl-kernel/admin/themes/default/js/uikit/upload.min.js vendored Normal file → Executable file
View File

@ -1,2 +1,2 @@
/*! UIkit 2.26.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ /*! UIkit 2.27.4 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(e){var t;window.UIkit&&(t=e(UIkit)),"function"==typeof define&&define.amd&&define("uikit-upload",["uikit"],function(){return t||e(UIkit)})}(function(e){"use strict";function t(o,a){function r(t,n){var o=new FormData,a=new XMLHttpRequest;if(n.before(n,t)!==!1){for(var r,i=0;r=t[i];i++)o.append(n.param,r);for(var l in n.params)o.append(l,n.params[l]);a.upload.addEventListener("progress",function(e){var t=e.loaded/e.total*100;n.progress(t,e)},!1),a.addEventListener("loadstart",function(e){n.loadstart(e)},!1),a.addEventListener("load",function(e){n.load(e)},!1),a.addEventListener("loadend",function(e){n.loadend(e)},!1),a.addEventListener("error",function(e){n.error(e)},!1),a.addEventListener("abort",function(e){n.abort(e)},!1),a.open(n.method,n.action,!0),"json"==n.type&&a.setRequestHeader("Accept","application/json"),a.onreadystatechange=function(){if(n.readystatechange(a),4==a.readyState){var t=a.responseText;if("json"==n.type)try{t=e.$.parseJSON(t)}catch(o){t=!1}n.complete(t,a)}},n.beforeSend(a),a.send(o)}}if(!e.support.ajaxupload)return this;if(a=e.$.extend({},t.defaults,a),o.length){if("*.*"!==a.allow)for(var i,l=0;i=o[l];l++)if(!n(a.allow,i.name))return"string"==typeof a.notallowed?alert(a.notallowed):a.notallowed(i,a),void 0;var f=a.complete;if(a.single){var s=o.length,d=0,p=!0;a.beforeAll(o),a.complete=function(e,t){d+=1,f(e,t),a.filelimit&&d>=a.filelimit&&(p=!1),p&&s>d?r([o[d]],a):a.allcomplete(e,t)},r([o[0]],a)}else a.complete=function(e,t){f(e,t),a.allcomplete(e,t)},r(o,a)}}function n(e,t){var n="^"+e.replace(/\//g,"\\/").replace(/\*\*/g,"(\\/[^\\/]+)*").replace(/\*/g,"[^\\/]+").replace(/((?!\\))\?/g,"$1.")+"$";return n="^"+n+"$",null!==t.match(new RegExp(n,"i"))}return e.component("uploadSelect",{init:function(){var e=this;this.on("change",function(){t(e.element[0].files,e.options);var n=e.element.clone(!0).data("uploadSelect",e);e.element.replaceWith(n),e.element=n})}}),e.component("uploadDrop",{defaults:{dragoverClass:"uk-dragover"},init:function(){var e=this,n=!1;this.on("drop",function(n){n.originalEvent.dataTransfer&&n.originalEvent.dataTransfer.files&&(n.stopPropagation(),n.preventDefault(),e.element.removeClass(e.options.dragoverClass),e.element.trigger("dropped.uk.upload",[n.originalEvent.dataTransfer.files]),t(n.originalEvent.dataTransfer.files,e.options))}).on("dragenter",function(e){e.stopPropagation(),e.preventDefault()}).on("dragover",function(t){t.stopPropagation(),t.preventDefault(),n||(e.element.addClass(e.options.dragoverClass),n=!0)}).on("dragleave",function(t){t.stopPropagation(),t.preventDefault(),e.element.removeClass(e.options.dragoverClass),n=!1})}}),e.support.ajaxupload=function(){function e(){var e=document.createElement("INPUT");return e.type="file","files"in e}function t(){var e=new XMLHttpRequest;return!!(e&&"upload"in e&&"onprogress"in e.upload)}function n(){return!!window.FormData}return e()&&t()&&n()}(),t.defaults={action:"",single:!0,method:"POST",param:"files[]",params:{},allow:"*.*",type:"text",filelimit:!1,before:function(){},beforeSend:function(){},beforeAll:function(){},loadstart:function(){},load:function(){},loadend:function(){},error:function(){},abort:function(){},progress:function(){},complete:function(){},allcomplete:function(){},readystatechange:function(){},notallowed:function(e,t){alert("Only the following file types are allowed: "+t.allow)}},e.Utils.xhrupload=t,t}); !function(e){var t;window.UIkit2&&(t=e(UIkit2)),"function"==typeof define&&define.amd&&define("uikit-upload",["uikit"],function(){return t||e(UIkit2)})}(function(e){"use strict";function t(o,a){function r(t,n){var o=new FormData,a=new XMLHttpRequest;if(n.before(n,t)!==!1){for(var r,i=0;r=t[i];i++)o.append(n.param,r);for(var l in n.params)o.append(l,n.params[l]);a.upload.addEventListener("progress",function(e){var t=e.loaded/e.total*100;n.progress(t,e)},!1),a.addEventListener("loadstart",function(e){n.loadstart(e)},!1),a.addEventListener("load",function(e){n.load(e)},!1),a.addEventListener("loadend",function(e){n.loadend(e)},!1),a.addEventListener("error",function(e){n.error(e)},!1),a.addEventListener("abort",function(e){n.abort(e)},!1),a.open(n.method,n.action,!0),"json"==n.type&&a.setRequestHeader("Accept","application/json");for(var s in n.headers)a.setRequestHeader(s,n.headers[s]);a.onreadystatechange=function(){if(n.readystatechange(a),4==a.readyState){var t=a.responseText;if("json"==n.type)try{t=e.$.parseJSON(t)}catch(o){t=!1}n.complete(t,a)}},n.beforeSend(a),a.send(o)}}if(!e.support.ajaxupload)return this;if(a=e.$.extend({},t.defaults,a),o.length){if("*.*"!==a.allow)for(var i,l=0;i=o[l];l++)if(!n(a.allow,i.name))return"string"==typeof a.notallowed?alert(a.notallowed):a.notallowed(i,a),void 0;var s=a.complete;if(a.single){var d=o.length,f=0,p=!0;a.beforeAll(o),a.complete=function(e,t){f+=1,s(e,t),a.filelimit&&f>=a.filelimit&&(p=!1),p&&d>f?r([o[f]],a):a.allcomplete(e,t)},r([o[0]],a)}else a.complete=function(e,t){s(e,t),a.allcomplete(e,t)},r(o,a)}}function n(e,t){var n="^"+e.replace(/\//g,"\\/").replace(/\*\*/g,"(\\/[^\\/]+)*").replace(/\*/g,"[^\\/]+").replace(/((?!\\))\?/g,"$1.")+"$";return n="^"+n+"$",null!==t.match(new RegExp(n,"i"))}return e.component("uploadSelect",{init:function(){var e=this;this.on("change",function(){t(e.element[0].files,e.options);var n=e.element.clone(!0).data("uploadSelect",e);e.element.replaceWith(n),e.element=n})}}),e.component("uploadDrop",{defaults:{dragoverClass:"uk-dragover"},init:function(){var e=this,n=!1;this.on("drop",function(n){n.originalEvent.dataTransfer&&n.originalEvent.dataTransfer.files&&(n.stopPropagation(),n.preventDefault(),e.element.removeClass(e.options.dragoverClass),e.element.trigger("dropped.uk.upload",[n.originalEvent.dataTransfer.files]),t(n.originalEvent.dataTransfer.files,e.options))}).on("dragenter",function(e){e.stopPropagation(),e.preventDefault()}).on("dragover",function(t){t.stopPropagation(),t.preventDefault(),n||(e.element.addClass(e.options.dragoverClass),n=!0)}).on("dragleave",function(t){t.stopPropagation(),t.preventDefault(),e.element.removeClass(e.options.dragoverClass),n=!1})}}),e.support.ajaxupload=function(){function e(){var e=document.createElement("INPUT");return e.type="file","files"in e}function t(){var e=new XMLHttpRequest;return!!(e&&"upload"in e&&"onprogress"in e.upload)}function n(){return!!window.FormData}return e()&&t()&&n()}(),t.defaults={action:"",single:!0,method:"POST",param:"files[]",params:{},allow:"*.*",type:"text",filelimit:!1,headers:{},before:function(){},beforeSend:function(){},beforeAll:function(){},loadstart:function(){},load:function(){},loadend:function(){},error:function(){},abort:function(){},progress:function(){},complete:function(){},allcomplete:function(){},readystatechange:function(){},notallowed:function(e,t){alert("Only the following file types are allowed: "+t.allow)}},e.Utils.xhrupload=t,t});

View File

@ -28,16 +28,6 @@ echo '
echo '<td>'.BLUDIT_BUILD.'</td>'; echo '<td>'.BLUDIT_BUILD.'</td>';
echo '</tr>'; echo '</tr>';
echo '<tr>';
echo '<td>PHP version</td>';
echo '<td>'.phpversion().'</td>';
echo '</tr>';
echo '<tr>';
echo '<td>PHP modules</td>';
echo '<td>'.implode(', ',get_loaded_extensions()).')</td>';
echo '</tr>';
echo ' echo '
</tbody> </tbody>
</table> </table>

View File

@ -20,7 +20,7 @@ foreach($categories as $categoryKey=>$category)
{ {
echo '<tr>'; echo '<tr>';
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-category/'.$categoryKey.'">'.$category.'</a></td>'; echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-category/'.$categoryKey.'">'.$category.'</a></td>';
echo '<td><a href="'.DOMAIN.$Url->filters('category', false).$categoryKey.'">'.DOMAIN.$Url->filters('category', false).$categoryKey.'</a></td>'; echo '<td><a href="'.DOMAIN_CATEGORIES.$categoryKey.'">'.$Url->filters('category', false).$categoryKey.'</a></td>';
echo '</tr>'; echo '</tr>';
} }

View File

@ -1,6 +1,6 @@
<?php <?php
HTML::title(array('title'=>$_Plugin->name(), 'icon'=>'puzzle-piece')); HTML::title(array('title'=>$plugin->name(), 'icon'=>'puzzle-piece'));
HTML::formOpen(array('id'=>'jsformplugin')); HTML::formOpen(array('id'=>'jsformplugin'));
@ -11,12 +11,14 @@ HTML::formOpen(array('id'=>'jsformplugin'));
)); ));
// Print the plugin form // Print the plugin form
echo $_Plugin->form(); echo $plugin->form();
// Form buttons if($plugin->formButtons()) {
echo '<div class="uk-form-row uk-margin-bottom"> // Form buttons
<button class="uk-button uk-button-primary" type="submit">'.$L->g('Save').'</button> echo '<div class="uk-form-row uk-margin-bottom">
<a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'plugins">'.$L->g('Cancel').'</a> <button class="uk-button uk-button-primary" type="submit">'.$L->g('Save').'</button>
</div>'; <a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'plugins">'.$L->g('Cancel').'</a>
</div>';
}
HTML::formClose(); HTML::formClose();

View File

@ -4,13 +4,13 @@
<div class="uk-width-medium-1-3"> <div class="uk-width-medium-1-3">
<div class="uk-panel"> <div class="uk-panel">
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-post' ?>"><i class="uk-icon-pencil"></i> <?php $L->p('New post') ?></a></h4> <h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><i class="uk-icon-pencil"></i> <?php $L->p('New content') ?></a></h4>
<p><?php $L->p('Create a new article for your blog') ?></p> <p><?php $L->p('Create a new page for your site') ?></p>
</div> </div>
<div class="uk-panel"> <div class="uk-panel">
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-posts' ?>"><i class="uk-icon-folder-o"></i> <?php $L->p('Manage posts') ?></a></h4> <h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'pages' ?>"><i class="uk-icon-folder-o"></i> <?php $L->p('Manage content') ?></a></h4>
<p><?php $L->p('edit-or-remove-your-blogs-posts') ?></p> <p><?php $L->p('Edit or delete pages from your site') ?></p>
</div> </div>
</div> </div>
@ -18,13 +18,13 @@
<div class="uk-width-medium-1-3" style="border-right: 1px solid #E6E6E6; border-left: 1px solid #E6E6E6"> <div class="uk-width-medium-1-3" style="border-right: 1px solid #E6E6E6; border-left: 1px solid #E6E6E6">
<div class="uk-panel"> <div class="uk-panel">
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-page' ?>"><i class="uk-icon-file-text-o"></i> <?php $L->p('New page') ?></a></h4> <h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'new-category' ?>"><i class="uk-icon-file-text-o"></i> <?php $L->p('New category') ?></a></h4>
<p><?php $L->p('Create a new page for your website') ?></p> <p><?php $L->p('Create a new category to organize your pages') ?></p>
</div> </div>
<div class="uk-panel"> <div class="uk-panel">
<h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'manage-pages' ?>"><i class="uk-icon-folder-o"></i> <?php $L->p('Manage pages') ?></a></h4> <h4><a href="<?php echo HTML_PATH_ADMIN_ROOT.'categories' ?>"><i class="uk-icon-folder-o"></i> <?php $L->p('Manage categories') ?></a></h4>
<p><?php $L->p('edit-or-remove-your=pages') ?></p> <p><?php $L->p('Edit or delete your categories') ?></p>
</div> </div>
</div> </div>
@ -35,7 +35,7 @@
<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 site') ?></p>
</div> </div>
<div class="uk-panel"> <div class="uk-panel">
@ -61,6 +61,52 @@
<div class="uk-width-1-3"> <div class="uk-width-1-3">
<div class="uk-panel">
<h4 class="panel-title"><?php $L->p('Notifications') ?></h4>
<ul class="uk-list uk-list-line">
<?php
$logs = array_slice($Syslog->db, 0, NOTIFICATIONS_AMOUNT);
foreach($logs as $log) {
$dict = $L->g($log['dictionaryKey']);
echo '<li>';
echo $dict;
if( !empty($log['notes'])) {
echo ' ('.$log['notes'].')';
}
echo '<br><span class="notification-date">';
echo Date::format($log['date'], DB_DATE_FORMAT, NOTIFICATIONS_DATE_FORMAT);
echo ' - by '.$log['username'];
echo '</span>';
echo '</li>';
}
?>
</ul>
</div>
</div>
<div class="uk-width-1-3">
<div class="uk-panel">
<h4 class="panel-title"><?php $L->p('Scheduled pages') ?></h4>
<ul class="uk-list">
<?php
$scheduledPages = $dbPages->getScheduledDB();
if( empty($scheduledPages) ) {
echo '<li>'.$Language->g('There are no scheduled pages').'</li>';
}
else {
$keys = array_keys($scheduledPages);
foreach($keys as $key) {
$page = buildPage($key);
echo '<li><span class="label-time">'.$page->dateRaw(SCHEDULED_DATE_FORMAT).'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'.($page->title()?$page->title():'['.$Language->g('Empty title').'] ').'</a></li>';
}
}
?>
</ul>
</div>
<div class="uk-panel"> <div class="uk-panel">
<h4 class="panel-title"><?php $L->p('Statistics') ?></h4> <h4 class="panel-title"><?php $L->p('Statistics') ?></h4>
<table class="uk-table statistics"> <table class="uk-table statistics">
@ -85,12 +131,15 @@
<h4 class="panel-title"><?php $L->p('Drafts') ?></h4> <h4 class="panel-title"><?php $L->p('Drafts') ?></h4>
<ul class="uk-list"> <ul class="uk-list">
<?php <?php
if( empty($_draftPages) ) { $draftPages = $dbPages->getDraftDB();
echo '<li>'.$Language->g('There are no drafts').'</li>'; if( empty($draftPages) ) {
echo '<li>'.$Language->g('There are no draft pages').'</li>';
} }
else { else {
foreach($_draftPages as $Page) { $keys = array_keys($scheduledPages);
echo '<li><span class="label-draft">'.$Language->g('Page').'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.($Page->title()?$Page->title():'['.$Language->g('Empty title').'] ').'</a></li>'; foreach($keys as $key) {
$page = buildPage($key);
echo '<li><span class="label-draft">'.$Language->g('Page').'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'.($page->title()?$page->title():'['.$Language->g('Empty title').'] ').'</a></li>';
} }
} }
?> ?>
@ -99,24 +148,6 @@
</div> </div>
<div class="uk-width-1-3">
<div class="uk-panel">
<h4 class="panel-title"><?php $L->p('Scheduled posts') ?></h4>
<ul class="uk-list">
<?php
if( empty($_scheduledPosts) ) {
echo '<li>'.$Language->g('There are no scheduled posts').'</li>';
}
else {
foreach($_scheduledPosts as $Post) {
echo '<li><span class="label-time">'.$Post->dateRaw(SCHEDULED_DATE_FORMAT).'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-post/'.$Post->key().'">'.($Post->title()?$Post->title():'['.$Language->g('Empty title').'] ').'</a></li>';
}
}
?>
</ul>
</div>
</div>
</div> </div>

View File

@ -0,0 +1,15 @@
<?php
HTML::title(array('title'=>$L->g('Developers'), 'icon'=>'support'));
echo '<h2>PHP version: '.phpversion().'</h2>';
// Constanst defined by Bludit
$constants = get_defined_constants(true);
printTable('Constants', $constants['user']);
// Loaded extensions
printTable('Loaded extensions',get_loaded_extensions());
// Site object
printTable('$Site object database',$Site->db);

View File

@ -1,6 +1,6 @@
<?php <?php
HTML::title(array('title'=>$L->g('Edit page'), 'icon'=>'file-text-o')); HTML::title(array('title'=>$L->g('Edit content'), 'icon'=>'file-text-o'));
HTML::formOpen(array('class'=>'uk-form-stacked')); HTML::formOpen(array('class'=>'uk-form-stacked'));
@ -133,8 +133,13 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
'name'=>'status', 'name'=>'status',
'label'=>$L->g('Status'), 'label'=>$L->g('Status'),
'class'=>'uk-width-1-1 uk-form-medium', 'class'=>'uk-width-1-1 uk-form-medium',
'options'=>array('published'=>$L->g('Published'), 'draft'=>$L->g('Draft')), 'options'=>array(
'selected'=>($page->draft()?'draft':'published'), 'published'=>$L->g('Published'),
'drpaft'=>$L->g('Draft'),
'fixed'=>$L->g('Fixed'),
'sticky'=>$L->g('Sticky')
),
'selected'=>$page->status(),
'tip'=>'' 'tip'=>''
)); ));
@ -147,24 +152,28 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
'label'=>$L->g('Date') 'label'=>$L->g('Date')
)); ));
// If the page is parent then doesn't can have a parent.
if(count($page->children())===0)
{
// Parent input // Parent input
$options = array(); // Check if the page has children
$options[NO_PARENT_CHAR] = '('.$Language->g('No parent').')'; if(count($page->children())===0) {
$options += $dbPages->parentKeyList(); $options = array();
unset($options[$page->key()]); $parentsList = $dbPages->getParents();
$parentsKey = array_keys($parentsList);
foreach($parentsKey as $pageKey) {
$parent = buildPage($pageKey);
$options[$pageKey] = $parent->title();
}
unset($options[$page->key()]);
HTML::formSelect(array( HTML::formSelect(array(
'name'=>'parent', 'name'=>'parent',
'label'=>$L->g('Parent'), 'label'=>$L->g('Parent'),
'class'=>'uk-width-1-1 uk-form-medium', 'class'=>'uk-width-1-1 uk-form-medium',
'options'=>$options, 'options'=>$options,
'selected'=>$page->parentKey(), 'selected'=>$page->parentKey(),
'tip'=>'' 'tip'=>'',
)); 'addEmptySpace'=>true
} ));
}
// Position input // Position input
HTML::formInputText(array( HTML::formInputText(array(

View File

@ -16,7 +16,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
// Security token // Security token
HTML::formInputHidden(array( HTML::formInputHidden(array(
'name'=>'username', 'name'=>'username',
'value'=>$_User->username() 'value'=>$User->username()
)); ));
HTML::legend(array('value'=>$L->g('Profile'), 'class'=>'first-child')); HTML::legend(array('value'=>$L->g('Profile'), 'class'=>'first-child'));
@ -24,7 +24,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
HTML::formInputText(array( HTML::formInputText(array(
'name'=>'usernameDisable', 'name'=>'usernameDisable',
'label'=>$L->g('Username'), 'label'=>$L->g('Username'),
'value'=>$_User->username(), 'value'=>$User->username(),
'class'=>'uk-width-1-2 uk-form-medium', 'class'=>'uk-width-1-2 uk-form-medium',
'disabled'=>true, 'disabled'=>true,
'tip'=>'' 'tip'=>''
@ -33,7 +33,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
HTML::formInputText(array( HTML::formInputText(array(
'name'=>'firstName', 'name'=>'firstName',
'label'=>$L->g('First name'), 'label'=>$L->g('First name'),
'value'=>$_User->firstName(), 'value'=>$User->firstName(),
'class'=>'uk-width-1-2 uk-form-medium', 'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>'' 'tip'=>''
)); ));
@ -41,7 +41,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
HTML::formInputText(array( HTML::formInputText(array(
'name'=>'lastName', 'name'=>'lastName',
'label'=>$L->g('Last name'), 'label'=>$L->g('Last name'),
'value'=>$_User->lastName(), 'value'=>$User->lastName(),
'class'=>'uk-width-1-2 uk-form-medium', 'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>'' 'tip'=>''
)); ));
@ -49,7 +49,7 @@ HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal
echo '<div class="uk-form-row"> echo '<div class="uk-form-row">
<label class="uk-form-label">'.$L->g('password').'</label> <label class="uk-form-label">'.$L->g('password').'</label>
<div class="uk-form-controls"> <div class="uk-form-controls">
<a href="'.HTML_PATH_ADMIN_ROOT.'user-password/'.$_User->username().'">'.$L->g('Change password').'</a> <a href="'.HTML_PATH_ADMIN_ROOT.'user-password/'.$User->username().'">'.$L->g('Change password').'</a>
</div> </div>
</div>'; </div>';
@ -59,7 +59,7 @@ if($Login->role()==='admin') {
'name'=>'role', 'name'=>'role',
'label'=>$L->g('Role'), 'label'=>$L->g('Role'),
'options'=>array('editor'=>$L->g('Editor'), 'admin'=>$L->g('Administrator')), 'options'=>array('editor'=>$L->g('Editor'), 'admin'=>$L->g('Administrator')),
'selected'=>$_User->role(), 'selected'=>$User->role(),
'tip'=>'' 'tip'=>''
)); ));
@ -68,7 +68,7 @@ if($Login->role()==='admin') {
HTML::formInputText(array( HTML::formInputText(array(
'name'=>'email', 'name'=>'email',
'label'=>$L->g('Email'), 'label'=>$L->g('Email'),
'value'=>$_User->email(), 'value'=>$User->email(),
'class'=>'uk-width-1-2 uk-form-medium', 'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>$L->g('email-will-not-be-publicly-displayed') 'tip'=>$L->g('email-will-not-be-publicly-displayed')
)); ));
@ -78,7 +78,7 @@ if($Login->role()==='admin') {
HTML::formInputText(array( HTML::formInputText(array(
'name'=>'twitter', 'name'=>'twitter',
'label'=>'Twitter', 'label'=>'Twitter',
'value'=>$_User->twitter(), 'value'=>$User->twitter(),
'class'=>'uk-width-1-2 uk-form-medium', 'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>'' 'tip'=>''
)); ));
@ -86,7 +86,7 @@ if($Login->role()==='admin') {
HTML::formInputText(array( HTML::formInputText(array(
'name'=>'facebook', 'name'=>'facebook',
'label'=>'Facebook', 'label'=>'Facebook',
'value'=>$_User->facebook(), 'value'=>$User->facebook(),
'class'=>'uk-width-1-2 uk-form-medium', 'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>'' 'tip'=>''
)); ));
@ -94,7 +94,7 @@ if($Login->role()==='admin') {
HTML::formInputText(array( HTML::formInputText(array(
'name'=>'googlePlus', 'name'=>'googlePlus',
'label'=>'Google+', 'label'=>'Google+',
'value'=>$_User->googlePlus(), 'value'=>$User->googlePlus(),
'class'=>'uk-width-1-2 uk-form-medium', 'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>'' 'tip'=>''
)); ));
@ -102,7 +102,7 @@ if($Login->role()==='admin') {
HTML::formInputText(array( HTML::formInputText(array(
'name'=>'instagram', 'name'=>'instagram',
'label'=>'Instagram', 'label'=>'Instagram',
'value'=>$_User->instagram(), 'value'=>$User->instagram(),
'class'=>'uk-width-1-2 uk-form-medium', 'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>'' 'tip'=>''
)); ));
@ -114,18 +114,28 @@ if($Login->role()==='admin') {
</div> </div>
</div>'; </div>';
HTML::legend(array('value'=>$L->g('Authentication Token')));
HTML::formInputText(array(
'name'=>'tokenAuth',
'label'=>$L->g('Token'),
'value'=>$User->tokenAuth(),
'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>$L->g('This token is similar to your password, do not share this token.')
));
HTML::legend(array('value'=>$L->g('Status'))); HTML::legend(array('value'=>$L->g('Status')));
HTML::formInputText(array( HTML::formInputText(array(
'name'=>'status', 'name'=>'status',
'label'=>$L->g('сurrent status'), 'label'=>$L->g('сurrent status'),
'value'=>$_User->enabled()?$L->g('Enabled'):$L->g('Disabled'), 'value'=>$User->enabled()?$L->g('Enabled'):$L->g('Disabled'),
'class'=>'uk-width-1-2 uk-form-medium', 'class'=>'uk-width-1-2 uk-form-medium',
'disabled'=>true, 'disabled'=>true,
'tip'=>$_User->enabled()?'':$L->g('To enable the user you have to set a new password') 'tip'=>$User->enabled()?'':$L->g('To enable the user you have to set a new password')
)); ));
if( $_User->enabled() ) { if( $User->enabled() ) {
echo '<div class="uk-form-row"> echo '<div class="uk-form-row">
<div class="uk-form-controls"> <div class="uk-form-controls">
<button type="submit" id="jsdisable-user" class="delete-button" name="disable-user"><i class="uk-icon-ban"></i> '.$L->g('Disable the user').'</button> <button type="submit" id="jsdisable-user" class="delete-button" name="disable-user"><i class="uk-icon-ban"></i> '.$L->g('Disable the user').'</button>
@ -133,7 +143,7 @@ if( $_User->enabled() ) {
</div>'; </div>';
} }
if( ($Login->role()==='admin') && ($_User->username()!='admin') ) { if( ($Login->role()==='admin') && ($User->username()!='admin') ) {
HTML::legend(array('value'=>$L->g('Delete'))); HTML::legend(array('value'=>$L->g('Delete')));
@ -152,7 +162,7 @@ echo '</div>';
echo '<div class="uk-width-3-10" style="margin-top: 50px; text-align: center;">'; echo '<div class="uk-width-3-10" style="margin-top: 50px; text-align: center;">';
HTML::profileUploader($_User->username()); HTML::profileUploader($User->username());
echo '</div>'; echo '</div>';
echo '</div>'; echo '</div>';

View File

@ -1,6 +1,6 @@
<?php <?php
HTML::title(array('title'=>$L->g('New page'), 'icon'=>'file-text-o')); HTML::title(array('title'=>$L->g('New content'), 'icon'=>'file-text-o'));
HTML::formOpen(array('class'=>'uk-form-stacked')); HTML::formOpen(array('class'=>'uk-form-stacked'));
@ -118,7 +118,12 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
'name'=>'status', 'name'=>'status',
'label'=>$L->g('Status'), 'label'=>$L->g('Status'),
'class'=>'uk-width-1-1 uk-form-medium', 'class'=>'uk-width-1-1 uk-form-medium',
'options'=>array('published'=>$L->g('Published'), 'draft'=>$L->g('Draft')), 'options'=>array(
'published'=>$L->g('Published'),
'draft'=>$L->g('Draft'),
'fixed'=>$L->g('Fixed'),
'sticky'=>$L->g('Sticky')
),
'selected'=>'published', 'selected'=>'published',
'tip'=>'' 'tip'=>''
)); ));
@ -134,9 +139,11 @@ echo '<div class="bl-publish-sidebar uk-width-2-10">';
// Parent input // Parent input
$options = array(); $options = array();
$parents = $dbPages->getParents(true); $parentsList = $dbPages->getParents();
foreach( $parents as $key=>$fields ) { $parentsKey = array_keys($parentsList);
$options[$key] = $pagesKey[$key]->title(); foreach($parentsKey as $pageKey) {
$parent = buildPage($pageKey);
$options[$pageKey] = $parent->title();
} }
HTML::formSelect(array( HTML::formSelect(array(

View File

@ -1,33 +1,35 @@
<?php <?php
HTML::title(array('title'=>$L->g('Manage pages'), 'icon'=>'folder')); HTML::title(array('title'=>$L->g('Manage content'), 'icon'=>'folder'));
echo '<a href="'.HTML_PATH_ADMIN_ROOT.'new-page"><i class="uk-icon-plus"></i> '.$L->g('Add a new page').'</a>'; echo '<a href="'.HTML_PATH_ADMIN_ROOT.'new-page"><i class="uk-icon-plus"></i> '.$L->g('Add new content').'</a>';
echo ' echo '
<table class="uk-table uk-table-striped"> <table class="uk-table uk-table-striped">
<thead> <thead>
<tr> <tr>
<th>'.$L->g('Title').'</th> <th>'.$L->g('Title').'</th>
<th class="uk-text-center">'.$L->g('Position').'</th> ';
echo '<th class="uk-text-center">'.( (ORDER_BY=='date') ? $L->g('Date') : $L->g('Position') ).'</th>';
echo '
<th>'.$L->g('URL').'</th> <th>'.$L->g('URL').'</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
'; ';
foreach($pages as $page) foreach($pages as $page) {
{
$status = false; $status = false;
if($page->scheduled()) { if($page->status()!='published') {
$status = $Language->g('Scheduled'); $status = $Language->g( $page->status() );
}
elseif(!$page->published()) {
$status = $Language->g('Draft');
} }
echo '<tr>'; echo '<tr>';
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'.($status?'<span class="label-draft">'.$status.'</span>':'').($page->title()?$page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ').'</a></td>'; echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$page->key().'">'.($status?'<span class="label-'.$page->status().'">'.$status.'</span>':'').($page->title()?$page->title():'<span class="label-empty-title">'.$Language->g('Empty title').'</span> ').'</a></td>';
echo '<td class="uk-text-center">'.$page->dateRaw().'</td>';
echo '<td class="uk-text-center">'.( (ORDER_BY=='date') ? $page->dateRaw() : $page->position() ).'</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><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>'; echo '<td><a target="_blank" href="'.$page->permalink().'">'.$friendlyURL.'</a></td>';
echo '</tr>'; echo '</tr>';
@ -36,4 +38,26 @@ foreach($pages as $page)
echo ' echo '
</tbody> </tbody>
</table> </table>
'; ';
?>
<!-- Paginator -->
<div id="paginator">
<ul>
<?php
// Show previus page link
if(Paginator::showPrev()) {
echo '<li class="first"><a href="'.Paginator::prevPageUrl().'" class="previous"><- Previous</a></li>';
}
for($i=1; $i<=Paginator::amountOfPages(); $i++) {
echo '<li><a href='.Paginator::absoluteUrl($i).' class="page">'.$i.'</a></li>';
}
// Show next page link
if(Paginator::showNext()) {
echo '<li class="next"><a href="'.Paginator::nextPageUrl().'" class="next">Next -></a></li>';
}
?>
</ul>
</div>

View File

@ -17,40 +17,39 @@ echo '
foreach($plugins['all'] as $Plugin) foreach($plugins['all'] as $Plugin)
{ {
echo ' echo '<tr '.($Plugin->installed()?'class="plugin-installed"':'class="plugin-notInstalled"').'>
<tr '.($Plugin->installed()?'class="plugin-installed"':'class="plugin-notInstalled"').'>
<td> <td>
<div class="plugin-name"> <div class="plugin-name">'.$Plugin->name().'</div>
'; <div class="plugin-links">';
if($Plugin->installed()) { if($Plugin->installed()) {
echo '<a class="uninstall" href="'.HTML_PATH_ADMIN_ROOT.'uninstall-plugin/'.$Plugin->className().'" title="'.$L->g('Deactivate').'"><i class="uk-icon-check-square-o"></i></a> ';
if(method_exists($Plugin, 'form')) { if(method_exists($Plugin, 'form')) {
echo '<a class="configure" href="'.HTML_PATH_ADMIN_ROOT.'configure-plugin/'.$Plugin->className().'" title="'.$L->g('Settings').'"><i class="uk-icon-cog settings-icon"></i></a> '; echo '<a class="configure" href="'.HTML_PATH_ADMIN_ROOT.'configure-plugin/'.$Plugin->className().'">'.$L->g('Settings').'</a>';
echo '<span class="separator"> | </span>';
} }
echo '<a class="uninstall" href="'.HTML_PATH_ADMIN_ROOT.'uninstall-plugin/'.$Plugin->className().'">'.$L->g('Deactivate').'</a>';
} }
else { else {
echo '<a class="install" href="'.HTML_PATH_ADMIN_ROOT.'install-plugin/'.$Plugin->className().'" title="'.$L->g('Activate').'"><i class="uk-icon-square-o"></i></a> '; echo '<a class="install" href="'.HTML_PATH_ADMIN_ROOT.'install-plugin/'.$Plugin->className().'">'.$L->g('Activate').'</a>';
} }
echo '
'.$Plugin->name().'</div>
</td>'; echo '</div>';
echo '</td>';
echo '<td>'; echo '<td>';
echo $Plugin->description(); echo $Plugin->description();
echo '</td>'; echo '</td>';
echo '
<td class="uk-text-center">'; echo '<td class="uk-text-center">';
if( !$Plugin->isCompatible() ) { if( !$Plugin->isCompatible() ) {
echo '<i class="uk-icon-exclamation-triangle incompatible-warning" title="'.$L->g('This plugin may not be supported by this version of Bludit').'"></i>'; echo '<i class="uk-icon-exclamation-triangle incompatible-warning" title="'.$L->g('This plugin may not be supported by this version of Bludit').'"></i>';
} }
echo '<span>'.$Plugin->version().'</span>';
echo '</td>';
echo '<span>'.$Plugin->version().'</span></td>'; echo '<td class="uk-text-center"><a target="_blank" href="'.$Plugin->website().'">'.$Plugin->author().'</a></td>';
echo '
<td class="uk-text-center"><a target="_blank" href="'.$Plugin->website().'">'.$Plugin->author().'</a></td>
';
echo '</tr>'; echo '</tr>';
} }

View File

@ -4,81 +4,82 @@ HTML::title(array('title'=>$L->g('Advanced settings'), 'icon'=>'cogs'));
HTML::formOpen(array('class'=>'uk-form-horizontal')); HTML::formOpen(array('class'=>'uk-form-horizontal'));
HTML::formInputHidden(array( HTML::formInputHidden(array(
'name'=>'tokenCSRF', 'name'=>'tokenCSRF',
'value'=>$Security->getTokenCSRF() 'value'=>$Security->getTokenCSRF()
)); ));
HTML::legend(array('value'=>$L->g('General'), 'class'=>'first-child')); HTML::legend(array('value'=>$L->g('General'), 'class'=>'first-child'));
HTML::formSelect(array( HTML::formSelect(array(
'name'=>'itemsPerPage', 'name'=>'itemsPerPage',
'label'=>$L->g('Items per page'), 'label'=>$L->g('Items per page'),
'options'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8'), 'options'=>array('1'=>'1','2'=>'2','3'=>'3','4'=>'4','5'=>'5','6'=>'6','7'=>'7','8'=>'8'),
'selected'=>$Site->itemsPerPage(), 'selected'=>$Site->itemsPerPage(),
'class'=>'uk-width-1-3 uk-form-medium', 'class'=>'uk-width-1-3 uk-form-medium',
'tip'=>$L->g('number-of-posts-to-show-per-page') 'tip'=>$L->g('Number of items to show per page')
)); ));
HTML::formInputText(array( HTML::formInputText(array(
'name'=>'url', 'name'=>'url',
'label'=>$L->g('Site URL'), 'label'=>$L->g('Site URL'),
'value'=>$Site->url(), 'value'=>$Site->url(),
'class'=>'uk-width-1-2 uk-form-medium', 'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>$L->g('the-url-of-your-site') 'tip'=>$L->g('the-url-of-your-site')
)); ));
HTML::legend(array('value'=>$L->g('Website or Blog'))); HTML::legend(array('value'=>$L->g('Website or Blog')));
HTML::formSelect(array( HTML::formSelect(array(
'name'=>'orderBy', 'name'=>'orderBy',
'label'=>$L->g('Order Pages By'), 'label'=>$L->g('Order content By'),
'options'=>array('date'=>'Date','position'=>'Position'), 'options'=>array('date'=>'Date','position'=>'Position'),
'selected'=>$Site->orderBy(), 'selected'=>$Site->orderBy(),
'class'=>'uk-width-1-3 uk-form-medium', 'class'=>'uk-width-1-3 uk-form-medium',
'tip'=>$L->g('Order the pages by date to create a Blog or order the pages by position to create a Website') 'tip'=>$L->g('Order the content by date to create a Blog or order the content by position to create a Website')
)); ));
HTML::legend(array('value'=>$L->g('Email account settings'))); HTML::legend(array('value'=>$L->g('Email account settings')));
HTML::formInputText(array( HTML::formInputText(array(
'name'=>'emailFrom', 'name'=>'emailFrom',
'label'=>$L->g('Sender email'), 'label'=>$L->g('Sender email'),
'value'=>$Site->emailFrom(), 'value'=>$Site->emailFrom(),
'class'=>'uk-width-1-2 uk-form-medium', 'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>$L->g('Emails will be sent from this address') 'tip'=>$L->g('Emails will be sent from this address')
)); ));
HTML::legend(array('value'=>$L->g('URL Filters'))); HTML::legend(array('value'=>$L->g('URL Filters')));
HTML::formInputText(array( HTML::formInputText(array(
'name'=>'uriPage', 'name'=>'uriPage',
'label'=>$L->g('Pages'), 'label'=>$L->g('Pages'),
'value'=>$Site->uriFilters('page'), 'value'=>$Site->uriFilters('page'),
'class'=>'uk-width-1-2 uk-form-medium', 'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>'' 'tip'=>DOMAIN_PAGES
)); ));
HTML::formInputText(array( HTML::formInputText(array(
'name'=>'uriTag', 'name'=>'uriTag',
'label'=>$L->g('Tags'), 'label'=>$L->g('Tags'),
'value'=>$Site->uriFilters('tag'), 'value'=>$Site->uriFilters('tag'),
'class'=>'uk-width-1-2 uk-form-medium', 'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>'' 'tip'=>DOMAIN_TAGS
)); ));
HTML::formInputText(array( HTML::formInputText(array(
'name'=>'uriCategory', 'name'=>'uriCategory',
'label'=>$L->g('Category'), 'label'=>$L->g('Category'),
'value'=>$Site->uriFilters('category'), 'value'=>$Site->uriFilters('category'),
'class'=>'uk-width-1-2 uk-form-medium', 'class'=>'uk-width-1-2 uk-form-medium',
'tip'=>'' 'tip'=>DOMAIN_CATEGORIES
)); ));
echo '<div class="uk-form-row"> echo '<div class="uk-form-row">
<div class="uk-form-controls"> <div class="uk-form-controls">
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button> <button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
</div> <a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'settings-advanced">'.$L->g('Cancel').'</a>
</div>'; </div>
</div>';
HTML::formClose(); HTML::formClose();

View File

@ -89,6 +89,7 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
echo '<div class="uk-form-row"> echo '<div class="uk-form-row">
<div class="uk-form-controls"> <div class="uk-form-controls">
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button> <button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
<a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'settings-general">'.$L->g('Cancel').'</a>
</div> </div>
</div>'; </div>';

View File

@ -50,6 +50,7 @@ HTML::formOpen(array('class'=>'uk-form-horizontal'));
echo '<div class="uk-form-row"> echo '<div class="uk-form-row">
<div class="uk-form-controls"> <div class="uk-form-controls">
<button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button> <button type="submit" class="uk-button uk-button-primary">'.$L->g('Save').'</button>
<a class="uk-button" href="'.HTML_PATH_ADMIN_ROOT.'settings-regional">'.$L->g('Cancel').'</a>
</div> </div>
</div>'; </div>';

View File

@ -20,34 +20,30 @@ foreach($themes as $theme)
echo ' echo '
<tr '.($theme['dirname']==$Site->theme()?'class="theme-installed"':'class="theme-notInstalled"').'> <tr '.($theme['dirname']==$Site->theme()?'class="theme-installed"':'class="theme-notInstalled"').'>
<td> <td>
<div class="plugin-name"> <div class="plugin-name">'.$theme['name'].'</div>
<div class="plugin-links">
'; ';
if($theme['dirname']!=$Site->theme()) { if($theme['dirname']!=$Site->theme()) {
echo '<a class="install" href="'.HTML_PATH_ADMIN_ROOT.'install-theme/'.$theme['dirname'].'" title="'.$L->g('Activate').'"><i class="uk-icon-square-o"></i></a> '; echo '<a class="install" href="'.HTML_PATH_ADMIN_ROOT.'install-theme/'.$theme['dirname'].'">'.$L->g('Activate').'</a>';
}
else {
echo '<i class="uk-icon-check-square-o"></i> ';
} }
echo ' echo '
'.$theme['name'].'</div> </div>
</td>'; </td>';
echo '<td>'; echo '<td>';
echo $theme['description']; echo $theme['description'];
echo '</td>'; echo '</td>';
echo '
<td class="uk-text-center">';
echo '<td class="uk-text-center">';
if( !$theme['compatible'] ) { if( !$theme['compatible'] ) {
echo '<i class="uk-icon-exclamation-triangle incompatible-warning" title="This theme is incompatible with Bludit v'.BLUDIT_VERSION.'"></i>'; echo '<i class="uk-icon-exclamation-triangle incompatible-warning" title="'.$L->g('This plugin may not be supported by this version of Bludit').'"></i>';
} }
echo $theme['version'].'</td>'; echo $theme['version'];
echo '</td>';
echo ' echo '<td class="uk-text-center"><a targe="_blank" href="'.$theme['website'].'">'.$theme['author'].'</a></td>';
<td class="uk-text-center"><a target="_blank" href="'.$theme['website'].'">'.$theme['author'].'</a></td>
';
echo '</tr>'; echo '</tr>';
} }

View File

@ -95,4 +95,4 @@ else
// Load plugins after the admin area is loaded. // Load plugins after the admin area is loaded.
Theme::plugins('afterAdminLoad'); Theme::plugins('afterAdminLoad');
} }

View File

@ -55,9 +55,7 @@ define('DB_SITE', PATH_DATABASES.'site.php');
define('DB_CATEGORIES', PATH_DATABASES.'categories.php'); define('DB_CATEGORIES', PATH_DATABASES.'categories.php');
define('DB_TAGS', PATH_DATABASES.'tags.php'); define('DB_TAGS', PATH_DATABASES.'tags.php');
define('DB_SYSLOG', PATH_DATABASES.'syslog.php'); define('DB_SYSLOG', PATH_DATABASES.'syslog.php');
define('DB_USERS', PATH_DATABASES.'users.php');
// ADMIN URI FILTER
define('ADMIN_URI_FILTER', '/admin/');
// Log separator // Log separator
define('LOG_SEP', ' | '); define('LOG_SEP', ' | ');
@ -70,9 +68,6 @@ if(!defined('JSON_PRETTY_PRINT')) {
// Protecting against Symlink attacks // Protecting against Symlink attacks
define('CHECK_SYMBOLIC_LINKS', TRUE); define('CHECK_SYMBOLIC_LINKS', TRUE);
// Auto scroll
define('AUTO_SCROLL', TRUE);
// Alert status ok // Alert status ok
define('ALERT_STATUS_OK', 0); define('ALERT_STATUS_OK', 0);
@ -125,6 +120,12 @@ define('SITEMAP_DATE_FORMAT', 'Y-m-d');
// Date format for Dashboard schedule posts // Date format for Dashboard schedule posts
define('SCHEDULED_DATE_FORMAT', 'd M - h:i a'); define('SCHEDULED_DATE_FORMAT', 'd M - h:i a');
// Notifications date format
define('NOTIFICATIONS_DATE_FORMAT', 'F j, Y, g:i a');
// Amount of items to show on notification panel
define('NOTIFICATIONS_AMOUNT', 10);
// Token time to live for login via email. The offset is defined by http://php.net/manual/en/datetime.modify.php // Token time to live for login via email. The offset is defined by http://php.net/manual/en/datetime.modify.php
define('TOKEN_EMAIL_TTL', '+15 minutes'); define('TOKEN_EMAIL_TTL', '+15 minutes');
@ -137,6 +138,9 @@ define('EXTREME_FRIENDLY_URL', FALSE);
// Permissions for new directories // Permissions for new directories
define('DIR_PERMISSIONS', 0755); define('DIR_PERMISSIONS', 0755);
// Admin URI filter
define('ADMIN_URI_FILTER', '/admin/');
// Set internal character encoding // Set internal character encoding
mb_internal_encoding(CHARSET); mb_internal_encoding(CHARSET);
@ -181,6 +185,12 @@ include(PATH_HELPERS.'filesystem.class.php');
include(PATH_HELPERS.'alert.class.php'); include(PATH_HELPERS.'alert.class.php');
include(PATH_HELPERS.'paginator.class.php'); include(PATH_HELPERS.'paginator.class.php');
include(PATH_HELPERS.'image.class.php'); include(PATH_HELPERS.'image.class.php');
include(PATH_HELPERS.'tcp.class.php');
// Include Bludit PRO
if( file_exists(PATH_KERNEL.'bludit.pro.php') ) {
include(PATH_KERNEL.'bludit.pro.php');
}
// Session // Session
Session::start(); Session::start();
@ -245,9 +255,27 @@ define('HTML_PATH_PLUGINS', HTML_PATH_ROOT.'bl-plugins/');
define('JQUERY', HTML_PATH_ROOT.'bl-kernel/js/jquery.min.js'); define('JQUERY', HTML_PATH_ROOT.'bl-kernel/js/jquery.min.js');
// --- Objects with dependency ---
$Language = new dbLanguage( $Site->locale() );
$Login = new Login( $dbUsers );
$Url->checkFilters( $Site->uriFilters() );
// --- CONSTANTS with dependency ---
// Tag URI filter
define('TAG_URI_FILTER', $Url->filters('tag'));
// Category URI filter
define('CATEGORY_URI_FILTER', $Url->filters('category'));
// Page URI filter
define('PAGE_URI_FILTER', $Url->filters('page'));
// Content order by: date / position
define('ORDER_BY', $Site->orderBy());
// --- PHP paths with dependency --- // --- PHP paths with dependency ---
// This paths are absolutes for the OS // This paths are absolutes for the OS
// Depreacted, use THEME_DIR and THEME_DIR_XXX
define('THEME_DIR', PATH_ROOT.'bl-themes'.DS.$Site->theme().DS); define('THEME_DIR', PATH_ROOT.'bl-themes'.DS.$Site->theme().DS);
define('THEME_DIR_PHP', THEME_DIR.'php'.DS); define('THEME_DIR_PHP', THEME_DIR.'php'.DS);
define('THEME_DIR_CSS', THEME_DIR.'css'.DS); define('THEME_DIR_CSS', THEME_DIR.'css'.DS);
@ -259,6 +287,7 @@ define('THEME_DIR_LANG', THEME_DIR.'languages'.DS);
// This paths are absolutes for the user / web browsing. // This paths are absolutes for the user / web browsing.
define('DOMAIN', $Site->domain()); define('DOMAIN', $Site->domain());
define('DOMAIN_BASE', DOMAIN.HTML_PATH_ROOT); define('DOMAIN_BASE', DOMAIN.HTML_PATH_ROOT);
define('DOMAIN_THEME', DOMAIN.HTML_PATH_THEME);
define('DOMAIN_THEME_CSS', DOMAIN.HTML_PATH_THEME_CSS); define('DOMAIN_THEME_CSS', DOMAIN.HTML_PATH_THEME_CSS);
define('DOMAIN_THEME_JS', DOMAIN.HTML_PATH_THEME_JS); define('DOMAIN_THEME_JS', DOMAIN.HTML_PATH_THEME_JS);
define('DOMAIN_THEME_IMG', DOMAIN.HTML_PATH_THEME_IMG); define('DOMAIN_THEME_IMG', DOMAIN.HTML_PATH_THEME_IMG);
@ -266,22 +295,19 @@ define('DOMAIN_UPLOADS', DOMAIN.HTML_PATH_UPLOADS);
define('DOMAIN_UPLOADS_PROFILES', DOMAIN.HTML_PATH_UPLOADS_PROFILES); define('DOMAIN_UPLOADS_PROFILES', DOMAIN.HTML_PATH_UPLOADS_PROFILES);
define('DOMAIN_UPLOADS_THUMBNAILS', DOMAIN.HTML_PATH_UPLOADS_THUMBNAILS); define('DOMAIN_UPLOADS_THUMBNAILS', DOMAIN.HTML_PATH_UPLOADS_THUMBNAILS);
// --- Objects with dependency --- define('DOMAIN_TAGS', Text::addSlashes(DOMAIN_BASE.TAG_URI_FILTER, false, true));
$Language = new dbLanguage( $Site->locale() ); define('DOMAIN_CATEGORIES', Text::addSlashes(DOMAIN_BASE.CATEGORY_URI_FILTER, false, true));
$Login = new Login( $dbUsers ); define('DOMAIN_PAGES', Text::addSlashes(DOMAIN_BASE.PAGE_URI_FILTER, false, true));
$Url->checkFilters( $Site->uriFilters() );
// --- Objects shortcuts ---
$L = $Language;
// --- CONSTANTS with dependency ---
define('ORDER_BY', $Site->orderBy());
$ADMIN_CONTROLLER = ''; $ADMIN_CONTROLLER = '';
$ADMIN_VIEW = ''; $ADMIN_VIEW = '';
$ID_EXECUTION = uniqid(); // string 13 characters long $ID_EXECUTION = uniqid(); // string 13 characters long
$WHERE_AM_I = $Url->whereAmI();
// --- Objects shortcuts ---
$L = $Language;
// DEBUG: Print constants // DEBUG: Print constants
// $arr = array_filter(get_defined_constants(), 'is_string'); // $arr = array_filter(get_defined_constants(), 'is_string');
// echo json_encode($arr); // echo json_encode($arr);
// exit; // exit;

View File

@ -23,7 +23,8 @@ $plugins = array(
'adminSidebar'=>array(), 'adminSidebar'=>array(),
'beforeRulesLoad'=>array(), 'beforeRulesLoad'=>array(),
'afterFormSave'=>array(), 'beforeAll'=>array(),
'afterAll'=>array(),
'afterPageCreate'=>array(), 'afterPageCreate'=>array(),
'afterPageModify'=>array(), 'afterPageModify'=>array(),
@ -91,7 +92,7 @@ function buildPlugins()
$Language->add($database); $Language->add($database);
} }
// Push Plugin to array all plugins installed and not installed. // Array with plugin all plugins, installed and not installed
$plugins['all'][$pluginClass] = $Plugin; $plugins['all'][$pluginClass] = $Plugin;
// If the plugin is installed, order by hooks. // If the plugin is installed, order by hooks.

View File

@ -7,17 +7,17 @@
// Array with all published pages // Array with all published pages
$pages = array(); $pages = array();
// Array with all pages (published, draft, scheduled) // Array with all pages (published, fixed, sticky, draft, scheduled)
$allPages = array(); $allPages = array();
// Object Page for the page filtered bye the user // Object Page for the page filtered by the user
$page = false; $page = $Page = false;
// Array with all page parents published // Array with all page parents published
//$pageParents = array(); //$pageParents = array();
// Array with all published pages, the array is a key=>Page-object // Array with all published pages, the array is a key=>Page-object
$pagesKey = array(); $pagesByKey = array();
// ============================================================================ // ============================================================================
// Main // Main
@ -30,20 +30,26 @@ if( $dbPages->scheduler() ) {
// Reindex categories // Reindex categories
reindexCategories(); reindexCategories();
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'page-published-from-scheduler',
'notes'=>''
));
} }
// Build specific page // Build specific page
if( $Url->whereAmI()==='page' ) { if( $Url->whereAmI()==='page' ) {
// Build the page // Build the page
$page = buildPage( $Url->slug() ); $page = $Page = buildPage( $Url->slug() );
// The page doesn't exist // The page doesn't exist
if($page===false) { if($page===false) {
$Url->setNotFound(true); $Url->setNotFound(true);
} }
// The page is not published // The page is not published, still scheduled or draft
elseif( !$page->published() ) { elseif( $page->scheduled() || $page->draft() ) {
$Url->setNotFound(true); $Url->setNotFound(true);
} }
else { else {
@ -63,7 +69,9 @@ elseif( $Url->whereAmI()==='admin' ) {
buildPagesForAdmin(); buildPagesForAdmin();
} }
// Set page 404 not found
if( $Url->notFound() ) { if( $Url->notFound() ) {
$Url->setWhereAmI('page'); $Url->setWhereAmI('page');
$page = new Page('error'); $page = buildPage('error');
$pages[0] = $page;
} }

View File

@ -30,20 +30,25 @@ Paginator::set('itemsPerPage', $itemsPerPage);
Paginator::set('amountOfItems', $amountOfItems); Paginator::set('amountOfItems', $amountOfItems);
// Amount of pages // Amount of pages
$amountOfPages = (int) max(ceil($amountOfItems / $itemsPerPage) -1, 0); $amountOfPages = (int) max(ceil($amountOfItems / $itemsPerPage), 1);
Paginator::set('amountOfPages', $amountOfPages); Paginator::set('amountOfPages', $amountOfPages);
$showOlder = $amountOfPages > $currentPage; // TRUE if exists a next page to show
Paginator::set('showOlder', $showOlder); $showNext = $amountOfPages > $currentPage;
Paginator::set('showNext', $showNext);
$showNewer = $currentPage > 0; // TRUE if exists a previous page to show
Paginator::set('showNewer', $showNewer); $showPrev = $currentPage > Paginator::firstPage();
Paginator::set('showPrev', $showPrev);
$show = $showNewer && $showOlder; // TRUE if exists a next and previous page to show
Paginator::set('show', true); $showNextPrev = $showNext && $showPrev;
Paginator::set('showNextPrev', $showNextPrev);
// Integer with the next page
$nextPage = max(0, $currentPage+1); $nextPage = max(0, $currentPage+1);
Paginator::set('nextPage', $nextPage); Paginator::set('nextPage', $nextPage);
// Integer with the previous page
$prevPage = min($amountOfPages, $currentPage-1); $prevPage = min($amountOfPages, $currentPage-1);
Paginator::set('prevPage', $prevPage); Paginator::set('prevPage', $prevPage);

View File

@ -45,11 +45,14 @@ function buildThemes()
$metadata = json_decode($metadataString, true); $metadata = json_decode($metadataString, true);
$database['compatible'] = false; $database['compatible'] = false;
if( !empty($metadata['compatible']) ) { if( !empty($metadata['compatible']) ) {
$explode = explode(',', $metadata['compatible']); $bluditRoot = explode('.', BLUDIT_VERSION);
if(in_array(BLUDIT_VERSION, $explode)) { $compatible = explode(',', $metadata['compatible']);
$database['compatible'] = true; foreach( $compatible as $version ) {
$root = explode('.', $version);
if( $root[0]==$bluditRoot[0] && $root[1]==$bluditRoot[1] ) {
$database['compatible'] = true;
}
} }
} }

View File

@ -3,8 +3,8 @@
// Load plugins rules // Load plugins rules
include(PATH_RULES.'60.plugins.php'); include(PATH_RULES.'60.plugins.php');
// Plugins before rules loaded // Plugins before all
Theme::plugins('beforeRulesLoad'); Theme::plugins('beforeAll');
// Load rules // Load rules
include(PATH_RULES.'69.pages.php'); include(PATH_RULES.'69.pages.php');
@ -30,3 +30,6 @@ else {
// Plugins after site loaded // Plugins after site loaded
Theme::plugins('afterSiteLoad'); Theme::plugins('afterSiteLoad');
// Plugins after all
Theme::plugins('afterAll');

View File

@ -21,8 +21,9 @@ class dbCategories extends dbList
$this->db[$key]['list'] = array(); $this->db[$key]['list'] = array();
} }
// Foreach post in the database // Get a database with published pages
$db = $dbPages->getDB(); $db = $dbPages->getPublishedDB();
foreach($db as $pageKey=>$pageFields) { foreach($db as $pageKey=>$pageFields) {
if( !empty($pageFields['category']) ) { if( !empty($pageFields['category']) ) {
$categoryKey = $pageFields['category']; $categoryKey = $pageFields['category'];

View File

@ -18,7 +18,7 @@ class dbPages extends dbJSON
'category'=> array('inFile'=>false, 'value'=>''), 'category'=> array('inFile'=>false, 'value'=>''),
'md5file'=> array('inFile'=>false, 'value'=>''), 'md5file'=> array('inFile'=>false, 'value'=>''),
'uuid'=> array('inFile'=>false, 'value'=>''), 'uuid'=> array('inFile'=>false, 'value'=>''),
'allowComments'=> array('inFile'=>false, 'value'=>false) 'allowComments'=> array('inFile'=>false, 'value'=>true)
); );
function __construct() function __construct()
@ -27,28 +27,22 @@ class dbPages extends dbJSON
} }
// Create a new page // Create a new page
public function add($args) public function add($args, $climode=false)
{ {
$dataForDb = array(); // This data will be saved in the database $dataForDb = array(); // This data will be saved in the database
$dataForFile = array(); // This data will be saved in the file $dataForFile = array(); // This data will be saved in the file
// The user is always the one loggued
$args['username'] = Session::get('username');
if( Text::isEmpty($args['username']) ) {
return false;
}
// Generate key // Generate key
$key = $this->generateKey($args['slug'], $args['parent']); $key = $this->generateKey($args['slug'], $args['parent']);
// Generate UUID // Generate UUID
$args['uuid'] = md5( uniqid() ); $args['uuid'] = $this->generateUUID();
// Date // Date
$currentDate = Date::current(DB_DATE_FORMAT); $currentDate = Date::current(DB_DATE_FORMAT);
// Validate date // Validate date
if(!Valid::date($args['date'], DB_DATE_FORMAT)) { if( !Valid::date($args['date'], DB_DATE_FORMAT) ) {
$args['date'] = $currentDate; $args['date'] = $currentDate;
} }
@ -90,48 +84,44 @@ class dbPages extends dbJSON
} }
} }
// Create the directory if( $climode===false ) {
if( Filesystem::mkdir(PATH_PAGES.$key, true) === false ) { // Create the directory
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the directory '.PATH_PAGES.$key); if( Filesystem::mkdir(PATH_PAGES.$key, true) === false ) {
return false; Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to create the directory '.PATH_PAGES.$key);
return false;
}
// Make the index.txt and save the file.
$data = implode("\n", $dataForFile);
if( file_put_contents(PATH_PAGES.$key.DS.FILENAME, $data) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME);
return false;
}
} }
// Make the index.txt and save the file. // Checksum MD5
$data = implode("\n", $dataForFile); $dataForDb['md5file'] = md5_file(PATH_PAGES.$key.DS.FILENAME);
if( file_put_contents(PATH_PAGES.$key.DS.FILENAME, $data) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME);
return false;
}
// Insert in database // Insert in database
$this->db[$key] = $dataForDb; $this->db[$key] = $dataForDb;
// Sort database // Sort database
$this->sortByDate(); $this->sortBy();
// Save database // Save database
if( $this->save() === false ) { $this->save();
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
return false;
}
return $key; return $key;
} }
public function edit($args) public function edit($args, $climode=false)
{ {
$dataForDb = array(); $dataForDb = array();
$dataForFile = array(); $dataForFile = array();
// The user is always the one loggued
$args['username'] = Session::get('username');
if( Text::isEmpty($args['username']) ) {
return false;
}
$newKey = $this->generateKey($args['slug'], $args['parent'], false, $args['key']); $newKey = $this->generateKey($args['slug'], $args['parent'], false, $args['key']);
// If the page is draft then the time created is now // If the page is draft then the created time is the current
if( $this->db[$args['key']]['status']=='draft' ) { if( $this->db[$args['key']]['status']=='draft' ) {
$args['date'] = Date::current(DB_DATE_FORMAT); $args['date'] = Date::current(DB_DATE_FORMAT);
} }
@ -178,35 +168,37 @@ class dbPages extends dbJSON
} }
} }
// Move the directory from old key to new key. if( $climode===false ) {
if($newKey!==$args['key']) { // Move the directory from old key to new key.
if( Filesystem::mv(PATH_PAGES.$args['key'], PATH_PAGES.$newKey) === false ) { if($newKey!==$args['key']) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to move the directory to '.PATH_PAGES.$newKey); if( Filesystem::mv(PATH_PAGES.$args['key'], PATH_PAGES.$newKey) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to move the directory to '.PATH_PAGES.$newKey);
return false;
}
}
// Make the index.txt and save the file.
$data = implode("\n", $dataForFile);
if( file_put_contents(PATH_PAGES.$newKey.DS.FILENAME, $data) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME);
return false; return false;
} }
} }
// Make the index.txt and save the file.
$data = implode("\n", $dataForFile);
if( file_put_contents(PATH_PAGES.$newKey.DS.FILENAME, $data) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file '.FILENAME);
return false;
}
// Remove the old key // Remove the old key
unset( $this->db[$args['key']] ); unset( $this->db[$args['key']] );
// Checksum MD5
$dataForDb['md5file'] = md5_file(PATH_PAGES.$newKey.DS.FILENAME);
// Insert in database // Insert in database
$this->db[$newKey] = $dataForDb; $this->db[$newKey] = $dataForDb;
// Sort database // Sort database
$this->sortByDate(); $this->sortBy();
// Save database // Save database
if( $this->save() === false ) { $this->save();
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
return false;
}
return $newKey; return $newKey;
} }
@ -239,6 +231,23 @@ class dbPages extends dbJSON
return true; return true;
} }
// Change a value of a page
public function setField($key, $field, $value)
{
if( $this->exists($key) ) {
settype($value, gettype($this->dbFields[$field]['value']));
$this->db[$key][$field] = $value;
return $this->save();
}
return false;
}
public function setStatus($key, $value)
{
return $this->setField($key, 'status', $value);
}
// Returns a database with published pages // Returns a database with published pages
public function getPublishedDB() public function getPublishedDB()
{ {
@ -251,6 +260,42 @@ class dbPages extends dbJSON
return $tmp; return $tmp;
} }
// (array) Returns a database with the fixed pages
public function getFixedDB()
{
$tmp = $this->db;
foreach($tmp as $key=>$fields) {
if($fields['status']!='fixed') {
unset($tmp[$key]);
}
}
return $tmp;
}
// Returns a database with drafts pages
public function getDraftDB()
{
$tmp = $this->db;
foreach($tmp as $key=>$fields) {
if($fields['status']!='draft') {
unset($tmp[$key]);
}
}
return $tmp;
}
// Returns a database with drafts pages
public function getScheduledDB()
{
$tmp = $this->db;
foreach($tmp as $key=>$fields) {
if($fields['status']!='scheduled') {
unset($tmp[$key]);
}
}
return $tmp;
}
// Return an array with the database for a page, FALSE otherwise. // Return an array with the database for a page, FALSE otherwise.
public function getPageDB($key) public function getPageDB($key)
{ {
@ -273,8 +318,14 @@ class dbPages extends dbJSON
$db = $this->getPublishedDB(); $db = $this->getPublishedDB();
} }
// Remove Error page from the list
unset($db['error']);
// The first page number is 1, so the real is 0
$realPageNumber = $pageNumber - 1;
$total = count($db); $total = count($db);
$init = (int) $amountOfItems * $pageNumber; $init = (int) $amountOfItems * $realPageNumber;
$end = (int) min( ($init + $amountOfItems - 1), $total ); $end = (int) min( ($init + $amountOfItems - 1), $total );
$outrange = $init<0 ? true : $init>$end; $outrange = $init<0 ? true : $init>$end;
@ -298,87 +349,117 @@ class dbPages extends dbJSON
return count($this->db); return count($this->db);
} }
public function getParents($onlyPublished=true) // Returns an array with all parents pages key, a parent page is not a child
public function getParents()
{ {
if( $onlyPublished ) { $db = $this->getPublishedDB();
$db = $this->getPublishedDB(); foreach($db as $key=>$fields) {
} // if the key has slash then is a child
else {
$db = $this->db;
}
foreach( $db as $key=>$fields ) {
if( Text::stringContains($key, '/') ) { if( Text::stringContains($key, '/') ) {
unset($db[$key]); unset($db[$key]);
} }
} }
return $db; return $db;
} }
// Return TRUE if the page exists, FALSE otherwise. // Return TRUE if the page exists, FALSE otherwise
public function exists($key) public function exists($key)
{ {
return isset( $this->db[$key] ); return isset( $this->db[$key] );
} }
public function sortBy()
{
if( ORDER_BY=='date' ) {
return $this->sortByDate(true);
} else {
return $this->sortByPosition(false);
}
}
// Sort pages by position
public function sortByPosition($HighToLow=false)
{
if($HighToLow) {
uasort($this->db, array($this, 'sortByPositionHighToLow'));
}
else {
uasort($this->db, array($this, 'sortByPositionLowToHigh'));
}
return true;
}
private function sortByPositionLowToHigh($a, $b) {
return $a['position']>$b['position'];
}
private function sortByPositionHighToLow($a, $b) {
return $a['position']<$b['position'];
}
// Sort pages by date // Sort pages by date
public function sortByDate($HighToLow=true) public function sortByDate($HighToLow=true)
{ {
if($HighToLow) { if($HighToLow) {
uasort($this->db, array($this, 'sortHighToLow')); uasort($this->db, array($this, 'sortByDateHighToLow'));
} }
else { else {
uasort($this->db, array($this, 'sortLowToHigh')); uasort($this->db, array($this, 'sortByDateLowToHigh'));
} }
return true; return true;
} }
private function sortLowToHigh($a, $b) { private function sortByDateLowToHigh($a, $b) {
return $a['date']>$b['date']; return $a['date']>$b['date'];
} }
private function sortHighToLow($a, $b) { private function sortByDateHighToLow($a, $b) {
return $a['date']<$b['date']; return $a['date']<$b['date'];
} }
// ----- OLD private function generateUUID() {
return md5( uniqid().time() );
}
// Set a field of the database // Returns TRUE if there are new pages published, FALSE otherwise
public function setField($key, $field, $value) public function scheduler()
{ {
if( $this->exists($key) ) { // Get current date
settype($value, gettype($this->dbFields[$key]['value'])); $currentDate = Date::current(DB_DATE_FORMAT);
$this->db[$key][$field] = $value; $saveDatabase = false;
// The database need to be sorted by date
foreach($this->db as $pageKey=>$fields) {
if($fields['status']=='scheduled') {
if($fields['date']<=$currentDate) {
$this->db[$pageKey]['status'] = 'published';
$saveDatabase = true;
}
}
elseif( ($fields['status']=='published') && (ORDER_BY=='date') ) {
break;
}
}
if($saveDatabase) {
if( $this->save() === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
return false;
}
Log::set(__METHOD__.LOG_SEP.'New pages published from the scheduler.');
return true;
} }
return false; return false;
} }
// Generate a valid Key/Slug
public function generateKey($text, $parent=false, $returnSlug=false, $oldKey='')
public function parentKeyList()
{
return $this->parentKeyList;
}
public function parentKeyExists($key)
{
return isset( $this->parentKeyList[$key] );
}
public function addParentKey($key)
{
$this->parentKeyList[$key] = $key;
}
// Generate a valid Key/Slug.
public function generateKey($text, $parent=NO_PARENT_CHAR, $returnSlug=false, $oldKey='')
{ {
if(Text::isEmpty($text)) { if(Text::isEmpty($text)) {
$text = 'empty'; $text = 'empty';
} }
if( Text::isEmpty($parent) || ($parent==NO_PARENT_CHAR) ) { if( empty($parent) ) {
$newKey = Text::cleanUrl($text); $newKey = Text::cleanUrl($text);
} }
else { else {
@ -411,6 +492,116 @@ class dbPages extends dbJSON
return $newKey; return $newKey;
} }
public function rescanClimode()
{
Log::set('CLI MODE'.LOG_SEP.'Starting re-scan on pages directory.');
$pageList = array();
// Search for pages
$directories = Filesystem::listDirectories(PATH_PAGES, $regex='*', $sortByDate=false);
foreach($directories as $directory) {
if( Sanitize::pathFile($directory.DS.FILENAME) ) {
$pageKey = basename($directory);
$pageList[$pageKey] = true;
// Search for children pages
$subDirectories = Filesystem::listDirectories(PATH_PAGES.$pageKey.DS, $regex='*', $sortByDate=false);
foreach($subDirectories as $subDirectory) {
if( Sanitize::pathFile($subDirectory.DS.FILENAME) ) {
$subPageKey = basename($subDirectory);
$subPageKey = $pageKey.'/'.$subPageKey;
$pageList[$subPageKey] = true;
}
}
}
}
Log::set('CLI MODE'.LOG_SEP.'Updating pages...');
$keys = array_keys($pageList);
foreach($keys as $pageKey) {
// Checksum
$checksum = md5_file(PATH_PAGES.$pageKey.DS.FILENAME);
// New page
if( !isset($this->db[$pageKey]) ) {
$this->verifyFieldsClimode($pageKey, true);
}
// Update page
elseif($this->db[$pageKey]['md5file']!=$checksum) {
$this->verifyFieldsClimode($pageKey, false);
}
}
Log::set('CLI MODE'.LOG_SEP.'Removing pages...');
foreach( array_diff_key($this->db, $pageList) as $pageKey=>$data ) {
Log::set('CLI MODE'.LOG_SEP.'Removing page from database, key: '.$pageKey);
unset( $this->db[$pageKey] );
}
$this->save();
}
private function verifyFieldsClimode($key, $insert=true)
{
$page = new Page($key);
$db = $page->getDB();
// Content from file
$db['content'] = $db['contentRaw'];
// Parent
$db['parent'] = '';
$db['slug'] = $key;
$explodeKey = explode('/', $key);
if(isset($explodeKey[1])) {
$db['parent'] = $explodeKey[0];
$db['slug'] = $explodeKey[1];
}
// Date
if( !isset($db['date']) ) {
$db['date'] = Date::current(DB_DATE_FORMAT);
}
// Status
if( !isset($db['status']) ) {
$db['status'] = CLI_STATUS;
}
// Owner username
if( !isset($db['username']) ) {
$db['username'] = CLI_USERNAME;
}
// New page or update page
if($insert) {
Log::set('CLI MODE'.LOG_SEP.'New page found, key:'.$key);
return $this->add($db, $climode=true);
} else {
Log::set('CLI MODE'.LOG_SEP.'Different checksum, updating page, key:'.$key);
return $this->edit($db, $climode=true);
}
}
// ----- OLD
public function parentKeyList()
{
return $this->parentKeyList;
}
public function parentKeyExists($key)
{
return isset( $this->parentKeyList[$key] );
}
public function addParentKey($key)
{
$this->parentKeyList[$key] = $key;
}
// Returns the database // Returns the database
public function getDB() public function getDB()
{ {
@ -455,37 +646,6 @@ class dbPages extends dbJSON
return $this->save(); return $this->save();
} }
// Return TRUE if there are new pages published, FALSE otherwise.
public function scheduler()
{
// Get current date
$currentDate = Date::current(DB_DATE_FORMAT);
$saveDatabase = false;
// The database need to be sorted by date
foreach($this->db as $pageKey=>$fields) {
if($fields['status']=='scheduled') {
if($fields['date']<=$currentDate) {
$this->db[$pageKey]['status'] = 'published';
$saveDatabase = true;
}
}
elseif($fields['status']=='published') {
break;
}
}
if($saveDatabase) { }
if( $this->save() === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
return false;
}
Log::set(__METHOD__.LOG_SEP.'New pages published from the scheduler.');
return true;
}
return false;
}
}

View File

@ -7,7 +7,7 @@ class dbSite extends dbJSON
'slogan'=> array('inFile'=>false, 'value'=>''), 'slogan'=> array('inFile'=>false, 'value'=>''),
'description'=> array('inFile'=>false, 'value'=>''), 'description'=> array('inFile'=>false, 'value'=>''),
'footer'=> array('inFile'=>false, 'value'=>'I wanna be a pirate!'), 'footer'=> array('inFile'=>false, 'value'=>'I wanna be a pirate!'),
'itemsPerPage'=> array('inFile'=>false, 'value'=>''), 'itemsPerPage'=> array('inFile'=>false, 'value'=>6),
'language'=> array('inFile'=>false, 'value'=>'en'), 'language'=> array('inFile'=>false, 'value'=>'en'),
'locale'=> array('inFile'=>false, 'value'=>'en_US'), 'locale'=> array('inFile'=>false, 'value'=>'en_US'),
'timezone'=> array('inFile'=>false, 'value'=>'America/Argentina/Buenos_Aires'), 'timezone'=> array('inFile'=>false, 'value'=>'America/Argentina/Buenos_Aires'),
@ -49,20 +49,13 @@ class dbSite extends dbJSON
public function set($args) public function set($args)
{ {
foreach($args as $field=>$value) foreach($args as $field=>$value) {
{ if( isset($this->dbFields[$field]) ) {
if( isset($this->dbFields[$field]) )
{
$this->db[$field] = Sanitize::html($value); $this->db[$field] = Sanitize::html($value);
} }
} }
if( $this->save() === false ) { return $this->save();
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
return false;
}
return true;
} }
// Returns an array with the filters for the url // Returns an array with the filters for the url
@ -97,6 +90,21 @@ class dbSite extends dbJSON
{ {
$filter = $this->getField('uriCategory'); $filter = $this->getField('uriCategory');
return $this->url().ltrim($filter, '/'); return $this->url().ltrim($filter, '/');
}
// Returns the URL of the rss.xml file
// You need to have enabled the plugin RSS
public function rss()
{
return DOMAIN_BASE.'rss.xml';
}
// Returns the URL of the sitemap.xml file
// You need to have enabled the plugin Sitemap
public function sitemap()
{
return DOMAIN_BASE.'sitemap.xml';
} }
public function twitter() public function twitter()
@ -129,6 +137,21 @@ class dbSite extends dbJSON
return $this->getField('orderBy'); return $this->getField('orderBy');
} }
public function pageError()
{
return $this->getField('pageError');
}
public function pageAbout()
{
return $this->getField('pageAbout');
}
public function pageContact()
{
return $this->getField('pageContact');
}
// Returns the site title // Returns the site title
public function title() public function title()
{ {
@ -181,7 +204,7 @@ class dbSite extends dbJSON
} }
// Returns the full domain and base url // Returns the full domain and base url
// For example, https://www.domain.com/bludit/ // For example, https://www.domain.com/bludit
public function url() public function url()
{ {
return $this->getField('url'); return $this->getField('url');

View File

@ -16,6 +16,27 @@ class dbSyslog extends dbJSON
parent::__construct(DB_SYSLOG); parent::__construct(DB_SYSLOG);
} }
// Returns TRUE if the ID of execution exists, FALSE otherwise
public function exists($idExecution)
{
foreach($this->db as $field) {
if( $field['idExecution']==$idExecution ) {
return true;
}
}
return false;
}
public function get($idExecution)
{
foreach($this->db as $field) {
if( $field['idExecution']==$idExecution ) {
return $field;
}
}
return false;
}
public function add($args) public function add($args)
{ {
global $Language; global $Language;
@ -36,6 +57,9 @@ class dbSyslog extends dbJSON
// Insert at beggining of the database // Insert at beggining of the database
array_unshift($this->db, $data); array_unshift($this->db, $data);
// Keep just NOTIFICATIONS_AMOUNT notifications
$this->db = array_slice($this->db, 0, NOTIFICATIONS_AMOUNT);
// Save // Save
return $this->save(); return $this->save();
} }

View File

@ -16,7 +16,9 @@ class dbTags extends dbList
{ {
global $dbPages; global $dbPages;
$db = $dbPages->getDB(); // Get a database with published pages
$db = $dbPages->getPublishedDB();
$tagsIndex = array(); $tagsIndex = array();
foreach($db as $pageKey=>$pageFields) { foreach($db as $pageKey=>$pageFields) {

View File

@ -13,6 +13,8 @@ class dbUsers extends dbJSON
'registered'=> array('inFile'=>false, 'value'=>'1985-03-15 10:00'), 'registered'=> array('inFile'=>false, 'value'=>'1985-03-15 10:00'),
'tokenEmail'=> array('inFile'=>false, 'value'=>''), 'tokenEmail'=> array('inFile'=>false, 'value'=>''),
'tokenEmailTTL'=> array('inFile'=>false, 'value'=>'2009-03-15 14:00'), 'tokenEmailTTL'=> array('inFile'=>false, 'value'=>'2009-03-15 14:00'),
'tokenAuth'=> array('inFile'=>false, 'value'=>''),
'tokenAuthTTL'=> array('inFile'=>false, 'value'=>'2009-03-15 14:00'),
'twitter'=> array('inFile'=>false, 'value'=>''), 'twitter'=> array('inFile'=>false, 'value'=>''),
'facebook'=> array('inFile'=>false, 'value'=>''), 'facebook'=> array('inFile'=>false, 'value'=>''),
'googlePlus'=> array('inFile'=>false, 'value'=>''), 'googlePlus'=> array('inFile'=>false, 'value'=>''),
@ -21,15 +23,86 @@ class dbUsers extends dbJSON
function __construct() function __construct()
{ {
parent::__construct(PATH_DATABASES.'users.php'); parent::__construct(DB_USERS);
}
// Disable the user
public function disableUser($username)
{
$args['username'] = $username;
$args['password'] = '!';
return $this->set($args);
}
// Return TRUE if the user exists, FALSE otherwise
public function exists($username)
{
return isset($this->db[$username]);
}
// Create a new user
public function add($args)
{
$dataForDb = array();
// Verify arguments with the database fields
foreach($this->dbFields as $field=>$options) {
if( isset($args[$field]) ) {
$value = Sanitize::html($args[$field]);
}
else {
$value = $options['value'];
}
// Set type
settype($value, gettype($options['value']));
// Save on database
$dataForDb[$field] = $value;
}
$dataForDb['registered'] = Date::current(DB_DATE_FORMAT);
$dataForDb['salt'] = $this->generateSalt();
$dataForDb['password'] = $this->generatePasswordHash($dataForDb['password'], $dataForDb['salt']);
$dataForDb['tokenAuth'] = $this->generateAuthToken();
// Save the database
$this->db[$dataForDb['username']] = $dataForDb;
return $this->save();
}
// Set the parameters of a user
public function set($args)
{
// Current database of the user
$user = $this->db[$args['username']];
// Verify arguments with the database fields
foreach($args as $field=>$value) {
if( isset($this->dbFields[$field]) ) {
$value = Sanitize::html($value);
settype($value, gettype($this->dbFields[$field]['value']));
$user[$field] = $value;
}
}
// Save the database
$this->db[$args['username']] = $user;
return $this->save();
}
// Delete an user
public function delete($username)
{
unset($this->db[$username]);
return $this->save();
} }
public function getUser($username) public function getUser($username)
{ {
$User = new User(); if($this->exists($username)) {
$User = new User();
if($this->userExists($username))
{
$User->setField('username', $username); $User->setField('username', $username);
foreach($this->db[$username] as $key=>$value) { foreach($this->db[$username] as $key=>$value) {
@ -42,16 +115,81 @@ class dbUsers extends dbJSON
return false; return false;
} }
public function getAll() public function generateAuthToken()
{ {
return $this->db; return md5( uniqid().time().DOMAIN );
} }
// Return an array with the username databases, filtered by username. public function generateEmailToken()
{
return $this->generateAuthToken();
}
public function generateSalt()
{
return Text::randomText(SALT_LENGTH);
}
public function generatePasswordHash($password, $salt)
{
return sha1($password.$salt);
}
public function setPassword($username, $password)
{
$salt = $this->generateSalt();
$hash = $this->generatePasswordHash($password, $salt);
$tokenAuth = $this->generateAuthToken();
$args['username'] = $username;
$args['salt'] = $salt;
$args['password'] = $hash;
$args['tokenAuth'] = $tokenAuth;
return $this->set($args);
}
// Return the username associated to an email, FALSE otherwise
public function getByEmail($email)
{
foreach($this->db as $username=>$values) {
if($values['email']==$email) {
return $username;
}
}
return false;
}
// Returns the username with the authentication token assigned, FALSE otherwise
public function getByAuthToken($token)
{
foreach($this->db as $username=>$fields) {
if($fields['tokenAuth']==$token) {
return $username;
}
}
return false;
}
public function setTokenEmail($username)
{
// Random hash
$token = $this->generateEmailToken();
$this->db[$username]['tokenEmail'] = $token;
// Token time to live, defined by TOKEN_EMAIL_TTL
$this->db[$username]['tokenEmailTTL'] = Date::currentOffset(DB_DATE_FORMAT, TOKEN_EMAIL_TTL);
// Save the database
$this->save();
return $token;
}
// ---- OLD
// Returns array with the username databases filtered by username, FALSE otherwise
public function getDb($username) public function getDb($username)
{ {
if($this->userExists($username)) if($this->exists($username)) {
{
$user = $this->db[$username]; $user = $this->db[$username];
return $user; return $user;
@ -60,163 +198,10 @@ class dbUsers extends dbJSON
return false; return false;
} }
// Return the username associated to an email, if the email does not exists return FALSE. public function getAll()
public function getByEmail($email)
{ {
foreach($this->db as $username=>$values) { return $this->db;
if($values['email']==$email) {
return $username;
}
}
return false;
} }
// Return TRUE if the user exists, FALSE otherwise.
public function userExists($username)
{
return isset($this->db[$username]);
}
public function generateTokenEmail($username) }
{
// Random hash
$token = sha1(Text::randomText(SALT_LENGTH).time());
$this->db[$username]['tokenEmail'] = $token;
// Token time to live, defined by TOKEN_EMAIL_TTL
$this->db[$username]['tokenEmailTTL'] = Date::currentOffset(DB_DATE_FORMAT, TOKEN_EMAIL_TTL);
// Save the database
if( $this->save() === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
return false;
}
return $token;
}
public function setPassword($username, $password)
{
$salt = Text::randomText(SALT_LENGTH);
$hash = sha1($password.$salt);
$args['username'] = $username;
$args['salt'] = $salt;
$args['password'] = $hash;
return $this->set($args);
}
// Disable the user
public function disableUser($username)
{
$args['username'] = $username;
$args['password'] = '!';
return $this->set($args);
}
public function set($args)
{
$dataForDb = array();
$user = $this->getDb($args['username']);
if($user===false)
{
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the username '.$args['username']);
return false;
}
// Verify arguments with the database fields.
foreach($args as $field=>$value)
{
if( isset($this->dbFields[$field]) )
{
// Sanitize.
$tmpValue = Sanitize::html($value);
// Set type.
settype($tmpValue, gettype($this->dbFields[$field]['value']));
$user[$field] = $tmpValue;
}
}
// Save the database
$this->db[$args['username']] = $user;
if( $this->save() === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
return false;
}
return true;
}
public function delete($username)
{
unset($this->db[$username]);
if( $this->save() === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
return false;
}
return true;
}
public function add($args)
{
$dataForDb = array();
// Verify arguments with the database fields.
foreach($this->dbFields as $field=>$options)
{
// If the user send the field.
if( isset($args[$field]) )
{
// Sanitize if will be saved on database.
if( !$options['inFile'] ) {
$tmpValue = Sanitize::html($args[$field]);
}
else {
$tmpValue = $args[$field];
}
}
// Uses a default value for the field.
else
{
$tmpValue = $options['value'];
}
// Set type
settype($tmpValue, gettype($options['value']));
// Save on database
$dataForDb[$field] = $tmpValue;
}
// Check if the user alredy exists.
if( $this->userExists($dataForDb['username']) ) {
return false;
}
// Current date.
$dataForDb['registered'] = Date::current(DB_DATE_FORMAT);
// Password
$dataForDb['salt'] = Text::randomText(SALT_LENGTH);
$dataForDb['password'] = sha1($dataForDb['password'].$dataForDb['salt']);
// Save the database
$this->db[$dataForDb['username']] = $dataForDb;
if( $this->save() === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
return false;
}
return true;
}
}

View File

@ -1,5 +1,6 @@
<?php defined('BLUDIT') or die('Bludit CMS.'); <?php defined('BLUDIT') or die('Bludit CMS.');
// (object) Returns a Page object, the class is page.class.php, FALSE if something fail to load the page
function buildPage($key) function buildPage($key)
{ {
global $dbPages; global $dbPages;
@ -59,30 +60,14 @@ function buildPage($key)
function reindexCategories() function reindexCategories()
{ {
global $dbPages;
global $dbCategories; global $dbCategories;
return $dbCategories->reindex();
// Get a database with published pages
$db = $dbPages->getPublishedDB();
// Regenerate the tags
$dbCategories->reindex($db);
return true;
} }
function reindexTags() function reindexTags()
{ {
global $dbPages; global $dbTags;
global $dbCategories; return $dbTags->reindex();
// Get a database with published pages
$db = $dbPages->getPublishedDB();
// Regenerate the tags
$dbTags->reindex($db);
return true;
} }
function buildPagesForAdmin() function buildPagesForAdmin()
@ -115,9 +100,10 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false)
{ {
global $dbPages; global $dbPages;
global $dbCategories; global $dbCategories;
global $dbTags;
global $Site; global $Site;
global $Url; global $Url;
global $pagesKey; global $pagesByKey;
global $pages; global $pages;
// Get the page number from URL // Get the page number from URL
@ -143,20 +129,265 @@ function buildPagesFor($for, $categoryKey=false, $tagKey=false)
} }
// There are not items for the page number then set the page notfound // There are not items for the page number then set the page notfound
if( empty($list) && $pageNumber>0 ) { if( empty($list) && $pageNumber>1 ) {
$Url->setNotFound(true); $Url->setNotFound(true);
} }
$pages = array(); // global variable $pages = array(); // global variable
$pagesKey = array(); // global variable $pagesByKey = array(); // global variable
foreach($list as $pageKey=>$fields) { foreach($list as $pageKey=>$fields) {
$page = buildPage($pageKey); $page = buildPage($pageKey);
if($page!==false) { if($page!==false) {
// $pagesKey // $pagesByKey
$pagesKey[$pageKey] = $page; $pagesByKey[$pageKey] = $page;
// $pages // $pages
array_push($pages, $page); array_push($pages, $page);
} }
} }
return $pages; return $pages;
} }
// Returns TRUE if the plugin is enabled, FALSE otherwise
function pluginEnabled($pluginName) {
global $plugins;
$pluginClass = 'plugin'.Text::firstCharUp($pluginName);
if( isset($plugins['all'][$pluginClass]) ) {
return $plugins['all'][$pluginClass]->installed();
}
return false;
}
function printDebug($array) {
echo '<pre>';
var_dump($array);
echo '</pre>';
}
function createPage($args) {
global $dbPages;
global $Syslog;
// The user is always the one loggued
$args['username'] = Session::get('username');
if( Text::isEmpty($args['username']) ) {
return false;
}
$key = $dbPages->add($args);
if($key) {
// Call the plugins after page created
Theme::plugins('afterPageCreate');
// Re-index categories
reindexCategories();
// Re-index tags
reindextags();
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'new-page-created',
'notes'=>$args['title']
));
return $key;
}
Log::set('Function createNewPage()'.LOG_SEP.'Error occurred when trying to create the page');
Log::set('Function createNewPage()'.LOG_SEP.'Cleaning database...');
$dbPages->delete($key);
return false;
}
function editPage($args) {
global $dbPages;
global $Syslog;
// The user is always the one loggued
$args['username'] = Session::get('username');
if( Text::isEmpty($args['username']) ) {
Log::set('Function editPage()'.LOG_SEP.'Empty username.');
return false;
}
if(!isset($args['parent'])) {
$args['parent'] = NO_PARENT_CHAR;
}
$key = $dbPages->edit($args);
if($key) {
// Call the plugins after page modified
Theme::plugins('afterPageModify');
// Re-index categories
reindexCategories();
// Re-index tags
reindextags();
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'page-edited',
'notes'=>$args['title']
));
return $key;
}
Log::set('Function editPage()'.LOG_SEP.'ERROR: Something happen when try to edit the page.');
return false;
}
function deletePage($key) {
global $dbPages;
global $Syslog;
if( $dbPages->delete($key) ) {
// Call the plugins after page deleted
Theme::plugins('afterPageDelete');
// Re-index categories
reindexCategories();
// Re-index tags
reindextags();
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'page-deleted',
'notes'=>$key
));
return true;
}
return false;
}
function disableUser($username) {
global $dbUsers;
global $Login;
global $Syslog;
// The editors can't disable users
if($Login->role()!=='admin') {
return false;
}
if( $dbUsers->disableUser($username) ) {
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'user-disabled',
'notes'=>$username
));
return true;
}
return false;
}
function editUser($args) {
global $dbUsers;
global $Syslog;
if( $dbUsers->set($args) ) {
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'user-edited',
'notes'=>$args['username']
));
return true;
}
return false;
}
function deleteUser($args, $deleteContent=false) {
global $dbUsers;
global $Login;
global $Syslog;
// The user admin cannot be deleted
if($args['username']=='admin') {
return false;
}
// The editors can't delete users
if($Login->role()!=='admin') {
return false;
}
if($deleteContent) {
//$dbPosts->deletePostsByUser($args['username']);
}
else {
//$dbPosts->linkPostsToUser($args['username'], 'admin');
}
if( $dbUsers->delete($args['username']) ) {
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'user-deleted',
'notes'=>$args['username']
));
return true;
}
return false;
}
function createUser($args) {
global $dbUsers;
global $Language;
global $Syslog;
// Check empty username
if( Text::isEmpty($args['new_username']) ) {
Alert::set($Language->g('username-field-is-empty'), ALERT_STATUS_FAIL);
return false;
}
// Check already exist username
if( $dbUsers->exists($args['new_username']) ) {
Alert::set($Language->g('username-already-exists'), ALERT_STATUS_FAIL);
return false;
}
// Password length
if( strlen($args['new_password']) < 6 ) {
Alert::set($Language->g('Password must be at least 6 characters long'), ALERT_STATUS_FAIL);
return false;
}
// Check new password and confirm password are equal
if( $args['new_password'] != $args['confirm_password'] ) {
Alert::set($Language->g('The password and confirmation password do not match'), ALERT_STATUS_FAIL);
return false;
}
// Filter form fields
$tmp = array();
$tmp['username'] = $args['new_username'];
$tmp['password'] = $args['new_password'];
$tmp['role'] = $args['role'];
$tmp['email'] = $args['email'];
// Add the user to the database
if( $dbUsers->add($tmp) ) {
// Add to syslog
$Syslog->add(array(
'dictionaryKey'=>'new-user',
'notes'=>$tmp['username']
));
return true;
}
return false;
}

View File

@ -3,7 +3,7 @@
class Filesystem { class Filesystem {
// Returns an array with the absolutes directories. // Returns an array with the absolutes directories.
public static function listDirectories($path, $regex='*') public static function listDirectories($path, $regex='*', $sortByDate=false)
{ {
$directories = glob($path.$regex, GLOB_ONLYDIR); $directories = glob($path.$regex, GLOB_ONLYDIR);
@ -11,6 +11,10 @@ class Filesystem {
return array(); return array();
} }
if($sortByDate) {
usort($directories, create_function('$a,$b', 'return filemtime($b) - filemtime($a);'));
}
return $directories; return $directories;
} }
@ -50,4 +54,44 @@ class Filesystem {
return unlink($filename); return unlink($filename);
} }
public static function fileExists($filename)
{
return file_exists($filename);
}
public static function directoryExists($path)
{
return file_exists($path);
}
public static function copyRecursive($source, $destination)
{
$destination = rtrim($destination, '/');
foreach($iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($source, RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST) as $item) {
if($item->isDir()) {
@mkdir($destination.DS.$iterator->getSubPathName());
} else {
copy($item, $destination.DS.$iterator->getSubPathName());
}
}
return true;
}
public static function deleteRecursive($source)
{
foreach(new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($source, FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST) as $item) {
if($item->isFile()) {
unlink($item);
} else {
rmdir($item);
}
}
return rmdir($source);
}
} }

View File

@ -4,13 +4,15 @@ class Paginator {
public static $pager = array( public static $pager = array(
'itemsPerPage'=>0, 'itemsPerPage'=>0,
'amountOfPages'=>0, 'amountOfPages'=>1,
'nextPage'=>0, 'amountOfItems'=>0,
'prevPage'=>0, 'firstPage'=>1,
'currentPage'=>0, 'nextPage'=>1,
'showOlder'=>false, 'prevPage'=>1,
'showNewer'=>false, 'currentPage'=>1,
'show'=>false 'showPrev'=>false,
'showNext'=>false,
'showNextPrev'=>false
); );
public static function set($key, $value) public static function set($key, $value)
@ -23,58 +25,62 @@ class Paginator {
return self::$pager[$key]; return self::$pager[$key];
} }
public static function urlNextPage() public static function amountOfPages()
{ {
global $Url; return self::get('amountOfPages');
$domain = trim(DOMAIN_BASE,'/');
$filter = trim($Url->activeFilter(), '/');
if(empty($filter)) {
$url = $domain.'/'.$Url->slug();
}
else {
$url = $domain.'/'.$filter.'/'.$Url->slug();
}
return $url.'?page='.self::get('nextPage');
} }
public static function urlPrevPage() public static function nextPage()
{ {
global $Url; return self::get('nextPage');
$domain = trim(DOMAIN_BASE,'/');
$filter = trim($Url->activeFilter(), '/');
if(empty($filter)) {
$url = $domain.'/'.$Url->slug();
}
else {
$url = $domain.'/'.$filter.'/'.$Url->slug();
}
return $url.'?page='.self::get('prevPage');
} }
public static function urlLastPage() public static function prevPage()
{ {
global $Url; return self::get('prevPage');
$domain = trim(DOMAIN_BASE,'/');
$filter = trim($Url->activeFilter(), '/');
if(empty($filter)) {
$url = $domain.'/'.$Url->slug();
}
else {
$url = $domain.'/'.$filter.'/'.$Url->slug();
}
return $url.'?page='.self::get('numberOfPages');
} }
public static function urlFirstPage() public static function showNext()
{
return self::get('showNext');
}
public static function showPrev()
{
return self::get('showPrev');
}
public static function firstPage()
{
return self::get('firstPage');
}
// Returns the absolute URL for the first page
public static function firstPageUrl()
{
return self::absoluteUrl( self::firstPage() );
}
// Returns the absolute URL for the last page
public static function lastPageUrl()
{
return self::absoluteUrl( self::amountOfPages() );
}
// Returns the absolute URL for the next page
public static function nextPageUrl()
{
return self::absoluteUrl( self::nextPage() );
}
// Returns the absolute URL for the previous page
public static function prevPageUrl()
{
return self::absoluteUrl( self::prevPage() );
}
// Return the absoulte URL with the current filter
public static function absoluteUrl($pageNumber)
{ {
global $Url; global $Url;
@ -88,7 +94,7 @@ class Paginator {
$url = $domain.'/'.$filter.'/'.$Url->slug(); $url = $domain.'/'.$filter.'/'.$Url->slug();
} }
return $url.'?page=0'; return $url.'?page='.$pageNumber;
} }
public static function html($textPrevPage=false, $textNextPage=false, $showPageNumber=false) public static function html($textPrevPage=false, $textNextPage=false, $showPageNumber=false)

View File

@ -0,0 +1,51 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
class TCP {
public static function http($url, $method='GET', $verifySSL=true, $timeOut=1, $followRedirections=true, $binary=true, $headers=false)
{
if( function_exists('curl_version') ) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, $followRedirections);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, $binary);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $verifySSL);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeOut);
curl_setopt($ch, CURLOPT_TIMEOUT, $timeOut);
if($method=='POST') {
curl_setopt($ch, CURLOPT_POST, true);
}
$output = curl_exec($ch);
if($output===false) {
Log::set('Curl error: '.curl_error($ch));
}
curl_close($ch);
}
else {
$options = array(
'http'=>array(
'method'=>$method,
'timeout'=>$timeOut,
'follow_location'=>$followRedirections
),
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false
)
);
$stream = stream_context_create($options);
$output = file_get_contents($url, false, $stream);
}
return $output;
}
public static function download($url, $destination)
{
$data = self::http($url, $method='GET', $verifySSL=true, $timeOut=3, $followRedirections=true, $binary=true, $headers=false);
return file_put_contents($destination, $data);
}
}

View File

@ -2,123 +2,111 @@
class Theme { class Theme {
public static function favicon($file='favicon.png', $path=HTML_PATH_THEME_IMG, $typeIcon=true, $echo=true) // Return the metatag <title> with a predefine structure
{ public static function headTitle()
$type = 'image/png';
if($typeIcon) {
$type = 'image/x-icon';
}
$tmp = '<link rel="shortcut icon" href="'.$path.$file.'" type="'.$type.'">'.PHP_EOL;
if($echo) {
echo $tmp;
}
return $tmp;
}
public static function css($files, $path=DOMAIN_THEME_CSS, $echo=true)
{
if(!is_array($files)) {
$files = array($files);
}
$tmp = '';
foreach($files as $file) {
$tmp .= '<link rel="stylesheet" type="text/css" href="'.$path.$file.'">'.PHP_EOL;
}
if($echo) {
echo $tmp;
}
return $tmp;
}
public static function javascript($files, $path=HTML_PATH_THEME_JS, $echo=true)
{
if(!is_array($files)) {
$files = array($files);
}
$tmp = '';
foreach($files as $file) {
$tmp .= '<script src="'.$path.$file.'"></script>'.PHP_EOL;
}
if($echo) {
echo $tmp;
}
return $tmp;
}
public static function title($title=false, $echo=true)
{ {
global $Url; global $Url;
global $Post, $Page;
global $Site; global $Site;
global $dbTags; global $dbTags;
global $dbCategories;
global $WHERE_AM_I;
global $page;
$tmp = $title; $title = $Site->title();
if(empty($title)) if( $WHERE_AM_I=='page' ) {
{ $title = $page->title().' - '.$Site->title();
if( $Url->whereAmI()=='post' ) { }
$tmp = $Post->title().' - '.$Site->title(); elseif( $WHERE_AM_I=='tag' ) {
} $tagKey = $Url->slug();
elseif( $Url->whereAmI()=='page' ) { $tagName = $dbTags->getName($tagKey);
$tmp = $Page->title().' - '.$Site->title(); $title = $tagName.' - '.$Site->title();
} }
elseif( $Url->whereAmI()=='tag' ) { elseif( $WHERE_AM_I=='category' ) {
$tag = $dbTags->getName($Url->slug()); $categoryKey = $Url->slug();
$tmp = $tag.' - '.$Site->title(); $categoryName = $dbCategories->getName($categoryKey);
} $title = $categoryName.' - '.$Site->title();
else {
$tmp = $Site->title();
}
} }
$tmp = '<title>'.$tmp.'</title>'.PHP_EOL; return '<title>'.$title.'</title>'.PHP_EOL;
if($echo) {
echo $tmp;
}
return $tmp;
} }
public static function description($description=false, $echo=true) // Return the metatag <decription> with a predefine structure
public static function headDescription()
{ {
global $Url;
global $Post, $Page;
global $Site; global $Site;
global $WHERE_AM_I;
global $page;
$tmp = $description; $description = $Site->description();
if(empty($description)) if( $WHERE_AM_I=='page' ) {
{ $description = $page->description();
if( $Url->whereAmI()=='post' ) {
$tmp = $Post->description();
}
elseif( $Url->whereAmI()=='page' ) {
$tmp = $Page->description();
}
else {
$tmp = $Site->description();
}
} }
$tmp = '<meta name="description" content="'.$tmp.'">'.PHP_EOL; return '<meta name="description" content="'.$description.'">'.PHP_EOL;
if($echo) {
echo $tmp;
}
return $tmp;
} }
public static function charset($charset)
{
return '<meta charset="'.$charset.'">'.PHP_EOL;
}
public static function viewport($content)
{
return '<meta name="viewport" content="'.$content.'">'.PHP_EOL;
}
public static function css($files)
{
if( !is_array($files) ) {
$files = array($files);
}
$links = '';
foreach($files as $file) {
$links .= '<link rel="stylesheet" type="text/css" href="'.DOMAIN_THEME.$file.'">'.PHP_EOL;
}
return $links;
}
public static function javascript($files)
{
if( !is_array($files) ) {
$files = array($files);
}
$scripts = '';
foreach($files as $file) {
$scripts .= '<script src="'.DOMAIN_THEME.$file.'"></script>'.PHP_EOL;
}
return $scripts;
}
public static function js($files)
{
return self::javascript($files);
}
public static function plugins($type)
{
global $plugins;
foreach($plugins[$type] as $plugin) {
echo call_user_func(array($plugin, $type));
}
}
public static function favicon($file='favicon.png', $typeIcon='image/png')
{
return '<link rel="shortcut icon" href="'.DOMAIN_THEME.$file.'" type="'.$typeIcon.'">'.PHP_EOL;
}
// ---- OLD
public static function keywords($keywords, $echo=true) public static function keywords($keywords, $echo=true)
{ {
if(is_array($keywords)) { if(is_array($keywords)) {
@ -134,38 +122,6 @@ class Theme {
return $tmp; return $tmp;
} }
public static function viewport($content='width=device-width, initial-scale=1.0', $echo=true)
{
$tmp = '<meta name="viewport" content="'.$content.'">'.PHP_EOL;
if($echo) {
echo $tmp;
}
return $tmp;
}
public static function charset($charset, $echo=true)
{
$tmp = '<meta charset="'.$charset.'">'.PHP_EOL;
if($echo) {
echo $tmp;
}
return $tmp;
}
public static function plugins($type)
{
global $plugins;
foreach($plugins[$type] as $plugin)
{
echo call_user_func(array($plugin, $type));
}
}
public static function jquery($echo=true) public static function jquery($echo=true)
{ {
$tmp = '<script src="'.HTML_PATH_ADMIN_THEME_JS.'jquery.min.js'.'"></script>'.PHP_EOL; $tmp = '<script src="'.HTML_PATH_ADMIN_THEME_JS.'jquery.min.js'.'"></script>'.PHP_EOL;

View File

@ -117,7 +117,7 @@ class Login {
$this->setLogin($username, $user['role']); $this->setLogin($username, $user['role']);
// Invalidate the current token. // Invalidate the current token.
$this->dbUsers->generateTokenEmail($username); $this->dbUsers->setTokenEmail($username);
Log::set(__METHOD__.LOG_SEP.'User logged succeeded by Token-email - Username: '.$username); Log::set(__METHOD__.LOG_SEP.'User logged succeeded by Token-email - Username: '.$username);

View File

@ -18,6 +18,7 @@ class Page {
{ {
$filePath = PATH_PAGES.$key.DS.FILENAME; $filePath = PATH_PAGES.$key.DS.FILENAME;
// Check if the file exists
if( !Sanitize::pathFile($filePath) ) { if( !Sanitize::pathFile($filePath) ) {
return false; return false;
} }
@ -25,32 +26,38 @@ class Page {
$tmp = 0; $tmp = 0;
$lines = file($filePath); $lines = file($filePath);
foreach($lines as $lineNumber=>$line) { foreach($lines as $lineNumber=>$line) {
$parts = array_map('trim', explode(':', $line, 2)); // Split the line in 2 parts, limiter by :
$parts = explode(':', $line, 2);
// Lowercase variable // Remove all characters except letters and dash -
$parts[0] = preg_replace('/[^A-Za-z\-]/', '', $parts[0]);
// Lowercase
$parts[0] = Text::lowercase($parts[0]); $parts[0] = Text::lowercase($parts[0]);
// If variables is content then break the foreach and process the content after. // Check if the current line start the content of the page
if($parts[0]==='content') { // We have two breakers, the word content or 3 dash ---
if( ($parts[0]==='content') || ($parts[0]==='---') ) {
$tmp = $lineNumber; $tmp = $lineNumber;
break; break;
} }
if( !empty($parts[0]) && !empty($parts[1]) ) { if( !empty($parts[0]) && !empty($parts[1]) ) {
// Sanitize all fields, except Content. $parts[1] = trim($parts[1]);
// Sanitize all fields, except the content
$this->vars[$parts[0]] = Sanitize::html($parts[1]); $this->vars[$parts[0]] = Sanitize::html($parts[1]);
} }
} }
// Process the content // Process the content
if($tmp!==0) { if($tmp!==0) {
// Next line after "Content:" variable // Next line after "Content:" or "---"
$tmp++; $tmp++;
// Remove lines after Content // Remove lines after Content
$output = array_slice($lines, $tmp); $output = array_slice($lines, $tmp);
if(!empty($parts[1])) { if( !empty($parts[1]) ) {
array_unshift($output, "\n"); array_unshift($output, "\n");
array_unshift($output, $parts[1]); array_unshift($output, $parts[1]);
} }
@ -68,6 +75,7 @@ class Page {
return($this->vars!==false); return($this->vars!==false);
} }
// DEPRACTED
// Returns the value from the $field, FALSE if the field doesn't exist // Returns the value from the $field, FALSE if the field doesn't exist
public function getField($field) public function getField($field)
{ {
@ -78,6 +86,20 @@ class Page {
return false; return false;
} }
public function getValue($field)
{
if(isset($this->vars[$field])) {
return $this->vars[$field];
}
return false;
}
public function getDB()
{
return $this->vars;
}
// Set a field with a value // Set a field with a value
public function setField($field, $value, $overwrite=true) public function setField($field, $value, $overwrite=true)
{ {
@ -95,7 +117,7 @@ class Page {
public function content($fullContent=true, $noSanitize=true) public function content($fullContent=true, $noSanitize=true)
{ {
// This content is not sanitized. // This content is not sanitized.
$content = $this->getField('content'); $content = $this->getValue('content');
if(!$fullContent) { if(!$fullContent) {
return $this->contentBreak(); return $this->contentBreak();
@ -110,7 +132,7 @@ class Page {
public function contentBreak() public function contentBreak()
{ {
return $this->getField('contentBreak'); return $this->getValue('contentBreak');
} }
// Returns the raw content // Returns the raw content
@ -119,7 +141,7 @@ class Page {
public function contentRaw($noSanitize=true) public function contentRaw($noSanitize=true)
{ {
// This content is not sanitized. // This content is not sanitized.
$content = $this->getField('contentRaw'); $content = $this->getValue('contentRaw');
if($noSanitize) { if($noSanitize) {
return $content; return $content;
@ -131,14 +153,14 @@ class Page {
// Returns the date according to locale settings and format settings // Returns the date according to locale settings and format settings
public function date() public function date()
{ {
return $this->getField('date'); return $this->getValue('date');
} }
// Returns the date according to locale settings and format as database stored // Returns the date according to locale settings and format as database stored
// (string) $format, you can specify the date format // (string) $format, you can specify the date format
public function dateRaw($format=false) public function dateRaw($format=false)
{ {
$date = $this->getField('dateRaw'); $date = $this->getValue('dateRaw');
if($format) { if($format) {
return Date::format($date, DB_DATE_FORMAT, $format); return Date::format($date, DB_DATE_FORMAT, $format);
@ -149,45 +171,35 @@ class Page {
// Returns the permalink // Returns the permalink
// (boolean) $absolute, TRUE returns the page link with the DOMAIN, FALSE without the DOMAIN // (boolean) $absolute, TRUE returns the page link with the DOMAIN, FALSE without the DOMAIN
public function permalink($absolute=false) public function permalink($absolute=true)
{ {
global $Url; // Get the key of the page
global $Site; $key = $this->getValue('key');
$url = trim(DOMAIN_BASE,'/');
$key = $this->key();
$filter = trim($Url->filters('page'), '/');
$htmlPath = trim(HTML_PATH_ROOT,'/');
if(empty($filter)) {
$tmp = $key;
}
else {
$tmp = $filter.'/'.$key;
}
if($absolute) { if($absolute) {
return $url.'/'.$tmp; return DOMAIN_PAGES.$key;
} }
if(empty($htmlPath)) { return HTML_PATH_ROOT.PAGE_URI_FILTER.$key;
return '/'.$tmp; }
}
return '/'.$htmlPath.'/'.$tmp; // Returns the category name
public function category()
{
return $this->categoryMap('name');
} }
// Returns the category key // Returns the category key
public function categoryKey() public function categoryKey()
{ {
return $this->getField('category'); return $this->getValue('category');
} }
// Returns the field from the array // Returns the field from the array
// categoryMap = array( 'name'=>'', 'list'=>array() ) // categoryMap = array( 'name'=>'', 'list'=>array() )
public function categoryMap($field) public function categoryMap($field)
{ {
$map = $this->getField('categoryMap'); $map = $this->getValue('categoryMap');
if($field=='key') { if($field=='key') {
return $this->categoryKey(); return $this->categoryKey();
@ -207,7 +219,7 @@ class Page {
public function user($field=false) public function user($field=false)
{ {
// Get the user object. // Get the user object.
$User = $this->getField('user'); $User = $this->getValue('user');
if($field) { if($field) {
return $User->getField($field); return $User->getField($field);
@ -219,13 +231,13 @@ class Page {
// Returns the username who created the post/page // Returns the username who created the post/page
public function username() public function username()
{ {
return $this->getField('username'); return $this->getValue('username');
} }
// Returns the description field // Returns the description field
public function description() public function description()
{ {
return $this->getField('description'); return $this->getValue('description');
} }
@ -237,7 +249,7 @@ class Page {
// $complete = true : full version // $complete = true : full version
public function relativeTime($complete = false) { public function relativeTime($complete = false) {
$current = new DateTime; $current = new DateTime;
$past = new DateTime($this->getField('date')); $past = new DateTime($this->getValue('date'));
$elapsed = $current->diff($past); $elapsed = $current->diff($past);
$elapsed->w = floor($elapsed->d / 7); $elapsed->w = floor($elapsed->d / 7);
@ -273,7 +285,7 @@ class Page {
// (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
public function tags($returnsArray=false) public function tags($returnsArray=false)
{ {
$tags = $this->getField('tags'); $tags = $this->getValue('tags');
if($returnsArray) { if($returnsArray) {
if($tags==false) { if($tags==false) {
@ -313,14 +325,13 @@ class Page {
// (boolean) $absolute, TRUE returns the absolute path and file name, FALSE just the file name // (boolean) $absolute, TRUE returns the absolute path and file name, FALSE just the file name
public function coverImage($absolute=true) public function coverImage($absolute=true)
{ {
$fileName = $this->getField('coverImage'); $fileName = $this->getValue('coverImage');
if(empty($fileName)) { if(empty($fileName)) {
return false; return false;
} }
if($absolute) { if($absolute) {
return HTML_PATH_UPLOADS.$fileName; return DOMAIN_UPLOADS.$fileName;
} }
return $fileName; return $fileName;
@ -329,54 +340,78 @@ class Page {
// Returns TRUE if the content has the text splited // Returns TRUE if the content has the text splited
public function readMore() public function readMore()
{ {
return $this->getField('readMore'); return $this->getValue('readMore');
} }
public function uuid() public function uuid()
{ {
return $this->getField('uuid'); return $this->getValue('uuid');
} }
// Returns the field key // Returns the field key
public function key() public function key()
{ {
return $this->getField('key'); return $this->getValue('key');
} }
// Returns TRUE if the post/page is published, FALSE otherwise. // (boolean) Returns TRUE if the page is published, FALSE otherwise
public function published() public function published()
{ {
return ($this->getField('status')==='published'); return ($this->getValue('status')==='published');
} }
// Returns TRUE if the post/page is scheduled, FALSE otherwise. // (boolean) Returns TRUE if the page is scheduled, FALSE otherwise
public function scheduled() public function scheduled()
{ {
return ($this->getField('status')==='scheduled'); return ($this->getValue('status')==='scheduled');
} }
// Returns TRUE if the post/page is draft, FALSE otherwise. // (boolean) Returns TRUE if the page is draft, FALSE otherwise
public function draft() public function draft()
{ {
return ($this->getField('status')=='draft'); return ($this->getValue('status')=='draft');
}
// (boolean) Returns TRUE if the page is sticky, FALSE otherwise
public function sticky()
{
return ($this->getValue('status')=='sticky');
}
// (boolean) Returns TRUE if the page is fixed, FALSE otherwise
public function fixed()
{
return ($this->getValue('status')=='fixed');
}
// (string) Returns status of the page
public function status()
{
return $this->getValue('status');
} }
// Returns the title field // Returns the title field
public function title() public function title()
{ {
return $this->getField('title'); return $this->getValue('title');
}
// Returns TRUE if the page has enabled the comments, FALSE otherwise
public function allowComments()
{
return $this->getValue('allowComments');
} }
// Returns the page position // Returns the page position
public function position() public function position()
{ {
return $this->getField('position'); return $this->getValue('position');
} }
// Returns the page slug // Returns the page slug
public function slug() public function slug()
{ {
$explode = explode('/', $this->getField('key')); $explode = explode('/', $this->getValue('key'));
// Check if the page have a parent. // Check if the page have a parent.
if(!empty($explode[1])) { if(!empty($explode[1])) {
@ -389,7 +424,7 @@ class Page {
// Returns the parent key, if the page doesn't have a parent returns FALSE // Returns the parent key, if the page doesn't have a parent returns FALSE
public function parentKey() public function parentKey()
{ {
$explode = explode('/', $this->getField('key')); $explode = explode('/', $this->getValue('key'));
if(isset($explode[1])) { if(isset($explode[1])) {
return $explode[0]; return $explode[0];
} }
@ -413,8 +448,7 @@ class Page {
public function children() public function children()
{ {
$tmp = array(); $tmp = array();
//$paths = glob(PATH_PAGES.$this->getField('key').DS.'*', GLOB_ONLYDIR); $paths = Filesystem::listDirectories(PATH_PAGES.$this->getValue('key').DS);
$paths = Filesystem::listDirectories(PATH_PAGES.$this->getField('key').DS);
foreach($paths as $path) { foreach($paths as $path) {
array_push($tmp, basename($path)); array_push($tmp, basename($path));
} }

View File

@ -116,6 +116,7 @@ class Url
public function setWhereAmI($where) public function setWhereAmI($where)
{ {
$GLOBALS['WHERE_AM_I'] = $where;
$this->whereAmI = $where; $this->whereAmI = $where;
} }
@ -127,9 +128,9 @@ class Url
public function pageNumber() public function pageNumber()
{ {
if(isset($this->parameters['page'])) { if(isset($this->parameters['page'])) {
return $this->parameters['page']; return (int)$this->parameters['page'];
} }
return 0; return 1;
} }
public function setNotFound($error=true) public function setNotFound($error=true)

View File

@ -36,6 +36,11 @@ class User
return $this->getField('lastName'); return $this->getField('lastName');
} }
public function tokenAuth()
{
return $this->getField('tokenAuth');
}
public function role() public function role()
{ {
return $this->getField('role'); return $this->getField('role');

View File

@ -257,6 +257,16 @@
"new-category": "New category", "new-category": "New category",
"slug": "slug", "slug": "slug",
"edit-category": "Edit category", "edit-category": "Edit category",
"last-page": "Last page",
"first-page": "First page" "new-theme-configured": "New theme configured",
"plugin-configured": "Plugin configured",
"new-category-created": "New category created",
"new-page-created": "New page created",
"page-deleted": "Page deleted",
"page-edited": "Page edited",
"user-edited": "User edited",
"changes-on-settings": "Changes on settings",
"plugin-installed": "Plugin installed",
"user-password-changed": "User password changed"
} }

View File

@ -2,9 +2,9 @@
"author": "Bludit", "author": "Bludit",
"email": "", "email": "",
"website": "https://plugins.bludit.com", "website": "https://plugins.bludit.com",
"version": "1.5.2", "version": "2.0",
"releaseDate": "2016-05-28", "releaseDate": "2017-05-26",
"license": "MIT", "license": "MIT",
"compatible": "1.5.2", "compatible": "2.0",
"notes": "" "notes": ""
} }

View File

@ -15,12 +15,14 @@ class pluginAbout extends Plugin {
global $Language; global $Language;
$html = '<div>'; $html = '<div>';
$html .= '<label>'.$Language->get('Plugin label').'</label>'; $html .= '<label>'.$Language->get('Label').'</label>';
$html .= '<input name="label" id="jslabel" type="text" value="'.$this->getDbField('label').'">'; $html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
$html .= '<span class="tip">'.$Language->get('Title of the plugin for the sidebar').'</span>';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';
$html .= '<label>'.$Language->get('About').'</label>'; $html .= '<label>'.$Language->get('About').'</label>';
$html .= '<textarea name="text" id="jstext">'.$this->getDbField('text').'</textarea>'; $html .= '<textarea name="text" id="jstext">'.$this->getValue('text').'</textarea>';
$html .= '</div>'; $html .= '</div>';
return $html; return $html;
@ -29,12 +31,12 @@ class pluginAbout extends Plugin {
public function siteSidebar() public function siteSidebar()
{ {
$html = '<div class="plugin plugin-about">'; $html = '<div class="plugin plugin-about">';
$html .= '<h2>'.$this->getDbField('label').'</h2>'; $html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
$html .= '<div class="plugin-content">'; $html .= '<div class="plugin-content">';
$html .= html_entity_decode(nl2br($this->getDbField('text'))); $html .= html_entity_decode(nl2br($this->getValue('text')));
$html .= '</div>'; $html .= '</div>';
$html .= '</div>'; $html .= '</div>';
return $html; return $html;
} }
} }

View File

@ -2,9 +2,9 @@
"author": "Bludit", "author": "Bludit",
"email": "", "email": "",
"website": "https://plugins.bludit.com", "website": "https://plugins.bludit.com",
"version": "1.5.2", "version": "2.0",
"releaseDate": "2016-05-28", "releaseDate": "2017-07-07",
"license": "MIT", "license": "MIT",
"compatible": "1.5.2", "compatible": "2.0",
"notes": "" "notes": ""
} }

View File

@ -2,48 +2,33 @@
class pluginAPI extends Plugin { class pluginAPI extends Plugin {
private $method;
public function init() public function init()
{ {
global $Security; // Generate the API Token
$token = md5( uniqid().time().DOMAIN );
// This key is used for request such as get the list of all posts and pages
$token = md5($Security->key1().time().DOMAIN);
$this->dbFields = array( $this->dbFields = array(
'ping'=>0, // 0 = false, 1 = true 'token'=>$token, // API Token
'token'=>$token, // Private key 'amountOfItems'=>15 // Amount of items to return
'showAllAmount'=>15, // Amount of posts and pages for return
'authentication'=>1 // Authentication required
); );
} }
public function form() public function form()
{ {
$html = ''; global $Language;
$html .= '<div>'; $html = '<div>';
$html .= '<p><b>Authorization Key:</b> '.$this->getDbField('token').'</p>'; $html .= '<label>'.$Language->get('API Token').'</label>';
$html .= '<div class="tip">This key is private, do not share it with anyone.</div>'; $html .= '<input name="token" type="text" value="'.$this->getValue('token').'">';
$html .= '<span class="tip">'.$Language->get('This token is for read only and is regenerated every time you install the plugin').'</span>';
$html .= '</div>'; $html .= '</div>';
$html .= '<div>'; $html .= '<div>';
$html .= '<p><b>Show all posts:</b> <a href="'.DOMAIN_BASE.'api/show/all/posts/'.$this->getDbField('token').'">'.DOMAIN_BASE.'api/show/all/posts/'.$this->getDbField('token').'</a></p>'; $html .= '<label>'.$Language->get('Amount of pages').'</label>';
$html .= '<div class="tip">Get all posts from this site.</div>'; $html .= '<input id="jsamountOfItems" name="amountOfItems" type="text" value="'.$this->getValue('amountOfItems').'">';
$html .= '</div>'; $html .= '<span class="tip">'.$Language->get('The amount of pages to return when you call to /api/pages').'</span>';
$html .= '<div>';
$html .= '<p><b>Show all pages:</b> <a href="'.DOMAIN_BASE.'api/show/all/pages/'.$this->getDbField('token').'">'.DOMAIN_BASE.'api/show/all/pages/'.$this->getDbField('token').'</a></p>';
$html .= '<div class="tip">Get all pages from this site.</div>';
$html .= '</div>';
$html .= '<div>';
$html .= '<p><b>Show post:</b> <a href="'.DOMAIN_BASE.'api/show/post/{POST-NAME}">'.DOMAIN_BASE.'api/show/post/{POST-NAME}</a></p>';
$html .= '<div class="tip">Get a particular post, change the {POST-NAME} with the post friendly url.</div>';
$html .= '</div>';
$html .= '<div>';
$html .= '<p><b>Show page:</b> <a href="'.DOMAIN_BASE.'api/show/page/{PAGE-NAME}">'.DOMAIN_BASE.'api/show/page/{PAGE-NAME}</a></p>';
$html .= '<div class="tip">Get a particular page, change the {PAGE-NAME} with the page friendly url.</div>';
$html .= '</div>'; $html .= '</div>';
return $html; return $html;
@ -53,23 +38,107 @@ class pluginAPI extends Plugin {
// API HOOKS // API HOOKS
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
public function beforeRulesLoad() public function beforeAll()
{ {
global $Url; global $Url;
global $dbPosts;
global $dbPages; global $dbPages;
global $dbUsers;
// Check if the URI start with /api/ // CHECK URL
$startString = HTML_PATH_ROOT.'api/'; // ------------------------------------------------------------
$URI = $Url->uri(); $URI = $this->webhook('api', $returnsAfterURI=true);
$length = mb_strlen($startString, CHARSET); if( $URI===false ) {
if( mb_substr($URI, 0, $length)!=$startString ) {
return false; return false;
} }
// Remove the first part of the URI // METHOD
$URI = mb_substr($URI, $length); // ------------------------------------------------------------
$method = $this->getMethod();
// INPUTS
// ------------------------------------------------------------
$inputs = $this->getInputs();
if( empty($inputs) ) {
$this->response(array(
'status'=>'1',
'message'=>'Missing inputs.'
));
}
// PARAMETERS
// ------------------------------------------------------------
$parameters = $this->getParameters($URI);
if( empty($parameters) ) {
$this->response(array(
'status'=>'1',
'message'=>'Missing parameters.'
));
}
// API TOKEN
// ------------------------------------------------------------
$tokenAPI = $this->getValue('token');
// Check empty token
if( empty($inputs['token']) ) {
$this->response(array(
'status'=>'1',
'message'=>'Missing API token.'
));
}
// Check the token is valid
if( $inputs['token']!=$tokenAPI ) {
$this->response(array(
'status'=>'1',
'message'=>'Invalid API token.'
));
}
// AUTHENTICATION TOKEN
// ------------------------------------------------------------
$writePermissions = false;
if( !empty($inputs['authentication']) ) {
// Get the user with the authentication token
$username = $dbUsers->getByAuthToken($inputs['authentication']);
if( $username!==false ) {
// Enable write permissions
$writePermissions = true;
}
}
// REQUESTS
// ------------------------------------------------------------
// (GET) /api/pages
if( ($method==='GET') && ($parameters[0]==='pages') && empty($parameters[1]) ) {
$data = $this->getPages();
}
// (GET) /api/pages/<key>
elseif( ($method==='GET') && ($parameters[0]==='pages') && !empty($parameters[1]) ) {
$data = $this->getPage($parameters[1]);
}
// (POST) /api/pages
elseif( ($method==='POST') && ($parameters[0]==='pages') && empty($parameters[1]) && $writePermissions ) {
$data = $this->newPage($inputs);
}
else {
$data = array(
'status'=>'1',
'message'=>'Error: URI not found or Access denied.'
);
}
$this->response($data);
}
// PRIVATE METHODS
// ----------------------------------------------------------------------------
private function getMethod()
{
// METHODS // METHODS
// ------------------------------------------------------------ // ------------------------------------------------------------
// GET // GET
@ -77,38 +146,14 @@ class pluginAPI extends Plugin {
// PUT // PUT
// DELETE // DELETE
$method = $_SERVER['REQUEST_METHOD']; $this->method = $_SERVER['REQUEST_METHOD'];
return $this->method;
// INPUTS }
// ------------------------------------------------------------
// token | authentication token
$inputs = json_decode(file_get_contents('php://input'),true);
if( empty($inputs) ) {
// Default variables for $input
$inputs = array(
'token'=>''
);
}
else {
// Sanitize inputs
foreach( $inputs as $key=>$value ) {
if(empty($value)) {
$this->response(array(
'status'=>'1',
'message'=>'Invalid input.'
));
} else {
$inputs[$key] = Sanitize::html($value);
}
}
}
private function getParameters($URI)
{
// PARAMETERS // PARAMETERS
// ------------------------------------------------------------ // ------------------------------------------------------------
// /api/posts | GET | returns all posts
// /api/posts/{key} | GET | returns the post with the {key}
// /api/pages | GET | returns all pages // /api/pages | GET | returns all pages
// /api/pages/{key} | GET | returns the page with the {key} // /api/pages/{key} | GET | returns the page with the {key}
// /api/cli/regenerate | POST | check for new posts and pages // /api/cli/regenerate | POST | check for new posts and pages
@ -116,150 +161,58 @@ class pluginAPI extends Plugin {
$parameters = explode('/', $URI); $parameters = explode('/', $URI);
// Sanitize parameters // Sanitize parameters
foreach( $parameters as $key=>$value ) { foreach($parameters as $key=>$value) {
if(empty($value)) { $parameters[$key] = Sanitize::html($value);
$this->response(array(
'status'=>'1',
'message'=>'Invalid parameter.'
));
} else {
$parameters[$key] = Sanitize::html($value);
}
} }
// Check authentication return $parameters;
if( $this->getDbField('authentication')==1 ) {
if( $inputs['token']!=$this->getDbField('token') ) {
$this->response(array(
'status'=>'1',
'message'=>'Invalid token.'
));
}
}
// /api/posts
if( ($method==='GET') && ($parameters[0]==='posts') && empty($parameters[1]) ) {
$data = $this->getAllPosts();
$this->response($data);
}
// /api/pages
elseif( ($method==='GET') && ($parameters[0]==='pages') && empty($parameters[1]) ) {
$data = $this->getAllPages();
$this->response($data);
}
// /api/posts/{key}
elseif( ($method==='GET') && ($parameters[0]==='posts') && !empty($parameters[1]) ) {
$data = $this->getPost($parameters[1]);
$this->response($data);
}
// /api/pages/{key}
elseif( ($method==='GET') && ($parameters[0]==='pages') && !empty($parameters[1]) ) {
$data = $this->getPage($parameters[1]);
$this->response($data);
}
// /api/cli/regenerate
elseif( ($method==='POST') && ($parameters[0]==='cli') && ($parameters[1]==='regenerate') ) {
// Regenerate posts
if( $dbPosts->cliMode() ) {
reIndexTagsPosts();
}
// Regenerate pages
$dbPages->cliMode();
$this->response(array(
'status'=>'0',
'message'=>'Pages and post regenerated.'
));
}
} }
// FUNCTIONS private function getInputs()
// ---------------------------------------------------------------------------- {
switch($this->method) {
case "POST":
$inputs = $_POST;
break;
case "GET":
case "DELETE":
$inputs = $_GET;
break;
case "PUT":
$inputs = file_get_contents("php://input");
break;
default:
$inputs = json_encode(array());
break;
}
return $this->cleanInputs($inputs);
}
private function cleanInputs($inputs)
{
$tmp = array();
if( is_array($inputs) ) {
foreach($inputs as $key=>$value) {
$tmp[$key] = Sanitize::html($value);
}
}
elseif( is_string($inputs) ) {
$tmp = json_decode($inputs, true);
if(json_last_error()===0) {
$tmp = array();
}
}
return $tmp;
}
private function response($data=array()) private function response($data=array())
{ {
$json = json_encode($data); $json = json_encode($data);
header('Content-Type: application/json'); header('Content-Type: application/json');
exit($json); exit($json);
} }
private function ping()
{
if($this->getDbField('ping')) {
// Get the authentication key
$token = $this->getDbField('token');
$url = 'https://api.bludit.com/ping?token='.$token.'&url='.DOMAIN_BASE;
// Check if curl is installed
if( function_exists('curl_version') ) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$out = curl_exec($ch);
if($out === false) {
Log::set('Plugin API : '.'Curl error: '.curl_error($ch));
}
curl_close($ch);
}
else {
$options = array(
"ssl"=>array(
"verify_peer"=>false,
"verify_peer_name"=>false
)
);
$stream = stream_context_create($options);
$out = file_get_contents($url, false, $stream);
}
}
}
private function getPost($key)
{
// Generate the object Post
$Post = buildPost($key);
if(!$Post) {
return array(
'status'=>'1',
'message'=>'Post not found.'
);
}
$data['status'] = '0';
$data['message'] = '';
$data['data'] = $Post->json( $returnsArray=true );
return $data;
}
private function getAllPosts()
{
$posts = buildPostsForPage(0, $this->getDbField('showAllAmount'), true, false);
$tmp = array(
'status'=>'0',
'message'=>'',
'data'=>array()
);
foreach($posts as $Post) {
array_push($tmp['data'], $Post->json( $returnsArray=true ));
}
return $tmp;
}
private function getPage($key) private function getPage($key)
{ {
// Generate the object Page // Generate the object Page
@ -272,30 +225,44 @@ class pluginAPI extends Plugin {
); );
} }
$data = array();
$data['status'] = '0'; $data['status'] = '0';
$data['message'] = ''; $data['message'] = 'Page filtered by key: '.$key;
$data['data'] = $Page->json( $returnsArray=true ); $data['data'] = $Page->json( $returnsArray=true );
return $data; return $data;
} }
private function getAllPages() private function getPages()
{ {
$pages = buildAllPages(); global $dbPages;
$onlyPublished = true;
$amountOfItems = $this->getValue('amountOfItems');
$pageNumber = 1;
$list = $dbPages->getList($pageNumber, $amountOfItems, $onlyPublished);
$tmp = array( $tmp = array(
'status'=>'0', 'status'=>'0',
'message'=>'', 'message'=>'List of pages, amount of items: '.$amountOfItems,
'data'=>array() 'data'=>array()
); );
foreach($pages as $Page) { // Get keys of pages
if($Page->published()) { $keys = array_keys($list);
array_push($tmp['data'], $Page->json( $returnsArray=true )); foreach($keys as $pageKey) {
} // Create the page object from the page key
$page = buildPage($pageKey);
array_push($tmp['data'], $page->json( $returnsArray=true ));
} }
return $tmp; return $tmp;
} }
private function createPage($args)
{
// This function is defined on functions.php
return createPage($args);
}
} }

View File

@ -0,0 +1,7 @@
{
"plugin-data":
{
"name": "Categories",
"description": "Shows all categories."
}
}

View File

@ -2,9 +2,9 @@
"author": "Bludit", "author": "Bludit",
"email": "", "email": "",
"website": "https://plugins.bludit.com", "website": "https://plugins.bludit.com",
"version": "1.5.2", "version": "2.0",
"releaseDate": "2016-05-28", "releaseDate": "2017-05-26",
"license": "MIT", "license": "MIT",
"compatible": "1.5.2", "compatible": "2.0",
"notes": "" "notes": ""
} }

View File

@ -0,0 +1,68 @@
<?php
class pluginCategories extends Plugin {
public function init()
{
// Fields and default values for the database of this plugin
$this->dbFields = array(
'label'=>'Categories',
'showCero'=>false
);
}
// Method called on the settings of the plugin on the admin area
public function form()
{
global $Language;
$html = '<div>';
$html .= '<label>'.$Language->get('Label').'</label>';
$html .= '<input name="label" type="text" value="'.$this->getValue('label').'">';
$html .= '<span class="tip">'.$Language->get('Title of the plugin for the sidebar').'</span>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('Categories without content').'</label>';
$html .= '<select name="showCero">';
$html .= '<option value="true" '.($this->getValue('showCero')===true?'selected':'').'>Enabled</option>';
$html .= '<option value="false" '.($this->getValue('showCero')===false?'selected':'').'>Disabled</option>';
$html .= '</select>';
$html .= '<span class="tip">'.$Language->get('Show the categories without content').'</span>';
$html .= '</div>';
return $html;
}
// Method called on the sidebar of the website
public function siteSidebar()
{
global $Language;
global $dbCategories;
// HTML for sidebar
$html = '<div class="plugin plugin-categories">';
$html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
$html .= '<div class="plugin-content">';
$html .= '<ul>';
// By default the database of categories are alphanumeric sorted
foreach( $dbCategories->db as $key=>$fields ) {
$count = count($fields['list']);
if($this->getValue('showCero') || $count>0) {
$html .= '<li>';
$html .= '<a href="'.DOMAIN_CATEGORIES.$key.'">';
$html .= $fields['name'];
$html .= ' ('.count($fields['list']).')';
$html .= '</a>';
$html .= '</li>';
}
}
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
}

View File

@ -2,9 +2,9 @@
"author": "Bludit", "author": "Bludit",
"email": "", "email": "",
"website": "https://plugins.bludit.com", "website": "https://plugins.bludit.com",
"version": "1.5.2", "version": "2.0",
"releaseDate": "2016-05-28", "releaseDate": "2017-05-26",
"license": "MIT", "license": "MIT",
"compatible": "1.5.2", "compatible": "2.0",
"notes": "" "notes": ""
} }

View File

@ -2,121 +2,51 @@
class pluginDisqus extends Plugin { class pluginDisqus extends Plugin {
private $enable;
public function init() public function init()
{ {
$this->dbFields = array( $this->dbFields = array(
'shortname'=>'', 'shortname'=>''
'enablePages'=>0,
'enablePosts'=>0,
'enableDefaultHomePage'=>1
); );
} }
function __construct()
{
parent::__construct();
global $Url;
$this->enable = false;
if( $this->getDbField('enablePosts') && ($Url->whereAmI()=='post') ) {
$this->enable = true;
}
elseif( $this->getDbField('enablePages') && ($Url->whereAmI()=='page') ) {
$this->enable = true;
}
elseif( $this->getDbField('enableDefaultHomePage') && ($Url->whereAmI()=='home') )
{
$this->enable = true;
}
}
public function form() public function form()
{ {
global $Language; global $Language;
$html = '<div>'; $html = '<div>';
$html .= '<label>'.$Language->get('Disqus shortname').'</label>'; $html .= '<label>'.$Language->get('Disqus shortname').'</label>';
$html .= '<input name="shortname" id="jsshortname" type="text" value="'.$this->getDbField('shortname').'">'; $html .= '<input name="shortname" id="jsshortname" type="text" value="'.$this->getValue('shortname').'">';
$html .= '</div>';
$html .= '<div>';
$html .= '<input type="hidden" name="enablePages" value="0">';
$html .= '<input name="enablePages" id="jsenablePages" type="checkbox" value="1" '.($this->getDbField('enablePages')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsenablePages">'.$Language->get('Enable Disqus on pages').'</label>';
$html .= '</div>';
$html .= '<div>';
$html .= '<input type="hidden" name="enablePosts" value="0">';
$html .= '<input name="enablePosts" id="jsenablePosts" type="checkbox" value="1" '.($this->getDbField('enablePosts')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsenablePosts">'.$Language->get('Enable Disqus on posts').'</label>';
$html .= '</div>';
$html .= '<div>';
$html .= '<input type="hidden" name="enableDefaultHomePage" value="0">';
$html .= '<input name="enableDefaultHomePage" id="jsenableDefaultHomePage" type="checkbox" value="1" '.($this->getDbField('enableDefaultHomePage')?'checked':'').'>';
$html .= '<label class="forCheckbox" for="jsenableDefaultHomePage">'.$Language->get('Enable Disqus on default home page').'</label>';
$html .= '</div>'; $html .= '</div>';
return $html; return $html;
} }
public function postEnd()
{
if( $this->enable ) {
return '<div id="disqus_thread"></div>';
}
return false;
}
public function pageEnd() public function pageEnd()
{ {
global $Url; global $page;
// Bludit check not-found page after the plugin method construct. if( ($page->key()!='error') && ($page->allowComments()) ) {
// It's necesary check here the page not-found. $html = '<div id="disqus_thread"></div>';
$html .= '<script type="text/javascript">
var disqus_config = function () {
this.page.url = "'.$page->permalink().'";
this.page.identifier = "'.$page->uuid().'";
};
if( $this->enable && !$Url->notFound()) { (function() {
return '<div id="disqus_thread"></div>'; var d = document, s = d.createElement("script");
} s.src = "https://'.$this->getValue('shortname').'.disqus.com/embed.js";
s.setAttribute("data-timestamp", +new Date());
return false; (d.head || d.body).appendChild(s);
} })();
</script>
public function siteHead()
{
if( $this->enable ) {
return '<style>#disqus_thread { margin: 20px 0 }</style>';
}
return false;
}
public function siteBodyEnd()
{
if( $this->enable ) {
$html = '
<script type="text/javascript">
var disqus_shortname = "'.$this->getDbField('shortname').'";
(function() {
var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
dsq.src = "//" + disqus_shortname + ".disqus.com/embed.js";
(document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>';
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
';
return $html; return $html;
} }
return false; return false;
} }
} }

View File

@ -0,0 +1,11 @@
{
"plugin-data":
{
"name": "Fixed pages",
"description": "Shows a list of pages, you can define the amount of items and the order depends of settings."
},
"home-page": "Home page",
"show-home-link": "Show home link",
"amount-of-items": "Amount of items"
}

View File

@ -2,9 +2,9 @@
"author": "Bludit", "author": "Bludit",
"email": "", "email": "",
"website": "https://plugins.bludit.com", "website": "https://plugins.bludit.com",
"version": "1.5.2", "version": "2.0",
"releaseDate": "2016-05-28", "releaseDate": "2017-05-26",
"license": "MIT", "license": "MIT",
"compatible": "1.5.2", "compatible": "2.0",
"notes": "" "notes": ""
} }

View File

@ -0,0 +1,80 @@
<?php
class pluginFixedPages extends Plugin {
public function init()
{
// Fields and default values for the database of this plugin
$this->dbFields = array(
'label'=>'Fixed Pages',
'homeLink'=>true
);
}
// Method called on the settings of the plugin on the admin area
public function form()
{
global $Language;
$html = '<div>';
$html .= '<label>'.$Language->get('Label').'</label>';
$html .= '<input id="jslabel" name="label" type="text" value="'.$this->getValue('label').'">';
$html .= '<span class="tip">'.$Language->get('Title of the plugin for the sidebar').'</span>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label>'.$Language->get('Home link').'</label>';
$html .= '<select name="homeLink">';
$html .= '<option value="true" '.($this->getValue('showCero')?'checked':'').'>Enabled</option>';
$html .= '<option value="false" '.($this->getValue('showCero')?'checked':'').'>Disabled</option>';
$html .= '</select>';
$html .= '<span class="tip">'.$Language->get('Show the home link on the sidebar').'</span>';
$html .= '</div>';
return $html;
}
// Method called on the sidebar of the website
public function siteSidebar()
{
global $Language;
global $Url;
global $Site;
global $dbPages;
$pages = $dbPages->getFixedDB();
// HTML for sidebar
$html = '<div class="plugin plugin-pages">';
$html .= '<h2 class="plugin-label">'.$this->getValue('label').'</h2>';
$html .= '<div class="plugin-content">';
$html .= '<ul>';
// Show Home page link
if( $this->getValue('homeLink') ) {
$html .= '<li>';
$html .= '<a href="'.$Site->url().'">';
$html .= $Language->get('Home page');
$html .= '</a>';
$html .= '</li>';
}
// Get keys of pages
$keys = array_keys($pages);
foreach($keys as $pageKey) {
// Create the page object from the page key
$page = buildPage($pageKey);
$html .= '<li>';
$html .= '<a href="'.$page->permalink().'">';
$html .= $page->title();
$html .= '</a>';
$html .= '</li>';
}
$html .= '</ul>';
$html .= '</div>';
$html .= '</div>';
return $html;
}
}

View File

@ -1,7 +1,7 @@
{ {
"plugin-data": "plugin-data":
{ {
"name": "Google Tools", "name": "Google",
"description": "This plugin generate the meta tag to validate your site with Google Webmasters Tools and the JavaScript code to track your site with Google Analytics." "description": "This plugin generate the meta tag to validate your site with Google Webmasters Tools and the JavaScript code to track your site with Google Analytics."
}, },

View File

@ -0,0 +1,10 @@
{
"author": "Bludit",
"email": "",
"website": "https://plugins.bludit.com",
"version": "2.0",
"releaseDate": "2017-05-26",
"license": "MIT",
"compatible": "2.0",
"notes": ""
}

View File

@ -0,0 +1,100 @@
<?php
class pluginGoogle extends Plugin {
public function init()
{
$this->dbFields = array(
'google-analytics-tracking-id'=>'',
'google-site-verification'=>'',
'google-tag-manager'=>''
);
}
public function form()
{
global $Language;
$html = '<div>';
$html .= '<label for="jsgoogle-site-verification">'.$Language->get('Google Webmasters tools').'</label>';
$html .= '<input id="jsgoogle-site-verification" type="text" name="google-site-verification" value="'.$this->getDbField('google-site-verification').'">';
$html .= '<span class="tip">'.$Language->get('complete-this-field-with-the-google-site-verification').'</span>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label for="jstracking-id">'.$Language->get('Google Analytics Tracking ID').'</label>';
$html .= '<input id="jsgoogle-analytics-tracking-id" type="text" name="google-analytics-tracking-id" value="'.$this->getDbField('google-analytics-tracking-id').'">';
$html .= '<span class="tip">'.$Language->get('complete-this-field-with-the-tracking-id').'</span>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label for="jsgoogle-tag-manager">'.$Language->get('Google Tag Manager').'</label>';
$html .= '<input id="jsgoogle-tag-manager" type="text" name="google-tag-manager" value="'.$this->getDbField('google-tag-manager').'">';
$html .= '<span class="tip">'.$Language->get('complete-this-field-with-the-tracking-id-google-tag').'</span>';
$html .= '</div>';
return $html;
}
public function siteHead()
{
global $Url;
global $WHERE_AM_I;
$html = '';
// Google HTML tag
if( $this->getValue('google-site-verification') && ($WHERE_AM_I=='home') ) {
$html .= PHP_EOL.'<!-- Google HTML tag -->'.PHP_EOL;
$html .= '<meta name="google-site-verification" content="'.$this->getDbField('google-site-verification').'" />'.PHP_EOL;
}
// Google Tag Manager
if( $this->getValue('google-tag-manager') ) {
$html .= PHP_EOL."<!-- Google Tag Manager -->".PHP_EOL;
$html .= "<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':".PHP_EOL;
$html .= "new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],".PHP_EOL;
$html .= "j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=".PHP_EOL;
$html .= "'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);".PHP_EOL;
$html .= "})(window,document,'script','dataLayer','".$this->getValue('google-tag-manager')."');</script>".PHP_EOL;
$html .= "<!-- End Google Tag Manager -->".PHP_EOL;
}
return $html;
}
public function siteBodyBegin()
{
$html = '';
// Google Tag Manager
if( $this->getValue('google-tag-manager') ) {
$html .= '<!-- Google Tag Manager (noscript) -->'.PHP_EOL;
$html .= '<noscript><iframe src="https://www.googletagmanager.com/ns.html?id='.$this->getValue('google-tag-manager').'" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>'.PHP_EOL;
$html .= '<!-- End Google Tag Manager (noscript) -->'.PHP_EOL;
}
return $html;
}
public function siteBodyEnd()
{
$html = '';
// Google Analytics
if( $this->getValue('google-analytics-tracking-id') ) {
$html .= PHP_EOL.'<!-- Google Analytics -->'.PHP_EOL;
$html .= "<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '".$this->getValue('google-analytics-tracking-id')."', 'auto');
ga('send', 'pageview');
</script>".PHP_EOL;
}
return $html;
}
}

View File

@ -1,95 +0,0 @@
<?php
class pluginGoogleTools extends Plugin {
public function init()
{
$this->dbFields = array(
'tracking-id'=>'',
'google-site-verification'=>'',
'google-tag-manager'=>''
);
}
public function form()
{
global $Language;
$html = '<div>';
$html .= '<label for="jsgoogle-site-verification">'.$Language->get('Google Webmasters tools').'</label>';
$html .= '<input id="jsgoogle-site-verification" type="text" name="google-site-verification" value="'.$this->getDbField('google-site-verification').'">';
$html .= '<div class="tip">'.$Language->get('complete-this-field-with-the-google-site-verification').'</div>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label for="jstracking-id">'.$Language->get('Google Analytics Tracking ID').'</label>';
$html .= '<input id="jstracking-id" type="text" name="tracking-id" value="'.$this->getDbField('tracking-id').'">';
$html .= '<div class="tip">'.$Language->get('complete-this-field-with-the-tracking-id').'</div>';
$html .= '</div>';
$html .= '<div>';
$html .= '<label for="jsgoogle-tag-manager">'.$Language->get('Google Tag Manager').'</label>';
$html .= '<input id="jsgoogle-tag-manager" type="text" name="google-tag-manager" value="'.$this->getDbField('google-tag-manager').'">';
$html .= '<div class="tip">'.$Language->get('complete-this-field-with-the-tracking-id-google-tag').'</div>';
$html .= '</div>';
return $html;
}
public function siteHead()
{
global $Url;
$html = '';
if((!Text::isEmpty($this->getDbField('google-site-verification'))) && ($Url->whereAmI()=='home')) {
$html .= PHP_EOL.'<!-- Google Webmasters Tools -->'.PHP_EOL;
$html .= '<meta name="google-site-verification" content="'.$this->getDbField('google-site-verification').'">'.PHP_EOL;
}
if(!(Text::isEmpty($this->getDbField('google-tag-manager')))) {
$html .= PHP_EOL."<!-- Google Tag Manager -->".PHP_EOL;
$html .= "<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':".PHP_EOL;
$html .= "new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],".PHP_EOL;
$html .= "j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=".PHP_EOL;
$html .= "'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);".PHP_EOL;
$html .= "})(window,document,'script','dataLayer','".$this->getDbField('google-tag-manager')."');</script>".PHP_EOL;
$html .= "<!-- End Google Tag Manager -->".PHP_EOL;
}
return $html;
}
public function siteBodyBegin()
{
if((Text::isEmpty($this->getDbField('google-tag-manager')))) {
return false;
}
$html = '<!-- Google Tag Manager (noscript) -->'.PHP_EOL;
$html .= '<noscript><iframe src="https://www.googletagmanager.com/ns.html?id='.$this->getDbField('google-tag-manager').'" height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>'.PHP_EOL;
$html .= '<!-- End Google Tag Manager (noscript) -->'.PHP_EOL;
return $html;
}
public function siteBodyEnd()
{
$html = PHP_EOL.'<!-- Google Analytics -->'.PHP_EOL;
$html .= "<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
ga('create', '".$this->getDbField('tracking-id')."', 'auto');
ga('send', 'pageview');
</script>".PHP_EOL;
if(Text::isEmpty($this->getDbField('tracking-id'))) {
return false;
}
return $html;
}
}

View File

@ -1,10 +0,0 @@
{
"plugin-data":
{
"name": "Последни публикации",
"description": "Показва най-новите публикации."
},
"amount-of-posts": "Брой последни публикации",
"show-home-link": "Покажи връзка за начало"
}

View File

@ -1,9 +0,0 @@
{
"plugin-data":
{
"name": "Neueste Beiträge",
"description": "Anzeige der neuesten Beiträge."
},
"amount-of-posts": "Anzahl der Beiträge"
}

Some files were not shown because too many files have changed in this diff Show More