diff --git a/README.md b/README.md index d36153d1..5e95096b 100644 --- a/README.md +++ b/README.md @@ -17,17 +17,19 @@ Social - [Facebook](https://www.facebook.com/bluditcms) - [Google+](https://plus.google.com/+Bluditcms) +[![Join the chat at https://gitter.im/dignajar/bludit](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/dignajar/bludit?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) + Requirements ------------ -You only need a Webserver with PHP support. +You only need a web server with PHP support. - PHP 5.3 or higher. -- PHP module [mbstring](http://php.net/manual/en/book.mbstring.php) for full UTF-8 support. +- PHP [mbstring](http://php.net/manual/en/book.mbstring.php) module for full UTF-8 support. - Webserver: - * Apache with module [mod_rewrite](http://httpd.apache.org/docs/current/mod/mod_rewrite.html) - * Lighttpd with module [mod_rewrite](http://redmine.lighttpd.net/projects/1/wiki/docs_modrewrite) - * Nginx with module [ngx_http_rewrite_module](http://nginx.org/en/docs/http/ngx_http_rewrite_module.html) + * Apache with [mod_rewrite](http://httpd.apache.org/docs/current/mod/mod_rewrite.html) module. + * Lighttpd with [mod_rewrite](http://redmine.lighttpd.net/projects/1/wiki/docs_modrewrite) module. + * Nginx with [ngx_http_rewrite_module](http://nginx.org/en/docs/http/ngx_http_rewrite_module.html) module. Installation guide ------------------ diff --git a/admin/README b/admin/README.md similarity index 100% rename from admin/README rename to admin/README.md diff --git a/admin/controllers/add-user.php b/admin/controllers/add-user.php index 723f0564..ce004cf3 100644 --- a/admin/controllers/add-user.php +++ b/admin/controllers/add-user.php @@ -18,30 +18,44 @@ function addUser($args) global $dbUsers; global $Language; - // Check if the username already exist in db. - if( Text::isEmpty($args['username']) ) + // Check empty username + if( Text::isEmpty($args['new_username']) ) { - Alert::set($Language->g('username-field-is-empty')); + Alert::set($Language->g('username-field-is-empty'), ALERT_STATUS_FAIL); return false; } - if( $dbUsers->userExists($args['username']) ) + // Check already exist username + if( $dbUsers->userExists($args['new_username']) ) { - Alert::set($Language->g('username-already-exists')); + Alert::set($Language->g('username-already-exists'), ALERT_STATUS_FAIL); return false; } - // Validate password. - if( ($args['password'] != $args['confirm-password'] ) || Text::isEmpty($args['password']) ) + // Password length + if( strlen($args['new_password']) < 6 ) { - Alert::set($Language->g('The password and confirmation password do not match')); + Alert::set($Language->g('Password must be at least 6 characters long'), ALERT_STATUS_FAIL); return false; } - // Add the user. - if( $dbUsers->add($args) ) + // Check new password and confirm password are equal + if( $args['new_password'] != $args['confirm_password'] ) { - Alert::set($Language->g('user-has-been-added-successfully')); + Alert::set($Language->g('The password and confirmation password do not match'), ALERT_STATUS_FAIL); + return false; + } + + // Filter form fields + $tmp = array(); + $tmp['username'] = $args['new_username']; + $tmp['password'] = $args['new_password']; + $tmp['role'] = $args['role']; + + // Add the user to the database + if( $dbUsers->add($tmp) ) + { + Alert::set($Language->g('user-has-been-added-successfully'), ALERT_STATUS_OK); return true; } else diff --git a/admin/controllers/edit-user.php b/admin/controllers/edit-user.php index 39a6bd7c..6b85671d 100644 --- a/admin/controllers/edit-user.php +++ b/admin/controllers/edit-user.php @@ -17,26 +17,6 @@ function editUser($args) } } -function setPassword($username, $new_password, $confirm_password) -{ - global $dbUsers; - global $Language; - - if( ($new_password===$confirm_password) && !Text::isEmpty($new_password) ) - { - if( $dbUsers->setPassword($username, $new_password) ) { - Alert::set($Language->g('The changes have been saved')); - } - else { - Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to change the user password.'); - } - } - else { - Alert::set($Language->g('The password and confirmation password do not match')); - return false; - } -} - function deleteUser($args, $deleteContent=false) { global $dbUsers; @@ -92,10 +72,6 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' ) elseif(isset($_POST['delete-user-associate'])) { deleteUser($_POST, false); } - elseif( !empty($_POST['new-password']) && !empty($_POST['confirm-password']) ) { - setPassword($_POST['username'], $_POST['new-password'], $_POST['confirm-password']); - editUser($_POST); - } else { editUser($_POST); } diff --git a/admin/controllers/user-password.php b/admin/controllers/user-password.php new file mode 100644 index 00000000..6b4c977a --- /dev/null +++ b/admin/controllers/user-password.php @@ -0,0 +1,73 @@ +g('Password must be at least 6 characters long'), ALERT_STATUS_FAIL); + return false; + } + + if($new_password===$confirm_password) + { + if( $dbUsers->setPassword($username, $new_password) ) { + Alert::set($Language->g('The changes have been saved'), ALERT_STATUS_OK); + return true; + } + else { + Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to change the user password.'); + return false; + } + } + else { + Alert::set($Language->g('The password and confirmation password do not match'), ALERT_STATUS_FAIL); + return false; + } +} + +// ============================================================================ +// Main before POST +// ============================================================================ + +// ============================================================================ +// POST Method +// ============================================================================ + +if( $_SERVER['REQUEST_METHOD'] == 'POST' ) +{ + // Prevent editors to administrate other users. + if($Login->role()!=='admin') + { + $_POST['username'] = $Login->username(); + unset($_POST['role']); + } + + if( setPassword($_POST['username'], $_POST['new_password'], $_POST['confirm_password']) ) { + Redirect::page('admin', 'users'); + } +} + +// ============================================================================ +// Main after POST +// ============================================================================ + +if($Login->role()!=='admin') { + $layout['parameters'] = $Login->username(); +} + +$_user = $dbUsers->getDb($layout['parameters']); + +// If the user doesn't exist, redirect to the users list. +if($_user===false) { + Redirect::page('admin', 'users'); +} + +$_user['username'] = $layout['parameters']; diff --git a/admin/themes/default/css/default.css b/admin/themes/default/css/default.css index 9d2e79ab..378232e9 100644 --- a/admin/themes/default/css/default.css +++ b/admin/themes/default/css/default.css @@ -99,9 +99,14 @@ button.delete-button:hover { text-decoration: underline; } +#jscontent { + height: 400px; +} + +/* ----------- ALERT ----------- */ + #alert { display: none; - background: rgba(48, 102, 187, 0.91); color: #ffffff; padding: 24px; position: fixed; @@ -110,6 +115,14 @@ button.delete-button:hover { z-index: 100; } +.alert-ok { + background: rgba(48, 102, 187, 0.91); +} + +.alert-fail { + background: rgba(187, 48, 48, 0.91); +} + /* ----------- LOGIN FORM ----------- */ div.login-box > h1 { diff --git a/admin/themes/default/css/form-file.min.css b/admin/themes/default/css/form-file.min.css new file mode 100644 index 00000000..8b573dcc --- /dev/null +++ b/admin/themes/default/css/form-file.min.css @@ -0,0 +1,2 @@ +/*! UIkit 2.23.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +.uk-form-file{display:inline-block;vertical-align:middle;position:relative;overflow:hidden}.uk-form-file input[type=file]{position:absolute;top:0;z-index:1;width:100%;opacity:0;cursor:pointer;left:0;font-size:500px} \ No newline at end of file diff --git a/admin/themes/default/css/form-password.almost-flat.min.css b/admin/themes/default/css/form-password.almost-flat.min.css deleted file mode 100644 index efdc7aa8..00000000 --- a/admin/themes/default/css/form-password.almost-flat.min.css +++ /dev/null @@ -1,2 +0,0 @@ -/*! 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/placeholder.min.css b/admin/themes/default/css/placeholder.min.css new file mode 100644 index 00000000..3680b109 --- /dev/null +++ b/admin/themes/default/css/placeholder.min.css @@ -0,0 +1,2 @@ +/*! UIkit 2.23.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +.uk-placeholder{margin-bottom:15px;padding:15px;border:1px dashed #ddd;background:#fafafa;color:#444}*+.uk-placeholder{margin-top:15px}.uk-placeholder>:last-child{margin-bottom:0}.uk-placeholder-large{padding-top:80px;padding-bottom:80px} \ No newline at end of file diff --git a/admin/themes/default/css/progress.min.css b/admin/themes/default/css/progress.min.css new file mode 100644 index 00000000..2e0c853f --- /dev/null +++ b/admin/themes/default/css/progress.min.css @@ -0,0 +1,2 @@ +/*! UIkit 2.23.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +.uk-progress{box-sizing:border-box;height:20px;margin-bottom:15px;background:#eee;overflow:hidden;line-height:20px}*+.uk-progress{margin-top:15px}.uk-progress-bar{width:0;height:100%;background:#00a8e6;float:left;-webkit-transition:width .6s ease;transition:width .6s ease;font-size:12px;color:#fff;text-align:center}.uk-progress-mini{height:6px}.uk-progress-small{height:12px}.uk-progress-success .uk-progress-bar{background-color:#8cc14c}.uk-progress-warning .uk-progress-bar{background-color:#faa732}.uk-progress-danger .uk-progress-bar{background-color:#da314b}.uk-progress-striped .uk-progress-bar{background-image:-webkit-linear-gradient(-45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-image:linear-gradient(-45deg,rgba(255,255,255,.15) 25%,transparent 25%,transparent 50%,rgba(255,255,255,.15) 50%,rgba(255,255,255,.15) 75%,transparent 75%,transparent);background-size:30px 30px}.uk-progress-striped.uk-active .uk-progress-bar{-webkit-animation:uk-progress-bar-stripes 2s linear infinite;animation:uk-progress-bar-stripes 2s linear infinite}@-webkit-keyframes uk-progress-bar-stripes{0%{background-position:0 0}100%{background-position:30px 0}}@keyframes uk-progress-bar-stripes{0%{background-position:0 0}100%{background-position:30px 0}} \ No newline at end of file diff --git a/admin/themes/default/css/upload.min.css b/admin/themes/default/css/upload.min.css new file mode 100644 index 00000000..2e72139b --- /dev/null +++ b/admin/themes/default/css/upload.min.css @@ -0,0 +1,2 @@ +/*! UIkit 2.23.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +.uk-dragover{box-shadow:0 0 20px rgba(100,100,100,.3)} \ No newline at end of file diff --git a/admin/themes/default/index.php b/admin/themes/default/index.php index 4164a56d..dae2d4d1 100644 --- a/admin/themes/default/index.php +++ b/admin/themes/default/index.php @@ -15,11 +15,16 @@ + + + + + @@ -43,7 +48,7 @@ $(document).ready(function() { }); -
'.$args['tip'].'
'; @@ -125,4 +126,78 @@ class HTML { $html = ''; } -} + public static function uploader() + { + global $L; + + $html = ' +