Dates and languages, env variables in different filename, bug fixes

This commit is contained in:
Diego Najar 2017-12-10 22:14:12 +01:00
parent 530e0e2108
commit 165ae0ff21
11 changed files with 242 additions and 2281 deletions

View File

@ -3,88 +3,22 @@
// ============================================================================
// Functions
// ============================================================================
// function updateBludit()
// {
// global $Site;
// global $dbPosts;
// global $dbPages;
function updateBludit() {
global $Site;
// Check if Bludit need to be update.
if( ($Site->currentBuild() < BLUDIT_BUILD) || isset($_GET['update']) ) {
Log::set('UPDATE SYSTEM - Starting.');
// // Check if Bludit need to be update.
// if( ($Site->currentBuild() < BLUDIT_BUILD) || isset($_GET['update']) )
// {
// // LOG
// Log::set('UPDATE SYSTEM - Starting...');
// From Bludit v2.0.x to v2.1.x
if ($Site->currentBuild() < '20171102') {
// Nothing to do
}
// // LOG
// Log::set('UPDATE SYSTEM - Checking posts.');
// // Update posts
// foreach($dbPosts->db as $key=>$post) {
// // Dates
// $date = Date::format($post['date'], 'Y-m-d H:i', DB_DATE_FORMAT);
// if($date !== false) {
// $dbPosts->setPostDb($key, 'date', $date);
// }
// // Checksum
// if( empty($post['md5file']) ) {
// $checksum = md5_file(PATH_POSTS.$key.DS.FILENAME);
// $dbPosts->setPostDb($key, 'md5file', $checksum);
// }
// }
// $dbPosts->save();
// // LOG
// Log::set('UPDATE SYSTEM - Checking pages.');
// // Update pages
// foreach($dbPages->db as $key=>$page) {
// $date = Date::format($page['date'], 'Y-m-d H:i', DB_DATE_FORMAT);
// if($date !== false) {
// $dbPages->setField($key, 'date', $date);
// }
// // Checksum
// if( empty($post['md5file']) ) {
// $checksum = md5_file(PATH_PAGES.$key.DS.FILENAME);
// $dbPages->setField($key, 'md5file', $checksum);
// }
// }
// $dbPages->save();
// // LOG
// Log::set('UPDATE SYSTEM - Checking directories.');
// // --- Update directories ---
// $directories = array(
// PATH_POSTS,
// PATH_PAGES,
// PATH_PLUGINS_DATABASES,
// PATH_UPLOADS_PROFILES,
// PATH_UPLOADS_THUMBNAILS,
// PATH_TMP
// );
// 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));
// // LOG
// Log::set('UPDATE SYSTEM - Updated...');
// }
// }
// Set the current build number
$Site->set(array('currentBuild'=>BLUDIT_BUILD));
Log::set('UPDATE SYSTEM - Finished.');
}
}
// ============================================================================
// Main before POST
@ -99,7 +33,7 @@
// ============================================================================
// Try update Bludit
//updateBludit();
updateBludit();
// Title of the page
$layout['title'] .= ' - '.$Language->g('Dashboard');

View File

