diff --git a/admin/controllers/login-email.php b/admin/controllers/login-email.php index 32b0f79e..28ccbb1d 100644 --- a/admin/controllers/login-email.php +++ b/admin/controllers/login-email.php @@ -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( diff --git a/admin/themes/default/css/form-password.almost-flat.min.css b/admin/themes/default/css/form-password.almost-flat.min.css new file mode 100755 index 00000000..efdc7aa8 --- /dev/null +++ b/admin/themes/default/css/form-password.almost-flat.min.css @@ -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} \ No newline at end of file diff --git a/admin/themes/default/css/installer.css b/admin/themes/default/css/installer.css new file mode 100644 index 00000000..fe465151 --- /dev/null +++ b/admin/themes/default/css/installer.css @@ -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; +} \ No newline at end of file diff --git a/admin/themes/default/index.php b/admin/themes/default/index.php index 2c1bb726..f800b244 100644 --- a/admin/themes/default/index.php +++ b/admin/themes/default/index.php @@ -19,7 +19,6 @@ - diff --git a/admin/themes/default/js/form-password.min.js b/admin/themes/default/js/form-password.min.js new file mode 100755 index 00000000..f5495f78 --- /dev/null +++ b/admin/themes/default/js/form-password.min.js @@ -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}); \ No newline at end of file diff --git a/admin/themes/default/login.php b/admin/themes/default/login.php index 43f58412..628d088e 100644 --- a/admin/themes/default/login.php +++ b/admin/themes/default/login.php @@ -12,7 +12,7 @@ - + diff --git a/install.php b/install.php index 844cf5a4..b552088f 100644 --- a/install.php +++ b/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' ) } ?> - - - + + @@ -441,86 +467,87 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' ) <?php echo $Language->get('Bludit Installer') ?> - - + + + + + + + + + + + + - - - -
-
-
- + +
+

get('Bludit Installer') ?>

-

get('Welcome to the Bludit installer') ?>

+
'; - echo ''; - - foreach($system as $value) { - echo ''; + // Missing requirements + if(!empty($system)) + { + foreach($system as $values) + { + echo '
'; + echo '
FAIL
'; + echo '

'.$values['title'].'

'; + echo $values['errorText']; + echo '
'; + } } - - echo '
'.$value.'
'; - echo '
'; - } - // Second step - elseif(isset($_GET['language'])) - { - + // Second step + elseif(isset($_GET['language'])) + { ?>

get('Complete the form choose a password for the username admin') ?>

-
- '.$error.'
'; + echo '
'.$error.'
'; } ?> -
- + - + - - - - - - -

-

-
+
+
+ +
+ + + +
+ +
+ +
+ +
+ +
+ +

get('Choose your language') ?>

-
+
- - - - -

-

-
- +
+ +
+ + + +
-
\ No newline at end of file diff --git a/kernel/boot/init.php b/kernel/boot/init.php index fe44b730..5a88b2c8 100644 --- a/kernel/boot/init.php +++ b/kernel/boot/init.php @@ -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'); diff --git a/kernel/dbsite.class.php b/kernel/dbsite.class.php index 5d12c517..b1058d9a 100644 --- a/kernel/dbsite.class.php +++ b/kernel/dbsite.class.php @@ -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); } @@ -204,4 +206,4 @@ class dbSite extends dbJSON return date_default_timezone_set($timezone); } -} +} \ No newline at end of file diff --git a/kernel/dbusers.class.php b/kernel/dbusers.class.php index d85bafcc..b13bf1ee 100644 --- a/kernel/dbusers.class.php +++ b/kernel/dbusers.class.php @@ -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 ) { diff --git a/languages/en_US.json b/languages/en_US.json index 939bbf05..cb45a200 100644 --- a/languages/en_US.json +++ b/languages/en_US.json @@ -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": "

This is a notification from your website {{WEBSITE_NAME}}

You request a login access code, follow the next link:

{{LINK}}

", - "there-are-no-scheduled-posts": "There are no scheduled posts" + "there-are-no-scheduled-posts": "There are no scheduled posts." } \ No newline at end of file