Dashboard clean-up
This commit is contained in:
parent
654b3d6b3b
commit
6fcf448e98
|
@ -25,14 +25,15 @@ function checkPost($args)
|
|||
|
||||
if(Valid::email($email))
|
||||
{
|
||||
$user = $dbUsers->getByEmail($email);
|
||||
if($user!=false)
|
||||
// Get username associated to an email.
|
||||
$username = $dbUsers->getByEmail($email);
|
||||
if($username!=false)
|
||||
{
|
||||
// Generate the token and the token expiration date.
|
||||
$token = $dbUsers->generateTokenEmail($user['username']);
|
||||
$token = $dbUsers->generateTokenEmail($username);
|
||||
|
||||
// ---- 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');
|
||||
$message = Text::replaceAssoc(
|
||||
array(
|
||||
|
|
|
@ -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}
|
|
@ -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;
|
||||
}
|
|
@ -19,7 +19,6 @@
|
|||
<!-- Javascript -->
|
||||
<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/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>
|
||||
|
||||
<!-- Plugins -->
|
||||
|
|
|
@ -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});
|
|
@ -12,7 +12,7 @@
|
|||
<link rel="shortcut icon" type="image/x-icon" href="./img/favicon.png">
|
||||
|
||||
<!-- 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 ?>">
|
||||
|
||||
<!-- Javascript -->
|
||||
|
|
187
install.php
187
install.php
|
@ -79,6 +79,15 @@ if(isset($_GET['language'])) {
|
|||
|
||||
$Language = new dbLanguage($localeFromHTTP);
|
||||
|
||||
// Timezone
|
||||
$iniDate = ini_get('date.timezone');
|
||||
if(empty($iniDate)) {
|
||||
date_default_timezone_set('UTC');
|
||||
}
|
||||
|
||||
// Locales
|
||||
setlocale(LC_ALL, $localeFromHTTP);
|
||||
|
||||
// ============================================================================
|
||||
// FUNCTIONS
|
||||
// ============================================================================
|
||||
|
@ -127,7 +136,10 @@ function checkSystem()
|
|||
{
|
||||
$errorText = 'Current PHP version '.phpversion().', you need > 5.3. (ERR_202)';
|
||||
error_log($errorText, 0);
|
||||
array_push($stdOut, $errorText);
|
||||
|
||||
$tmp['title'] = 'PHP version';
|
||||
$tmp['errorText'] = $errorText;
|
||||
array_push($stdOut, $tmp);
|
||||
|
||||
return $stdOut;
|
||||
}
|
||||
|
@ -136,34 +148,46 @@ function checkSystem()
|
|||
{
|
||||
$errorText = 'Missing file, upload the file .htaccess (ERR_201)';
|
||||
error_log($errorText, 0);
|
||||
array_push($stdOut, $errorText);
|
||||
|
||||
$tmp['title'] = 'File .htaccess';
|
||||
$tmp['errorText'] = $errorText;
|
||||
array_push($stdOut, $tmp);
|
||||
}
|
||||
|
||||
if(!in_array('dom', $phpModules))
|
||||
{
|
||||
$errorText = 'PHP module DOM is not installed. (ERR_203)';
|
||||
error_log($errorText, 0);
|
||||
array_push($stdOut, $errorText);
|
||||
|
||||
$tmp['title'] = 'PHP module';
|
||||
$tmp['errorText'] = $errorText;
|
||||
array_push($stdOut, $tmp);
|
||||
}
|
||||
|
||||
if(!in_array('json', $phpModules))
|
||||
{
|
||||
$errorText = 'PHP module JSON is not installed. (ERR_204)';
|
||||
error_log($errorText, 0);
|
||||
array_push($stdOut, $errorText);
|
||||
|
||||
$tmp['title'] = 'PHP module';
|
||||
$tmp['errorText'] = $errorText;
|
||||
array_push($stdOut, $tmp);
|
||||
}
|
||||
|
||||
if(!is_writable(PATH_CONTENT))
|
||||
{
|
||||
$errorText = 'Writing test failure, check directory content permissions. (ERR_205)';
|
||||
error_log($errorText, 0);
|
||||
array_push($stdOut, $errorText);
|
||||
|
||||
$tmp['title'] = 'PHP permissions';
|
||||
$tmp['errorText'] = $errorText;
|
||||
array_push($stdOut, $tmp);
|
||||
}
|
||||
|
||||
return $stdOut;
|
||||
}
|
||||
|
||||
function install($adminPassword, $email)
|
||||
function install($adminPassword, $email, $timezoneOffset)
|
||||
{
|
||||
global $Language;
|
||||
|
||||
|
@ -171,6 +195,8 @@ function install($adminPassword, $email)
|
|||
|
||||
$currentDate = Date::current(DB_DATE_FORMAT);
|
||||
|
||||
$timezone = timezone_name_from_abbr("", $timezoneOffset, 0);
|
||||
|
||||
// ============================================================================
|
||||
// Create directories
|
||||
// ============================================================================
|
||||
|
@ -242,7 +268,7 @@ function install($adminPassword, $email)
|
|||
'username'=>'admin',
|
||||
'status'=>'published',
|
||||
'tags'=>array('bludit'=>'Bludit','cms'=>'CMS','flat-files'=>'Flat files'),
|
||||
'allowComments'=>false,
|
||||
'allowComments'=>'false',
|
||||
'date'=>$currentDate
|
||||
)
|
||||
);
|
||||
|
@ -256,7 +282,7 @@ function install($adminPassword, $email)
|
|||
'footer'=>Date::current('Y'),
|
||||
'language'=>$Language->getCurrentLocale(),
|
||||
'locale'=>$Language->getCurrentLocale(),
|
||||
'timezone'=>'UTC',
|
||||
'timezone'=>$timezone,
|
||||
'theme'=>'pure',
|
||||
'adminTheme'=>'default',
|
||||
'homepage'=>'',
|
||||
|
@ -265,7 +291,8 @@ function install($adminPassword, $email)
|
|||
'uriPage'=>'/',
|
||||
'uriTag'=>'/tag/',
|
||||
'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);
|
||||
|
@ -399,7 +426,7 @@ function checkPOST($args)
|
|||
$email = sanitize::email($args['email']);
|
||||
|
||||
// Install Bludit
|
||||
install($args['password'], $email, $args['language']);
|
||||
install($args['password'], $email, $args['timezone']);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -431,9 +458,8 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
|||
}
|
||||
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<!DOCTYPE HTML>
|
||||
<html class="uk-height-1-1 uk-notouch">
|
||||
<head>
|
||||
<base href="admin/themes/default/">
|
||||
<meta charset="<?php echo CHARSET ?>">
|
||||
|
@ -441,86 +467,87 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
|||
|
||||
<title><?php echo $Language->get('Bludit Installer') ?></title>
|
||||
|
||||
<link rel="stylesheet" href="./css/kube.min.css">
|
||||
<link rel="stylesheet" href="./css/installer.css">
|
||||
<!-- Favicon -->
|
||||
<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>
|
||||
<body>
|
||||
<div class="units-row">
|
||||
<div class="unit-centered unit-60">
|
||||
<div class="main">
|
||||
|
||||
<body class="uk-height-1-1">
|
||||
<div class="uk-vertical-align uk-text-center uk-height-1-1">
|
||||
<div class="uk-vertical-align-middle">
|
||||
<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
|
||||
|
||||
$system = checkSystem();
|
||||
|
||||
// Missing requirements
|
||||
if(!empty($system))
|
||||
{
|
||||
echo '<div class="boxInstallerForm unit-centered unit-50">';
|
||||
echo '<table class="table-stripped">';
|
||||
|
||||
foreach($system as $value) {
|
||||
echo '<tr><td>'.$value.'</td></tr>';
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
foreach($system as $values)
|
||||
{
|
||||
echo '<div class="uk-panel">';
|
||||
echo '<div class="uk-panel-badge uk-badge uk-badge-danger">FAIL</div>';
|
||||
echo '<h3 class="uk-panel-title">'.$values['title'].'</h3>';
|
||||
echo $values['errorText'];
|
||||
echo '</div>';
|
||||
}
|
||||
}
|
||||
// Second step
|
||||
elseif(isset($_GET['language']))
|
||||
{
|
||||
|
||||
?>
|
||||
<p><?php echo $Language->get('Complete the form choose a password for the username admin') ?></p>
|
||||
|
||||
<div class="boxInstallerForm unit-centered unit-40">
|
||||
|
||||
<?php
|
||||
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="language" id="jslanguage" value="<?php echo $localeFromHTTP ?>">
|
||||
<input type="hidden" name="timezone" id="jstimezone" value="0">
|
||||
|
||||
<label>
|
||||
<input type="text" value="admin" disabled="disabled" class="width-100">
|
||||
</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 class="uk-form-row">
|
||||
<input type="text" value="admin" class="uk-width-9-10 uk-form-large" disabled>
|
||||
</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
|
||||
} // END elseif(isset($_GET['language']))
|
||||
}
|
||||
else
|
||||
{
|
||||
?>
|
||||
<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">
|
||||
|
||||
<label for="jslanguage">
|
||||
<select id="jslanguage" name="language" class="width-100">
|
||||
<div class="uk-form-row">
|
||||
<select id="jslanguage" name="language" class="uk-width-1-1">
|
||||
<?php
|
||||
$htmlOptions = getLanguageList();
|
||||
foreach($htmlOptions as $locale=>$nativeName) {
|
||||
|
@ -528,31 +555,51 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
|||
}
|
||||
?>
|
||||
</select>
|
||||
</label>
|
||||
|
||||
<p><button class="btn btn-blue width-100"><?php echo $Language->get('Next') ?></button>
|
||||
</p>
|
||||
</form>
|
||||
</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>
|
||||
|
||||
<script>
|
||||
$(document).ready(function()
|
||||
{
|
||||
// Set timezone
|
||||
var timezoneOffset = -(new Date().getTimezoneOffset() * 60);
|
||||
$("#jstimezone").val(timezoneOffset);
|
||||
|
||||
// Proceed without email field.
|
||||
$("#jscompleteEmail").on("click", function() {
|
||||
|
||||
$("#jsnoCheckEmail").val("1");
|
||||
if(!$("jspassword").val()) {
|
||||
|
||||
if(!$("#jspassword").val()) {
|
||||
$("#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>
|
||||
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -73,7 +73,7 @@ define('DB_DATE_FORMAT', 'Y-m-d H:i');
|
|||
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
|
||||
define('TOKEN_TTL', '+1 day');
|
||||
define('TOKEN_EMAIL_TTL', '+15 minutes');
|
||||
|
||||
// Charset, default UTF-8.
|
||||
define('CHARSET', 'UTF-8');
|
||||
|
|
|
@ -189,11 +189,13 @@ class dbSite extends dbJSON
|
|||
// Set the locale.
|
||||
public function setLocale($locale)
|
||||
{
|
||||
if(setlocale(LC_ALL, $locale.'.UTF-8')!==false)
|
||||
if(setlocale(LC_ALL, $locale.'.UTF-8')!==false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if(setlocale(LC_ALL, $locale.'.UTF8')!==false)
|
||||
if(setlocale(LC_ALL, $locale.'.UTF8')!==false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return setlocale(LC_ALL, $locale);
|
||||
}
|
||||
|
|
|
@ -33,12 +33,12 @@ class dbUsers extends dbJSON
|
|||
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)
|
||||
{
|
||||
foreach($this->db as $user) {
|
||||
if($user['email']==$email) {
|
||||
return $user;
|
||||
foreach($this->db as $username=>$values) {
|
||||
if($values['email']==$email) {
|
||||
return $username;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,8 +62,8 @@ class dbUsers extends dbJSON
|
|||
$token = sha1(Text::randomText(SALT_LENGTH).time());
|
||||
$this->db[$username]['tokenEmail'] = $token;
|
||||
|
||||
// Token time to live, defined by TOKEN_TTL
|
||||
$this->db[$username]['tokenEmailTTL'] = Date::currentOffset(DB_DATE_FORMAT, TOKEN_TTL);
|
||||
// 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 ) {
|
||||
|
|
|
@ -190,5 +190,5 @@
|
|||
"send-me-a-login-access-code": "Send me a 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>",
|
||||
"there-are-no-scheduled-posts": "There are no scheduled posts"
|
||||
"there-are-no-scheduled-posts": "There are no scheduled posts."
|
||||
}
|
Loading…
Reference in New Issue