@ -102,7 +102,7 @@
margin-bottom: 3px
}
.xdsoft_datetimepicker .xdsoft_mounthpicker {
.xdsoft_datetimepicker .xdsoft_monthpicker {
position: relative;
text-align: center;
}

2093
bl-kernel/admin/themes/default/js/jquery.datetimepicker.js Normal file → Executable file

File diff suppressed because one or more lines are too long

View File

@ -59,108 +59,13 @@ define('DB_SYSLOG', PATH_DATABASES.'syslog.php');
define('DB_USERS', PATH_DATABASES.'users.php');
define('DB_SECURITY', PATH_DATABASES.'security.php');
// Log separator
define('LOG_SEP', ' | ');
// JSON pretty print
if(!defined('JSON_PRETTY_PRINT')) {
define('JSON_PRETTY_PRINT', 128);
}
// Protecting against Symlink attacks
define('CHECK_SYMBOLIC_LINKS', TRUE);
// Alert status ok
define('ALERT_STATUS_OK', 0);
// Alert status fail
define('ALERT_STATUS_FAIL', 1);
// Amount of thumbnails shown on Bludit Quick images
define('THUMBNAILS_AMOUNT', 6);
// Thubmnails size
define('THUMBNAILS_WIDTH', 400);
define('THUMBNAILS_HEIGHT', 400);
define('THUMBNAILS_QUALITY', 100); // 100%
// Profile image size
define('PROFILE_IMG_WIDTH', 400);
define('PROFILE_IMG_HEIGHT', 400);
define('PROFILE_IMG_QUALITY', 100); // 100%
// Password length
define('PASSWORD_LENGTH', 6);
// Password salt length
define('SALT_LENGTH', 8);
// Page brake string
define('PAGE_BREAK', '<!-- pagebreak -->');
// Parent key for the array $pagesByParents
define('PARENT', 'BLUDIT3849abb4cb7abd24c2d8dac17b216f17');
// Items per page for admin area
define('ITEMS_PER_PAGE_ADMIN', 10);
// Cli mode, status for new pages
define('CLI_STATUS', 'published');
// Cli mode, username for new pages
define('CLI_USERNAME', 'admin');
// Remember me
define('REMEMBER_COOKIE_USERNAME', 'BLUDITREMEMBERUSERNAME');
define('REMEMBER_COOKIE_TOKEN', 'BLUDITREMEMBERTOKEN');
define('REMEMBER_COOKIE_EXPIRE_IN_DAYS', 30);
// Filename
define('FILENAME', 'index.txt');
// Database date format
define('DB_DATE_FORMAT', 'Y-m-d H:i:s');
// Database date format
define('BACKUP_DATE_FORMAT', 'Y-m-d-H-i-s');
// Sitemap date format
define('SITEMAP_DATE_FORMAT', 'Y-m-d');
// Date format for Dashboard schedule posts
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
define('TOKEN_EMAIL_TTL', '+15 minutes');
// Charset, default UTF-8.
define('CHARSET', 'UTF-8');
// EXTREME FRIENDLY URL, TRUE for dissmiss internet standard. Experimental!
define('EXTREME_FRIENDLY_URL', FALSE);
// Permissions for new directories
define('DIR_PERMISSIONS', 0755);
// Admin URI filter to access to the admin panel
define('ADMIN_URI_FILTER', 'admin');
// Default language file, in this case is English
define('DEFAULT_LANGUAGE_FILE', 'en.json');
// Session timeout server side, gc_maxlifetime
// 3600 = 1hour
define('SESSION_GC_MAXLIFETIME', 3600);
// Session lifetime of the cookie in seconds which is sent to the browser
// The value 0 means until the browser is closed
define('SESSION_COOKIE_LIFE_TIME', 0);
// User environment variables
include(PATH_KERNEL.'boot'.DS.'variables.php');
// Set internal character encoding
mb_internal_encoding(CHARSET);

View File

@ -0,0 +1,104 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
/*
Environment variables
If you are going to change some variable from here is recommended do it before the installation
*/
// Log separator
define('LOG_SEP', ' | ');
// Protecting against Symlink attacks
define('CHECK_SYMBOLIC_LINKS', TRUE);
// Alert status ok
define('ALERT_STATUS_OK', 0);
// Alert status fail
define('ALERT_STATUS_FAIL', 1);
// Amount of thumbnails shown on Bludit Quick images
define('THUMBNAILS_AMOUNT', 6);
// Thubmnails size
define('THUMBNAILS_WIDTH', 400);
define('THUMBNAILS_HEIGHT', 400);
define('THUMBNAILS_QUALITY', 100); // 100%
// Profile image size
define('PROFILE_IMG_WIDTH', 400);
define('PROFILE_IMG_HEIGHT', 400);
define('PROFILE_IMG_QUALITY', 100); // 100%
// Password length
define('PASSWORD_LENGTH', 6);
// Password salt length
define('SALT_LENGTH', 8);
// Page brake string
define('PAGE_BREAK', '<!-- pagebreak -->');
// Parent key for the array $pagesByParents
define('PARENT', 'BLUDIT3849abb4cb7abd24c2d8dac17b216f17');
// Items per page for admin area
define('ITEMS_PER_PAGE_ADMIN', 10);
// Cli mode, status for new pages
define('CLI_STATUS', 'published');
// Cli mode, username for new pages
define('CLI_USERNAME', 'admin');
// Remember me
define('REMEMBER_COOKIE_USERNAME', 'BLUDITREMEMBERUSERNAME');
define('REMEMBER_COOKIE_TOKEN', 'BLUDITREMEMBERTOKEN');
define('REMEMBER_COOKIE_EXPIRE_IN_DAYS', 30);
// Filename
define('FILENAME', 'index.txt');
// Database date format
define('DB_DATE_FORMAT', 'Y-m-d H:i:s');
// Database date format
define('BACKUP_DATE_FORMAT', 'Y-m-d-H-i-s');
// Sitemap date format
define('SITEMAP_DATE_FORMAT', 'Y-m-d');
// Date format for Dashboard schedule posts
define('SCHEDULED_DATE_FORMAT', 'D, j M Y, H:i');
// Notifications date format
define('NOTIFICATIONS_DATE_FORMAT', 'D, j M Y, H:i');
// 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
define('TOKEN_EMAIL_TTL', '+15 minutes');
// Charset, default UTF-8.
define('CHARSET', 'UTF-8');
// EXTREME FRIENDLY URL, TRUE for dissmiss internet standard. Experimental!
define('EXTREME_FRIENDLY_URL', FALSE);
// Permissions for new directories
define('DIR_PERMISSIONS', 0755);
// Admin URI filter to access to the admin panel
define('ADMIN_URI_FILTER', 'admin');
// Default language file, in this case is English
define('DEFAULT_LANGUAGE_FILE', 'en.json');
// Session timeout server side, gc_maxlifetime
// 3600 = 1hour
define('SESSION_GC_MAXLIFETIME', 3600);
// Session lifetime of the cookie in seconds which is sent to the browser
// The value 0 means until the browser is closed
define('SESSION_COOKIE_LIFE_TIME', 0);

View File

@ -5,6 +5,7 @@ class dbLanguage extends dbJSON
public $data;
public $db;
public $currentLanguage;
public $dates;
function __construct($currentLanguage)
{
@ -30,6 +31,10 @@ class dbLanguage extends dbJSON
// Language-data
$this->data = $this->db['language-data'];
unset($this->db['language-data']);
// Dates
$this->dates = $this->db['dates'];
unset($this->db['dates']);
}
public function locale()
@ -114,4 +119,10 @@ class dbLanguage extends dbJSON
}
return $tmp;
}
// Returns array with all the dates and months
public function getDates()
{
return $this->dates;
}
}

