Updater, Profile Image bug fixes, Catch language files corrupt

This commit is contained in:
dignajar 2015-11-20 00:21:39 -03:00
parent bf53719fca
commit c0ce1c3c31
10 changed files with 69 additions and 28 deletions

View File

@ -46,7 +46,7 @@ class dbJSON
} }
} }
public function restoreDb() public function restoreDB()
{ {
$this->db = $this->dbBackup; $this->db = $this->dbBackup;
return true; return true;

View File

@ -3,6 +3,28 @@
// ============================================================================ // ============================================================================
// Functions // Functions
// ============================================================================ // ============================================================================
function updateBludit()
{
global $Site;
// Check if Bludit need to be update.
if($Site->currentBuild() < BLUDIT_BUILD)
{
$directories = array(PATH_POSTS, PATH_PAGES, PATH_PLUGINS_DATABASES, PATH_UPLOADS_PROFILES);
foreach($directories as $dir)
{
// Check if the directory is already created.
if(!file_exists($dir)) {
// Create the directory recursive.
mkdir($dir, DIR_PERMISSIONS, true);
}
}
// Set and save the database.
$Site->set(array('currentBuild'=>BLUDIT_BUILD));
}
}
// ============================================================================ // ============================================================================
// Main before POST // Main before POST
@ -16,6 +38,10 @@
// Main after POST // Main after POST
// ============================================================================ // ============================================================================
// Try update Bludit
updateBludit();
// Get draft posts and schedules
$_draftPosts = array(); $_draftPosts = array();
$_scheduledPosts = array(); $_scheduledPosts = array();
foreach($posts as $Post) foreach($posts as $Post)
@ -28,6 +54,7 @@ foreach($posts as $Post)
} }
} }
// Get draft pages
$_draftPages = array(); $_draftPages = array();
foreach($pages as $Page) foreach($pages as $Page)
{ {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

@ -99,9 +99,9 @@ $(document).ready(function() {
<ul class="uk-navbar-nav"> <ul class="uk-navbar-nav">
<li class="uk-parent" data-uk-dropdown> <li class="uk-parent" data-uk-dropdown>
<?php <?php
$profilePictureSrc = HTML_PATH_UPLOADS_PROFILES.$Login->username().'.jpg'; $profilePictureSrc = HTML_PATH_ADMIN_THEME_IMG.'default.jpg';
if(!file_exists($profilePictureSrc)) { if(file_exists(PATH_UPLOADS_PROFILES.$Login->username().'.jpg')) {
$profilePictureSrc = HTML_PATH_ADMIN_THEME_IMG.'default.jpg'; $profilePictureSrc = HTML_PATH_UPLOADS_PROFILES.$Login->username().'.jpg';
} }
?> ?>
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'edit-user/'.$Login->username() ?>"> <a href="<?php echo HTML_PATH_ADMIN_ROOT.'edit-user/'.$Login->username() ?>">

View File

@ -4,6 +4,7 @@
define('BLUDIT_VERSION', 'githubVersion'); define('BLUDIT_VERSION', 'githubVersion');
define('BLUDIT_CODENAME', ''); define('BLUDIT_CODENAME', '');
define('BLUDIT_RELEASE_DATE', ''); define('BLUDIT_RELEASE_DATE', '');
define('BLUDIT_BUILD', '20151119');
// Debug mode // Debug mode
define('DEBUG_MODE', TRUE); define('DEBUG_MODE', TRUE);
@ -85,6 +86,9 @@ define('TOKEN_EMAIL_TTL', '+15 minutes');
// Charset, default UTF-8. // Charset, default UTF-8.
define('CHARSET', 'UTF-8'); define('CHARSET', 'UTF-8');
// Directory permissions
define('DIR_PERMISSIONS', '0755');
// Multibyte string extension loaded. // Multibyte string extension loaded.
define('MB_STRING', extension_loaded('mbstring')); define('MB_STRING', extension_loaded('mbstring'));

View File

@ -22,7 +22,7 @@ function reIndexTagsPosts()
$dbTags->reindexPosts( $dbPosts->db ); $dbTags->reindexPosts( $dbPosts->db );
// Restore de db on dbPost // Restore de db on dbPost
$dbPosts->restoreDb(); $dbPosts->restoreDB();
return true; return true;
} }

View File

@ -93,14 +93,17 @@ class dbLanguage extends dbJSON
foreach($files as $file) foreach($files as $file)
{ {
$t = new dbJSON($file, false); $t = new dbJSON($file, false);
$native = $t->db['language-data']['native'];
$locale = basename($file, '.json'); // Check if the JSON is complete.
$tmp[$locale] = $native; if(isset($t->db['language-data']['native']))
{
$native = $t->db['language-data']['native'];
$locale = basename($file, '.json');
$tmp[$locale] = $native;
}
} }
return $tmp; return $tmp;
} }
} }

