Bug fixes

This commit is contained in:
dignajar 2015-06-26 01:31:53 -03:00
parent 69e1de657e
commit 99bf979597
17 changed files with 211 additions and 77 deletions

View File

@ -1,7 +1,16 @@
<?php
<?php defined('BLUDIT') or die('Bludit CMS.');
// DEBUG: Estas funciones llamarlas despues que el usuario se logueo, en la parte de administracion.
$dbPosts->regenerate();
$dbPages->regenerate();
// ============================================================================
// Functions
// ============================================================================
?>
// ============================================================================
// POST Method
// ============================================================================
// ============================================================================
// Main
// ============================================================================
$_newPosts = $dbPosts->regenerate();
$_newPages = $dbPages->regenerate();

View File

@ -21,6 +21,15 @@ function setSettings($args)
$args['advancedOptions'] = 'false';
}
// Add slash at the begin and end.
// This fields are in the settings->advanced mode
if(isset($args['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( $Site->set($args) ) {
Alert::set('Settings has been saved successfully');
}

View File

@ -8,6 +8,10 @@ a:hover {
text-decoration: none !important;
}
body {
background-color: #f9f9f9;
}
/* ----------- FONTS AWESOME ----------- */
.fa-right {
margin-right: 5px;
@ -55,7 +59,7 @@ a:hover {
}
#sidebar li {
border-bottom: 1px solid #eee;
}
/* ----------- ALERT ----------- */
@ -78,6 +82,70 @@ h2.title {
font-weight: normal;
}
/* ----------- TABLE ----------- */
table {
background-color: #fff;
}
table thead {
border-bottom: 2px solid #ccc;
}
/* ----------- DASHBOARD ----------- */
div.dashboardBox {
box-shadow: 0 1px 2px rgba(0,0,0,.26);
background-color: #fff;
border-radius: 2px;
box-sizing: border-box;
margin-bottom: 20px;
}
div.dashboardBox div.content {
border-top: 1px solid #ddd;
padding: 10px 20px;
}
div.dashboardBox div.contentBlue {
background-color: #64b5f6 !important;
color: #e3f2fd !important;
position: relative;
overflow: hidden;
}
div.dashboardBox div.contentGreen {
background-color: #81c784 !important;
color: #e8f5e9 !important;
position: relative;
overflow: hidden;
}
div.dashboardBox .nav {
margin: 0 !important;
}
div.dashboardBox i.iconContent {
bottom: -1rem;
position: absolute;
right: 0;
font-size: 4em;
}
div.dashboardBox div.bigContent {
font-size: 1.8em;
font-weight: bold;
}
div.dashboardBox h2 {
color: #666;
font-size: 1.1em;
font-weight: normal;
margin: 0;
padding: 10px 20px;
}
/* ----------- FORMS ----------- */
form h4 {
@ -99,12 +167,12 @@ p.advOptions {
/* ----------- PLUGINS ----------- */
div.pluginBox {
background: rgba(234, 234, 234, 0.18) none repeat scroll 0 0;
box-shadow: 0 1px 2px rgba(0,0,0,.26);
background-color: #fff;
border-radius: 2px;
padding: 10px;
box-sizing: border-box;
padding: 20px;
width: 70%;
box-shadow: 0 2px 5px 0 rgba(183, 183, 183, 0.26);
margin-bottom: 20px;
}
div.pluginBox p {

View File

@ -1,2 +1,55 @@
<h2 class="title">Dashboard</h2>
<p>Not implemented...</p>
<div class="units-row">
<div class="unit-40">
<div class="dashboardBox">
<div class="content contentBlue">
<div class="bigContent"><?php echo $dbPosts->count() ?></div>
<div class="littleContent">posts</div>
<i class="iconContent fa fa-pie-chart"></i>
</div>
</div>
<div class="dashboardBox">
<div class="content contentGreen">
<div class="bigContent"><?php echo $dbUsers->count() ?></div>
<div class="littleContent">Users</div>
<i class="iconContent fa fa-user"></i>
</div>
</div>
</div>
<div class="unit-60">
<?php if($_newPosts || $_newPages) { ?>
<div class="dashboardBox">
<div class="content contentGreen">
<div class="bigContent">Database regenerated</div>
<div class="littleContent">New posts and pages synchronized.</div>
<i class="iconContent fa fa-pie-chart"></i>
</div>
</div>
<?php } ?>
<div class="dashboardBox">
<h2>Notifications</h2>
<div class="content">
<nav class="nav">
<ul>
<li>New comment</li>
<li>Admin session started at 07:00pm</li>
<li>Failed login with username diego</li>
<li>Database regenerated</li>
<li>New session started at 01:00pm</li>
<li>New post added</li>
<li>New page added</li>
</ul>
</nav>
</div>
</div>
</div>
</div>

View File

@ -11,7 +11,7 @@
<label>
Content <span class="forms-desc">HTML and Markdown code supported.</span>
<textarea name="content" rows="10" class="width-70"><?php echo $_Page->contentRaw() ?></textarea>
<textarea name="content" rows="10" class="width-70"><?php echo htmlspecialchars($_Page->contentRaw(), ENT_COMPAT|ENT_HTML5, CHARSET) ?></textarea>
</label>
<?php

View File

@ -3,7 +3,7 @@
<form method="post" action="" class="forms">
<input type="hidden" id="key" name="key" value="<?php echo $_Post->key() ?>">
<?php var_dump($_Post->title()); ?>
<label>
Title
<input id="title" name="title" type="text" class="width-70" value="<?php echo $_Post->title() ?>">

View File

@ -16,8 +16,7 @@ class dbJSON
{
$lines = file($file);
if($firstLine)
{
if($firstLine) {
// Remove the first line.
unset($lines[0]);
}
@ -32,6 +31,11 @@ class dbJSON
}
}
public function count()
{
return count($this->db);
}
public function save()
{
if($this->firstLine)

View File

@ -7,9 +7,10 @@ class fileContent
function __construct($pathSlug)
{
if($this->build($pathSlug)===false)
if($this->build($pathSlug)===false) {
$this->vars = false;
}
}
// Return true if valid
public function isValid()
@ -42,9 +43,6 @@ class fileContent
return false;
}
// Path
//$this->setField('path', $this->path);
// Database Key
$this->setField('key', $pathSlug);
@ -84,7 +82,10 @@ class fileContent
array_unshift($output, $parts[1]);
}
$this->vars['content'] = implode($output);
$implode = implode($output);
// Sanitize content.
$this->vars['content'] = Sanitize::html($implode);
}
}

View File

@ -54,13 +54,15 @@ define('JSON', function_exists('json_encode'));
// TRUE if new posts hand-made set published, or FALSE for draft.
define('HANDMADE_PUBLISHED', true);
define('CHARSET', 'UTF-8');
if(MB_STRING)
{
// Tell PHP that we're using UTF-8 strings until the end of the script.
mb_internal_encoding('UTF-8');
mb_internal_encoding(CHARSET);
// Tell PHP that we'll be outputting UTF-8 to the browser.
mb_http_output('UTF-8');
mb_http_output(CHARSET);
}
// Abstract Classes

View File

@ -2,12 +2,12 @@
class dbLanguage extends dbJSON
{
public $en_EN;
public $en_US;
function __construct($language)
{
parent::__construct(PATH_LANGUAGES.'en_EN.json', false);
$this->en_EN = $this->db;
parent::__construct(PATH_LANGUAGES.'en_US.json', false);
$this->en_US = $this->db;
parent::__construct(PATH_LANGUAGES.$language.'.json', false);
}
@ -22,7 +22,7 @@ class dbLanguage extends dbJSON
return $this->db[$key];
// If the key is not translated then return the English translation.
return $this->en_EN[$key];
return $this->en_US[$key];
}
// Print the translation.

View File

@ -146,7 +146,7 @@ class dbPages extends dbJSON
}
}
// Make the directory. Recursive.
// Move the directory from old key to new key.
if($newKey!==$args['key'])
{
if( Filesystem::mv(PATH_PAGES.$args['key'], PATH_PAGES.$newKey) === false ) {
@ -157,7 +157,7 @@ class dbPages extends dbJSON
// Make the index.txt and save the file.
$data = implode("\n", $dataForFile);
if( file_put_contents(PATH_PAGES.$newKey.'/index.txt', $data) === false ) {
if( file_put_contents(PATH_PAGES.$newKey.DS.'index.txt', $data) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file index.txt');
return false;
}
@ -183,7 +183,7 @@ class dbPages extends dbJSON
}
// Delete the index.txt file.
if( Filesystem::rmfile(PATH_PAGES.$key.'/index.txt') === false ) {
if( Filesystem::rmfile(PATH_PAGES.$key.DS.'index.txt') === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the file index.txt');
}
@ -313,18 +313,18 @@ class dbPages extends dbJSON
{
$key = basename($directory);
if(file_exists($directory.'/index.txt')){
if(file_exists($directory.DS.'index.txt')){
// The key is the directory name
$paths[$key] = true;
}
// Recovery pages from subdirectories
$subPaths = glob($directory.'/*', GLOB_ONLYDIR);
$subPaths = glob($directory.DS.'*', GLOB_ONLYDIR);
foreach($subPaths as $subDirectory)
{
$subKey = basename($subDirectory);
if(file_exists($subDirectory.'/index.txt')) {
if(file_exists($subDirectory.DS.'index.txt')) {
// The key is composed by the directory/subdirectory
$paths[$key.'/'.$subKey] = true;
}
@ -347,7 +347,7 @@ class dbPages extends dbJSON
return false;
}
return true;
return $this->db!=$db;
}
}

View File

@ -113,7 +113,7 @@ class dbPosts extends dbJSON
// Make the index.txt and save the file.
$data = implode("\n", $dataForFile);
if( file_put_contents(PATH_POSTS.$key.'/index.txt', $data) === false ) {
if( file_put_contents(PATH_POSTS.$key.DS.'index.txt', $data) === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to put the content in the file index.txt');
return false;
}
@ -150,7 +150,7 @@ class dbPosts extends dbJSON
}
// Delete the index.txt file.
if( Filesystem::rmfile(PATH_POSTS.$key.'/index.txt') === false ) {
if( Filesystem::rmfile(PATH_POSTS.$key.DS.'index.txt') === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to delete the file index.txt');
}
@ -195,8 +195,9 @@ class dbPosts extends dbJSON
// Username
$fields['username'] = 'admin';
if(HANDMADE_PUBLISHED)
if(HANDMADE_PUBLISHED) {
$fields['status']='published';
}
// Recovery pages from the first level of directories
$tmpPaths = glob(PATH_POSTS.'*', GLOB_ONLYDIR);
@ -204,7 +205,7 @@ class dbPosts extends dbJSON
{
$key = basename($directory);
if(file_exists($directory.'/index.txt')) {
if(file_exists($directory.DS.'index.txt')) {
// The key is the directory name
$paths[$key] = true;
}
@ -220,7 +221,13 @@ class dbPosts extends dbJSON
$this->db[$slug] = $fields;
}
$this->save();
// Save the database.
if( $this->save() === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
return false;
}
return $this->db!=$db;
}
public function getPage($pageNumber, $postPerPage, $draftPosts=false)

View File

@ -9,7 +9,7 @@ class dbSite extends dbJSON
'footer'=> array('inFile'=>false, 'value'=>''),
'postsperpage'=>array('inFile'=>false, 'value'=>''),
'language'=> array('inFile'=>false, 'value'=>'en'),
'locale'=> array('inFile'=>false, 'value'=>'en_EN'),
'locale'=> array('inFile'=>false, 'value'=>'en_US'),
'timezone'=> array('inFile'=>false, 'value'=>'America/Argentina/Buenos_Aires'),
'theme'=> array('inFile'=>false, 'value'=>'pure'),
'adminTheme'=> array('inFile'=>false, 'value'=>'kure'),

View File

@ -5,7 +5,7 @@ class Sanitize {
// new
public static function html($text)
{
return htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
return htmlspecialchars($text, ENT_COMPAT|ENT_HTML5, CHARSET);
}
public static function pathFile($path, $file)

View File

@ -4,6 +4,23 @@ class Text {
// New
public static function addSlashes($text, $begin=true, $end=true)
{
if($begin) {
$text = '/' . ltrim($text, '/');
}
if($end) {
$text = rtrim($text, '/') . '/';
}
if($text=='//') {
return '/';
}
return $text;
}
public static function endsWith($string, $endsString)
{
$endsPosition = (-1)*self::length($endsString);

View File

@ -1,36 +0,0 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
class Language extends DB_SERIALIZE
{
public $en_EN;
function __construct($language)
{
parent::__construct(PATH_LANGUAGES.'en_EN.json', false);
$this->en_EN = $this->vars;
parent::__construct(PATH_LANGUAGES.$language.'.json', false);
}
// Return the translation, if the translation does'n exist then return the English translation.
public function get($text)
{
$key = Text::lowercase($text);
$key = Text::replace(' ', '-', $key);
if(isset($this->vars[$key]))
return $this->vars[$key];
// If the key is not translated then return the English translation.
return $this->en_EN[$key];
}
// Print the translation.
public function p($text)
{
echo $this->get($text);
}
}
?>