View File

@ -12,14 +12,18 @@ class Date {
public static function current($format)
{
$Date = new DateTime();
return $Date->format($format);
$output = $Date->format($format);
return Self::translate($output);
}
public static function currentOffset($format, $offset)
{
$Date = new DateTime();
$Date->modify($offset);
return $Date->format($format);
$output = $Date->format($format);
return Self::translate($output);
}
// Format a local time/date according to locale settings.
@ -29,7 +33,8 @@ class Date {
$Date = DateTime::createFromFormat($currentFormat, $date);
if ($Date!==false) {
return $Date->format($outputFormat);
$output = $Date->format($outputFormat);
return Self::translate($output);
}
return false;
@ -39,7 +44,22 @@ class Date {
{
$Date = DateTime::createFromFormat($currentFormat, $date);
$Date->setTimezone(new DateTimeZone('UTC'));
return $Date->format($outputFormat);
$output = $Date->format($outputFormat);
return Self::translate($output);
}
public static function translate($date)
{
global $Language;
// If English default language don't translate
if ($Language->currentLanguage()=='en') {
return $date;
}
$dates = $Language->getDates();
return str_replace(array_keys($dates), array_values($dates), $date);
}
public static function timeago($time)

View File

@ -155,12 +155,12 @@ class Url
return 1;
}
public function setNotFound($notFound=true, $httpCode=404, $httpMessage='Not Found')
public function setNotFound()
{
$this->setWhereAmI('page');
$this->notFound = $notFound;
$this->httpCode = $httpCode;
$this->httpMessage = $httpMessage;
$this->notFound = true;
$this->httpCode = 404;
$this->httpMessage = 'Not Found';
}
public function httpCode()

View File

@ -6,7 +6,46 @@
"last-update": "2017-10-14",
"author": "Bludit",
"email": "",
"website": "https://www.bludit.com"
"website": "https://www.bludit.com"
},
"dates": {
"Mon": "Mon",
"Tue": "Tue",
"Wed": "Wed",
"Thu": "Thu",
"Fri": "Fri",
"Sat": "Sat",
"Sun": "Sun",
"Monday": "Monday",
"Tuesday": "Tuesday",
"Wednesday": "Wednesday",
"Thursday": "Thursday",
"Friday": "Friday",
"Saturday": "Saturday",
"Sunday": "Sunday",
"Jan": "Jan",
"Feb": "Feb",
"Mar": "Mar",
"Apr": "Apr",
"Jun": "Jun",
"Jul": "Jul",
"Aug": "Aug",
"Sep": "Sep",
"Oct": "Oct",
"Nov": "Nov",
"Dec": "Dec",
"January": "January",
"February": "February",
"March": "March",
"April": "April",
"May": "May",
"June": "June",
"July": "July",
"August": "August",
"September": "September",
"October": "October",
"November": "November",
"December": "December"
},
"dashboard": "Dashboard",
"manage-users": "Manage users",

View File

@ -8,6 +8,45 @@
"email": "",
"website": "https://www.bludit.com"
},
"dates": {
"Mon": "Lun",
"Tue": "Mar",
"Wed": "Mier",
"Thu": "Jue",
"Fri": "Vie",
"Sat": "Sab",
"Sun": "Dom",
"Monday": "Lunes",
"Tuesday": "Martes",
"Wednesday": "Miercoles",
"Thursday": "Jueves",
"Friday": "Viernes",
"Saturday": "Sabado",
"Sunday": "Domingo",
"Jan": "Ene",
"Feb": "Feb",
"Mar": "Mar",
"Apr": "Abr",
"Jun": "Jun",
"Jul": "Jul",
"Aug": "Ago",
"Sep": "Sep",
"Oct": "Oct",
"Nov": "Nov",
"Dec": "Dic",
"January": "Enero",
"February": "Febrero",
"March": "Marzo",
"April": "Abril",
"May": "Mayo",
"June": "Junio",
"July": "Julio",
"August": "Agosto",
"September": "Septiembre",
"October": "Octubre",
"November": "Noviembre",
"December": "Diciembre"
},
"dashboard": "Panel",
"manage-users": "Administrar usuarios",
"manage-categories": "Administrar categorías",

View File

@ -2,6 +2,6 @@
"plugin-data":
{
"name": "Backup",
"description": ""
"description": "The simple way to backup your Bludit."
}
}