View File

@ -21,7 +21,8 @@ class dbSite extends dbJSON
'cliMode'=> array('inFile'=>false, 'value'=>true), 'cliMode'=> array('inFile'=>false, 'value'=>true),
'emailFrom'=> array('inFile'=>false, 'value'=>''), 'emailFrom'=> array('inFile'=>false, 'value'=>''),
'dateFormat'=> array('inFile'=>false, 'value'=>'F j, Y'), 'dateFormat'=> array('inFile'=>false, 'value'=>'F j, Y'),
'timeFormat'=> array('inFile'=>false, 'value'=>'g:i a') 'timeFormat'=> array('inFile'=>false, 'value'=>'g:i a'),
'currentBuild'=> array('inFile'=>false, 'value'=>0)
); );
function __construct() function __construct()
@ -167,6 +168,12 @@ class dbSite extends dbJSON
return $this->getField('timezone'); return $this->getField('timezone');
} }
// Returns the current build / version of Bludit.
public function currentBuild()
{
return $this->getField('currentBuild');
}
// Returns posts per page. // Returns posts per page.
public function postsPerPage() public function postsPerPage()
{ {

View File

@ -8,7 +8,7 @@ class dbTags extends dbJSON
$postsIndex['tag2']['name'] = 'Tag 2'; $postsIndex['tag2']['name'] = 'Tag 2';
$postsIndex['tag2']['posts'] = array('post1','post5'); $postsIndex['tag2']['posts'] = array('post1','post5');
*/ */
private $dbFields = array( public $dbFields = array(
'postsIndex'=>array('inFile'=>false, 'value'=>array()), 'postsIndex'=>array('inFile'=>false, 'value'=>array()),
'pagesIndex'=>array('inFile'=>false, 'value'=>array()) 'pagesIndex'=>array('inFile'=>false, 'value'=>array())
); );

View File

@ -2,17 +2,17 @@
class dbUsers extends dbJSON class dbUsers extends dbJSON
{ {
private $dbFields = array( public $dbFields = array(
'firstName'=> array('inFile'=>false, 'value'=>''), 'firstName'=> array('inFile'=>false, 'value'=>''),
'lastName'=> array('inFile'=>false, 'value'=>''), 'lastName'=> array('inFile'=>false, 'value'=>''),
'username'=> array('inFile'=>false, 'value'=>''), 'username'=> array('inFile'=>false, 'value'=>''),
'role'=> array('inFile'=>false, 'value'=>'editor'), 'role'=> array('inFile'=>false, 'value'=>'editor'),
'password'=> array('inFile'=>false, 'value'=>''), 'password'=> array('inFile'=>false, 'value'=>''),
'salt'=> array('inFile'=>false, 'value'=>'!Pink Floyd!Welcome to the machine!'), 'salt'=> array('inFile'=>false, 'value'=>'!Pink Floyd!Welcome to the machine!'),
'email'=> array('inFile'=>false, 'value'=>''), 'email'=> array('inFile'=>false, 'value'=>''),
'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')
); );
function __construct() function __construct()
@ -20,6 +20,11 @@ class dbUsers extends dbJSON
parent::__construct(PATH_DATABASES.'users.php'); parent::__construct(PATH_DATABASES.'users.php');
} }
public function getAll()
{
return $this->db;
}
// Return an array with the username databases, filtered by username. // Return an array with the username databases, filtered by username.
public function getDb($username) public function getDb($username)
{ {
@ -51,11 +56,6 @@ class dbUsers extends dbJSON
return isset($this->db[$username]); return isset($this->db[$username]);
} }
public function getAll()
{
return $this->db;
}
public function generateTokenEmail($username) public function generateTokenEmail($username)
{ {
// Random hash // Random hash