Dashboard clean-up

This commit is contained in:
dignajar 2015-10-23 20:23:33 -03:00
parent 654b3d6b3b
commit 6fcf448e98
11 changed files with 212 additions and 102 deletions

View File

@ -25,14 +25,15 @@ function checkPost($args)
if(Valid::email($email)) if(Valid::email($email))
{ {
$user = $dbUsers->getByEmail($email); // Get username associated to an email.
if($user!=false) $username = $dbUsers->getByEmail($email);
if($username!=false)
{ {
// Generate the token and the token expiration date. // Generate the token and the token expiration date.
$token = $dbUsers->generateTokenEmail($user['username']); $token = $dbUsers->generateTokenEmail($username);
// ---- EMAIL ---- // ---- EMAIL ----
$link = $Site->url().'admin/login-email?tokenEmail='.$token.'&username='.$user['username']; $link = $Site->url().'admin/login-email?tokenEmail='.$token.'&username='.$username;
$subject = $Language->g('BLUDIT Login access code'); $subject = $Language->g('BLUDIT Login access code');
$message = Text::replaceAssoc( $message = Text::replaceAssoc(
array( array(

View File

@ -0,0 +1,2 @@
/*! UIkit 2.23.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
.uk-form-password{display:inline-block;position:relative;max-width:100%}.uk-form-password-toggle{display:block;position:absolute;top:50%;right:10px;margin-top:-6px;font-size:13px;line-height:13px;color:#999}.uk-form-password-toggle:hover{color:#999;text-decoration:none}.uk-form-password>input{padding-right:50px!important}

View File

@ -0,0 +1,57 @@
/* ----------- UIKIT HACKs FOR BLUDIT ----------- */
html {
background: #f1f1f1;
}
.uk-button-primary {
background: #444;
}
.uk-button-primary:hover {
background: #333;
}
input[type="text"],
input[type="password"] {
border-color: #FFF !important;
background: #FFF;
}
input:disabled {
background: #ccc;
}
.uk-vertical-align-middle {
margin-top: -100px;
}
.uk-panel {
background: #ffffff;
display: block;
margin: 20px 0;
padding: 20px;
position: relative;
text-align: left;
}
/* ----------- BLUDIT ----------- */
h1.title {
font-weight: lighter;
letter-spacing: 4px;
text-transform: uppercase;
}
h3 {
margin-top: 0px !important;
}
.content {
text-align: left;
}
#jsshowPassword {
color: #999;
cursor: pointer;
font-size: 1.3em;
}

View File

@ -19,7 +19,6 @@
<!-- Javascript --> <!-- Javascript -->
<script charset="utf-8" src="./js/jquery.min.js?version=<?php echo BLUDIT_VERSION ?>"></script> <script charset="utf-8" src="./js/jquery.min.js?version=<?php echo BLUDIT_VERSION ?>"></script>
<script charset="utf-8" src="./js/uikit.min.js?version=<?php echo BLUDIT_VERSION ?>"></script> <script charset="utf-8" src="./js/uikit.min.js?version=<?php echo BLUDIT_VERSION ?>"></script>
<script charset="utf-8" src="./js/form-password.min.js?version=<?php echo BLUDIT_VERSION ?>"></script>
<script charset="utf-8" src="./js/jquery.datetimepicker.js?version=<?php echo BLUDIT_VERSION ?>"></script> <script charset="utf-8" src="./js/jquery.datetimepicker.js?version=<?php echo BLUDIT_VERSION ?>"></script>
<!-- Plugins --> <!-- Plugins -->

View File

@ -0,0 +1,2 @@
/*! UIkit 2.23.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */
!function(t){var i;window.UIkit&&(i=t(UIkit)),"function"==typeof define&&define.amd&&define("uikit-form-password",["uikit"],function(){return i||t(UIkit)})}(function(t){"use strict";return t.component("formPassword",{defaults:{lblShow:"Show",lblHide:"Hide"},boot:function(){t.$html.on("click.formpassword.uikit","[data-uk-form-password]",function(i){var e=t.$(this);e.data("formPassword")||(i.preventDefault(),t.formPassword(e,t.Utils.options(e.attr("data-uk-form-password"))),e.trigger("click"))})},init:function(){var t=this;this.on("click",function(i){if(i.preventDefault(),t.input.length){var e=t.input.attr("type");t.input.attr("type","text"==e?"password":"text"),t.element.html(t.options["text"==e?"lblShow":"lblHide"])}}),this.input=this.element.next("input").length?this.element.next("input"):this.element.prev("input"),this.element.html(this.options[this.input.is("[type='password']")?"lblShow":"lblHide"]),this.element.data("formPassword",this)}}),t.formPassword});

View File

@ -12,7 +12,7 @@
<link rel="shortcut icon" type="image/x-icon" href="./img/favicon.png"> <link rel="shortcut icon" type="image/x-icon" href="./img/favicon.png">
<!-- CSS --> <!-- CSS -->
<link rel="stylesheet" type="text/css" href="./css/uikit.css?version=<?php echo BLUDIT_VERSION ?>"> <link rel="stylesheet" type="text/css" href="./css/uikit.almost-flat.min.css?version=<?php echo BLUDIT_VERSION ?>">
<link rel="stylesheet" type="text/css" href="./css/login.css?version=<?php echo BLUDIT_VERSION ?>"> <link rel="stylesheet" type="text/css" href="./css/login.css?version=<?php echo BLUDIT_VERSION ?>">
<!-- Javascript --> <!-- Javascript -->

View File

@ -79,6 +79,15 @@ if(isset($_GET['language'])) {
$Language = new dbLanguage($localeFromHTTP); $Language = new dbLanguage($localeFromHTTP);
// Timezone
$iniDate = ini_get('date.timezone');
if(empty($iniDate)) {
date_default_timezone_set('UTC');
}
// Locales
setlocale(LC_ALL, $localeFromHTTP);
// ============================================================================ // ============================================================================
// FUNCTIONS // FUNCTIONS
// ============================================================================ // ============================================================================
@ -127,7 +136,10 @@ function checkSystem()
{ {
$errorText = 'Current PHP version '.phpversion().', you need > 5.3. (ERR_202)'; $errorText = 'Current PHP version '.phpversion().', you need > 5.3. (ERR_202)';
error_log($errorText, 0); error_log($errorText, 0);
array_push($stdOut, $errorText);
$tmp['title'] = 'PHP version';
$tmp['errorText'] = $errorText;
array_push($stdOut, $tmp);
return $stdOut; return $stdOut;
} }
@ -136,34 +148,46 @@ function checkSystem()
{ {
$errorText = 'Missing file, upload the file .htaccess (ERR_201)'; $errorText = 'Missing file, upload the file .htaccess (ERR_201)';
error_log($errorText, 0); error_log($errorText, 0);
array_push($stdOut, $errorText);
$tmp['title'] = 'File .htaccess';
$tmp['errorText'] = $errorText;
array_push($stdOut, $tmp);
} }
if(!in_array('dom', $phpModules)) if(!in_array('dom', $phpModules))
{ {
$errorText = 'PHP module DOM is not installed. (ERR_203)'; $errorText = 'PHP module DOM is not installed. (ERR_203)';
error_log($errorText, 0); error_log($errorText, 0);
array_push($stdOut, $errorText);
$tmp['title'] = 'PHP module';
$tmp['errorText'] = $errorText;
array_push($stdOut, $tmp);
} }
if(!in_array('json', $phpModules)) if(!in_array('json', $phpModules))
{ {
$errorText = 'PHP module JSON is not installed. (ERR_204)'; $errorText = 'PHP module JSON is not installed. (ERR_204)';
error_log($errorText, 0); error_log($errorText, 0);
array_push($stdOut, $errorText);
$tmp['title'] = 'PHP module';
$tmp['errorText'] = $errorText;
array_push($stdOut, $tmp);
} }
if(!is_writable(PATH_CONTENT)) if(!is_writable(PATH_CONTENT))
{ {
$errorText = 'Writing test failure, check directory content permissions. (ERR_205)'; $errorText = 'Writing test failure, check directory content permissions. (ERR_205)';
error_log($errorText, 0); error_log($errorText, 0);
array_push($stdOut, $errorText);
$tmp['title'] = 'PHP permissions';
$tmp['errorText'] = $errorText;
array_push($stdOut, $tmp);
} }
return $stdOut; return $stdOut;
} }
function install($adminPassword, $email) function install($adminPassword, $email, $timezoneOffset)
{ {
global $Language; global $Language;
@ -171,6 +195,8 @@ function install($adminPassword, $email)
$currentDate = Date::current(DB_DATE_FORMAT); $currentDate = Date::current(DB_DATE_FORMAT);
$timezone = timezone_name_from_abbr("", $timezoneOffset, 0);
// ============================================================================ // ============================================================================
// Create directories // Create directories
// ============================================================================ // ============================================================================
@ -242,7 +268,7 @@ function install($adminPassword, $email)
'username'=>'admin', 'username'=>'admin',
'status'=>'published', 'status'=>'published',
'tags'=>array('bludit'=>'Bludit','cms'=>'CMS','flat-files'=>'Flat files'), 'tags'=>array('bludit'=>'Bludit','cms'=>'CMS','flat-files'=>'Flat files'),
'allowComments'=>false, 'allowComments'=>'false',
'date'=>$currentDate 'date'=>$currentDate
) )
); );
@ -256,7 +282,7 @@ function install($adminPassword, $email)
'footer'=>Date::current('Y'), 'footer'=>Date::current('Y'),
'language'=>$Language->getCurrentLocale(), 'language'=>$Language->getCurrentLocale(),
'locale'=>$Language->getCurrentLocale(), 'locale'=>$Language->getCurrentLocale(),
'timezone'=>'UTC', 'timezone'=>$timezone,
'theme'=>'pure', 'theme'=>'pure',
'adminTheme'=>'default', 'adminTheme'=>'default',
'homepage'=>'', 'homepage'=>'',
@ -265,7 +291,8 @@ function install($adminPassword, $email)
'uriPage'=>'/', 'uriPage'=>'/',
'uriTag'=>'/tag/', 'uriTag'=>'/tag/',
'url'=>'http://'.DOMAIN.HTML_PATH_ROOT, 'url'=>'http://'.DOMAIN.HTML_PATH_ROOT,
'cliMode'=>true 'cliMode'=>'true',
'emailFrom'=>'no-reply@'.DOMAIN
); );
file_put_contents(PATH_DATABASES.'site.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX); file_put_contents(PATH_DATABASES.'site.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
@ -399,7 +426,7 @@ function checkPOST($args)
$email = sanitize::email($args['email']); $email = sanitize::email($args['email']);
// Install Bludit // Install Bludit
install($args['password'], $email, $args['language']); install($args['password'], $email, $args['timezone']);
return true; return true;
} }
@ -431,9 +458,8 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
} }
?> ?>
<!DOCTYPE HTML>
<!doctype html> <html class="uk-height-1-1 uk-notouch">
<html lang="en">
<head> <head>
<base href="admin/themes/default/"> <base href="admin/themes/default/">
<meta charset="<?php echo CHARSET ?>"> <meta charset="<?php echo CHARSET ?>">
@ -441,86 +467,87 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
<title><?php echo $Language->get('Bludit Installer') ?></title> <title><?php echo $Language->get('Bludit Installer') ?></title>
<link rel="stylesheet" href="./css/kube.min.css"> <!-- Favicon -->
<link rel="stylesheet" href="./css/installer.css"> <link rel="shortcut icon" type="image/x-icon" href="./img/favicon.png">
<!-- CSS -->
<link rel="stylesheet" type="text/css" href="./css/uikit.almost-flat.min.css">
<link rel="stylesheet" type="text/css" href="./css/installer.css">
<link rel="stylesheet" type="text/css" href="./css/form-password.almost-flat.min.css">
<!-- Javascript -->
<script charset="utf-8" src="./js/jquery.min.js"></script>
<script charset="utf-8" src="./js/uikit.min.js"></script>
<script charset="utf-8" src="./js/form-password.min.js"></script>
<script src="./js/jquery.min.js"></script>
<script src="./js/kube.min.js"></script>
</head> </head>
<body> <body class="uk-height-1-1">
<div class="units-row"> <div class="uk-vertical-align uk-text-center uk-height-1-1">
<div class="unit-centered unit-60"> <div class="uk-vertical-align-middle">
<div class="main">
<h1 class="title"><?php echo $Language->get('Bludit Installer') ?></h1> <h1 class="title"><?php echo $Language->get('Bludit Installer') ?></h1>
<p><?php echo $Language->get('Welcome to the Bludit installer') ?></p> <div class="content">
<?php <?php
$system = checkSystem(); $system = checkSystem();
// Missing requirements // Missing requirements
if(!empty($system)) if(!empty($system))
{ {
echo '<div class="boxInstallerForm unit-centered unit-50">'; foreach($system as $values)
echo '<table class="table-stripped">'; {
echo '<div class="uk-panel">';
foreach($system as $value) { echo '<div class="uk-panel-badge uk-badge uk-badge-danger">FAIL</div>';
echo '<tr><td>'.$value.'</td></tr>'; echo '<h3 class="uk-panel-title">'.$values['title'].'</h3>';
} echo $values['errorText'];
echo '</table>';
echo '</div>'; echo '</div>';
} }
}
// Second step // Second step
elseif(isset($_GET['language'])) elseif(isset($_GET['language']))
{ {
?> ?>
<p><?php echo $Language->get('Complete the form choose a password for the username admin') ?></p> <p><?php echo $Language->get('Complete the form choose a password for the username admin') ?></p>
<div class="boxInstallerForm unit-centered unit-40">
<?php <?php
if(!empty($error)) { if(!empty($error)) {
echo '<div class="tools-message tools-message-red">'.$error.'</div>'; echo '<div class="uk-alert uk-alert-danger">'.$error.'</div>';
} }
?> ?>
<form id="jsformInstaller" method="post" action="" class="forms" autocomplete="off"> <form id="jsformInstaller" class="uk-form uk-form-stacked" method="post" action="" autocomplete="off">
<input type="hidden" name="noCheckEmail" id="jsnoCheckEmail" value="0"> <input type="hidden" name="noCheckEmail" id="jsnoCheckEmail" value="0">
<input type="hidden" name="language" id="jslanguage" value="<?php echo $localeFromHTTP ?>"> <input type="hidden" name="timezone" id="jstimezone" value="0">
<label> <div class="uk-form-row">
<input type="text" value="admin" disabled="disabled" class="width-100"> <input type="text" value="admin" class="uk-width-9-10 uk-form-large" disabled>
</label>
<label>
<input type="text" name="password" id="jspassword" placeholder="<?php echo $Language->get('Password visible field') ?>" class="width-100" autocomplete="off" maxlength="100" value="<?php echo isset($_POST['password'])?$_POST['password']:'' ?>">
</label>
<label>
<input type="text" name="email" id="jsemail" placeholder="<?php echo $Language->get('Email') ?>" class="width-100" autocomplete="off" maxlength="100">
</label>
<p><button class="btn btn-blue width-100"><?php echo $Language->get('Install') ?></button>
</p>
</form>
</div> </div>
<div class="uk-form-row">
<input name="password" id="jspassword" type="password" class="uk-width-9-10 uk-form-large" value="<?php echo isset($_POST['password'])?$_POST['password']:'' ?>" placeholder="<?php echo $Language->get('Password') ?>">
<i id="jsshowPassword" class="uk-icon-eye"></i>
</div>
<div class="uk-form-row">
<input name="email" id="jsemail" type="text" class="uk-width-9-10 uk-form-large" placeholder="<?php echo $Language->get('Email') ?>" autocomplete="off" maxlength="100">
</div>
<div class="uk-form-row">
<button type="submit" class="uk-width-1-1 uk-button uk-button-primary uk-button-large"><?php $Language->p('Install') ?></button>
</div>
</form>
<?php <?php
} // END elseif(isset($_GET['language'])) }
else else
{ {
?> ?>
<p><?php echo $Language->get('Choose your language') ?></p> <p><?php echo $Language->get('Choose your language') ?></p>
<div class="boxInstallerForm unit-centered unit-40"> <form class="uk-form" method="get" action="" autocomplete="off">
<form id="jsformLanguage" method="get" action="" class="forms" autocomplete="off"> <div class="uk-form-row">
<select id="jslanguage" name="language" class="uk-width-1-1">
<label for="jslanguage">
<select id="jslanguage" name="language" class="width-100">
<?php <?php
$htmlOptions = getLanguageList(); $htmlOptions = getLanguageList();
foreach($htmlOptions as $locale=>$nativeName) { foreach($htmlOptions as $locale=>$nativeName) {
@ -528,31 +555,51 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
} }
?> ?>
</select> </select>
</label>
<p><button class="btn btn-blue width-100"><?php echo $Language->get('Next') ?></button>
</p>
</form>
</div> </div>
<?php
} // END else
?>
<div class="uk-form-row">
<button type="submit" class="uk-width-1-1 uk-button uk-button-primary uk-button-large"><?php $Language->p('Next') ?></button>
</div>
</form>
<?php
}
?>
</div>
</div> </div>
</div> </div>
<script> <script>
$(document).ready(function() $(document).ready(function()
{ {
// Set timezone
var timezoneOffset = -(new Date().getTimezoneOffset() * 60);
$("#jstimezone").val(timezoneOffset);
// Proceed without email field.
$("#jscompleteEmail").on("click", function() { $("#jscompleteEmail").on("click", function() {
$("#jsnoCheckEmail").val("1"); $("#jsnoCheckEmail").val("1");
if(!$("jspassword").val()) {
if(!$("#jspassword").val()) {
$("#jsformInstaller").submit(); $("#jsformInstaller").submit();
} }
}); });
// Show password
$("#jsshowPassword").on("click", function() {
var input = document.getElementById("jspassword");
if(input.getAttribute("type")=="text") {
input.setAttribute("type", "password");
}
else {
input.setAttribute("type", "text");
}
});
}); });
</script> </script>
</div>
</body> </body>
</html> </html>

View File

@ -73,7 +73,7 @@ define('DB_DATE_FORMAT', 'Y-m-d H:i');
define('SCHEDULED_DATE_FORMAT', 'd M - h:i a'); define('SCHEDULED_DATE_FORMAT', 'd M - h:i a');
// 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_TTL', '+1 day'); define('TOKEN_EMAIL_TTL', '+15 minutes');
// Charset, default UTF-8. // Charset, default UTF-8.
define('CHARSET', 'UTF-8'); define('CHARSET', 'UTF-8');

View File

@ -189,11 +189,13 @@ class dbSite extends dbJSON
// Set the locale. // Set the locale.
public function setLocale($locale) public function setLocale($locale)
{ {
if(setlocale(LC_ALL, $locale.'.UTF-8')!==false) if(setlocale(LC_ALL, $locale.'.UTF-8')!==false) {
return true; return true;
}
if(setlocale(LC_ALL, $locale.'.UTF8')!==false) if(setlocale(LC_ALL, $locale.'.UTF8')!==false) {
return true; return true;
}
return setlocale(LC_ALL, $locale); return setlocale(LC_ALL, $locale);
} }

View File

@ -33,12 +33,12 @@ class dbUsers extends dbJSON
return false; return false;
} }
// Return an array with the username databases, filtered by email address. // Return the username associated to an email, if the email does not exists return FALSE.
public function getByEmail($email) public function getByEmail($email)
{ {
foreach($this->db as $user) { foreach($this->db as $username=>$values) {
if($user['email']==$email) { if($values['email']==$email) {
return $user; return $username;
} }
} }
@ -62,8 +62,8 @@ class dbUsers extends dbJSON
$token = sha1(Text::randomText(SALT_LENGTH).time()); $token = sha1(Text::randomText(SALT_LENGTH).time());
$this->db[$username]['tokenEmail'] = $token; $this->db[$username]['tokenEmail'] = $token;
// Token time to live, defined by TOKEN_TTL // Token time to live, defined by TOKEN_EMAIL_TTL
$this->db[$username]['tokenEmailTTL'] = Date::currentOffset(DB_DATE_FORMAT, TOKEN_TTL); $this->db[$username]['tokenEmailTTL'] = Date::currentOffset(DB_DATE_FORMAT, TOKEN_EMAIL_TTL);
// Save the database // Save the database
if( $this->save() === false ) { if( $this->save() === false ) {

View File

@ -190,5 +190,5 @@
"send-me-a-login-access-code": "Send me a login access code", "send-me-a-login-access-code": "Send me a login access code",
"get-login-access-code": "Get login access code", "get-login-access-code": "Get login access code",
"email-notification-login-access-code": "<p>This is a notification from your website {{WEBSITE_NAME}}</p><p>You request a login access code, follow the next link:</p><p>{{LINK}}</p>", "email-notification-login-access-code": "<p>This is a notification from your website {{WEBSITE_NAME}}</p><p>You request a login access code, follow the next link:</p><p>{{LINK}}</p>",
"there-are-no-scheduled-posts": "There are no scheduled posts" "there-are-no-scheduled-posts": "There are no scheduled posts."
} }