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() { }); -
+
diff --git a/admin/themes/default/init.php b/admin/themes/default/init.php index 51780c98..58f1cce4 100644 --- a/admin/themes/default/init.php +++ b/admin/themes/default/init.php @@ -30,6 +30,7 @@ class HTML { $type = isset($args['type']) ? $args['type'] : 'text'; $class = empty($args['class']) ? '' : 'class="'.$args['class'].'"'; $placeholder = empty($args['placeholder']) ? '' : 'placeholder="'.$args['placeholder'].'"'; + $disabled = empty($args['disabled']) ? '' : 'disabled'; $html = '
'; @@ -39,7 +40,7 @@ class HTML { $html .= '
'; - $html .= ''; + $html .= ''; if(!empty($args['tip'])) { $html .= '

'.$args['tip'].'

'; @@ -125,4 +126,78 @@ class HTML { $html = ''; } -} + public static function uploader() + { + global $L; + + $html = ' +
+ '.$L->g('Upload Image').'
'.$L->g('Drag and drop or click here').' +
+ +
+
0%
+
+ '; + + $html .= ''; + + $html .= ' +
+ +
+ '; + + $html .= ' + '; + + echo $html; + } + +} \ No newline at end of file diff --git a/admin/themes/default/js/form-password.min.js b/admin/themes/default/js/form-password.min.js deleted file mode 100644 index f5495f78..00000000 --- a/admin/themes/default/js/form-password.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/*! 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/js/upload.min.js b/admin/themes/default/js/upload.min.js new file mode 100644 index 00000000..47420d36 --- /dev/null +++ b/admin/themes/default/js/upload.min.js @@ -0,0 +1,2 @@ +/*! UIkit 2.23.0 | http://www.getuikit.com | (c) 2014 YOOtheme | MIT License */ +!function(e){var t;window.UIkit&&(t=e(UIkit)),"function"==typeof define&&define.amd&&define("uikit-upload",["uikit"],function(){return t||e(UIkit)})}(function(e){"use strict";function t(o,a){function r(t,n){var o=new FormData,a=new XMLHttpRequest;if(n.before(n,t)!==!1){for(var r,i=0;r=t[i];i++)o.append(n.param,r);for(var l in n.params)o.append(l,n.params[l]);a.upload.addEventListener("progress",function(e){var t=e.loaded/e.total*100;n.progress(t,e)},!1),a.addEventListener("loadstart",function(e){n.loadstart(e)},!1),a.addEventListener("load",function(e){n.load(e)},!1),a.addEventListener("loadend",function(e){n.loadend(e)},!1),a.addEventListener("error",function(e){n.error(e)},!1),a.addEventListener("abort",function(e){n.abort(e)},!1),a.open(n.method,n.action,!0),"json"==n.type&&a.setRequestHeader("Accept","application/json"),a.onreadystatechange=function(){if(n.readystatechange(a),4==a.readyState){var t=a.responseText;if("json"==n.type)try{t=e.$.parseJSON(t)}catch(o){t=!1}n.complete(t,a)}},n.beforeSend(a),a.send(o)}}if(!e.support.ajaxupload)return this;if(a=e.$.extend({},t.defaults,a),o.length){if("*.*"!==a.allow)for(var i,l=0;i=o[l];l++)if(!n(a.allow,i.name))return"string"==typeof a.notallowed?alert(a.notallowed):a.notallowed(i,a),void 0;var s=a.complete;if(a.single){var d=o.length,f=0,p=!0;a.beforeAll(o),a.complete=function(e,t){f+=1,s(e,t),a.filelimit&&f>=a.filelimit&&(p=!1),p&&d>f?r([o[f]],a):a.allcomplete(e,t)},r([o[0]],a)}else a.complete=function(e,t){s(e,t),a.allcomplete(e,t)},r(o,a)}}function n(e,t){var n="^"+e.replace(/\//g,"\\/").replace(/\*\*/g,"(\\/[^\\/]+)*").replace(/\*/g,"[^\\/]+").replace(/((?!\\))\?/g,"$1.")+"$";return n="^"+n+"$",null!==t.match(new RegExp(n,"i"))}return e.component("uploadSelect",{init:function(){var e=this;this.on("change",function(){t(e.element[0].files,e.options);var n=e.element.clone(!0).data("uploadSelect",e);e.element.replaceWith(n),e.element=n})}}),e.component("uploadDrop",{defaults:{dragoverClass:"uk-dragover"},init:function(){var e=this,n=!1;this.on("drop",function(n){n.dataTransfer&&n.dataTransfer.files&&(n.stopPropagation(),n.preventDefault(),e.element.removeClass(e.options.dragoverClass),e.element.trigger("dropped.uk.upload",[n.dataTransfer.files]),t(n.dataTransfer.files,e.options))}).on("dragenter",function(e){e.stopPropagation(),e.preventDefault()}).on("dragover",function(t){t.stopPropagation(),t.preventDefault(),n||(e.element.addClass(e.options.dragoverClass),n=!0)}).on("dragleave",function(t){t.stopPropagation(),t.preventDefault(),e.element.removeClass(e.options.dragoverClass),n=!1})}}),e.support.ajaxupload=function(){function e(){var e=document.createElement("INPUT");return e.type="file","files"in e}function t(){var e=new XMLHttpRequest;return!!(e&&"upload"in e&&"onprogress"in e.upload)}function n(){return!!window.FormData}return e()&&t()&&n()}(),e.support.ajaxupload&&e.$.event.props.push("dataTransfer"),t.defaults={action:"",single:!0,method:"POST",param:"files[]",params:{},allow:"*.*",type:"text",filelimit:!1,before:function(){},beforeSend:function(){},beforeAll:function(){},loadstart:function(){},load:function(){},loadend:function(){},error:function(){},abort:function(){},progress:function(){},complete:function(){},allcomplete:function(){},readystatechange:function(){},notallowed:function(e,t){alert("Only the following file types are allowed: "+t.allow)}},e.Utils.xhrupload=t,t}); \ No newline at end of file diff --git a/admin/views/add-user.php b/admin/views/add-user.php index ff3b871d..2b7230e0 100644 --- a/admin/views/add-user.php +++ b/admin/views/add-user.php @@ -2,7 +2,7 @@ HTML::title(array('title'=>$L->g('Add a new user'), 'icon'=>'user-plus')); -HTML::formOpen(array('class'=>'uk-form-horizontal')); +HTML::formOpen(array('id'=>'add-user-form', 'class'=>'uk-form-horizontal')); // Security token HTML::formInputHidden(array( @@ -11,15 +11,15 @@ HTML::formOpen(array('class'=>'uk-form-horizontal')); )); HTML::formInputText(array( - 'name'=>'username', + 'name'=>'new_username', 'label'=>$L->g('Username'), - 'value'=>(isset($_POST['username'])?$_POST['username']:''), + 'value'=>(isset($_POST['new_username'])?$_POST['new_username']:''), 'class'=>'uk-width-1-2 uk-form-medium', 'tip'=>'' )); HTML::formInputPassword(array( - 'name'=>'password', + 'name'=>'new_password', 'label'=>$L->g('Password'), 'value'=>'', 'class'=>'uk-width-1-2 uk-form-medium', @@ -27,7 +27,7 @@ HTML::formOpen(array('class'=>'uk-form-horizontal')); )); HTML::formInputPassword(array( - 'name'=>'confirm-password', + 'name'=>'confirm_password', 'label'=>$L->g('Confirm Password'), 'value'=>'', 'class'=>'uk-width-1-2 uk-form-medium', diff --git a/admin/views/edit-page.php b/admin/views/edit-page.php index 1e05de23..02ce7c86 100644 --- a/admin/views/edit-page.php +++ b/admin/views/edit-page.php @@ -57,6 +57,7 @@ echo '
'; // Tabs, general and advanced mode echo ''; @@ -86,6 +87,13 @@ echo '
'; echo ''; + // ---- IMAGES TAB ---- + echo '
  • '; + + HTML::uploader(); + + echo '
  • '; + // ---- ADVANCED TAB ---- echo '
  • '; diff --git a/admin/views/edit-post.php b/admin/views/edit-post.php index 9a26ec14..cab1c9c7 100644 --- a/admin/views/edit-post.php +++ b/admin/views/edit-post.php @@ -51,6 +51,7 @@ echo '
    '; // Tabs, general and advanced mode echo ''; @@ -80,6 +81,13 @@ echo '
    '; echo '
  • '; + // ---- IMAGES TAB ---- + echo '
  • '; + + HTML::uploader(); + + echo '
  • '; + // ---- ADVANCED TAB ---- echo '
  • '; diff --git a/admin/views/edit-user.php b/admin/views/edit-user.php index 6416e9b5..bb336c46 100644 --- a/admin/views/edit-user.php +++ b/admin/views/edit-user.php @@ -1,8 +1,8 @@ $L->g('Edit user').' :: '.$_user['username'], 'icon'=>'user')); +HTML::title(array('title'=>$L->g('Edit user'), 'icon'=>'user')); -HTML::formOpen(array('class'=>'uk-form-horizontal')); +HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal')); // Security token HTML::formInputHidden(array( @@ -18,6 +18,15 @@ HTML::formOpen(array('class'=>'uk-form-horizontal')); HTML::legend(array('value'=>$L->g('Profile'))); + HTML::formInputText(array( + 'name'=>'usernameDisable', + 'label'=>$L->g('Username'), + 'value'=>$_user['username'], + 'class'=>'uk-width-1-2 uk-form-medium', + 'disabled'=>true, + 'tip'=>'' + )); + HTML::formInputText(array( 'name'=>'firstName', 'label'=>$L->g('First name'), @@ -34,6 +43,13 @@ HTML::formOpen(array('class'=>'uk-form-horizontal')); 'tip'=>'' )); + echo '
    + + +
    '; + if($Login->role()==='admin') { HTML::formSelect(array( @@ -54,24 +70,6 @@ if($Login->role()==='admin') { 'tip'=>$L->g('email-will-not-be-publicly-displayed') )); - HTML::legend(array('value'=>$L->g('Change password'))); - - HTML::formInputPassword(array( - 'name'=>'new-password', - 'label'=>$L->g('New password'), - 'value'=>'', - 'class'=>'uk-width-1-2 uk-form-medium', - 'tip'=>'' - )); - - HTML::formInputPassword(array( - 'name'=>'confirm-password', - 'label'=>$L->g('Confirm Password'), - 'value'=>'', - 'class'=>'uk-width-1-2 uk-form-medium', - 'tip'=>'' - )); - echo '
    diff --git a/admin/views/manage-pages.php b/admin/views/manage-pages.php index 26f3bcd2..fa8754ac 100644 --- a/admin/views/manage-pages.php +++ b/admin/views/manage-pages.php @@ -27,7 +27,7 @@ echo ' } echo ''; - echo ''.($Page->parentKey()?NO_PARENT_CHAR:'').''.($Page->published()?'':''.$Language->g('Draft').' ').($Page->title()?$Page->title():''.$Language->g('Empty title').' ').''; + echo ''.($Page->parentKey()?'- ':'').''.($Page->published()?'':''.$Language->g('Draft').' ').($Page->title()?$Page->title():''.$Language->g('Empty title').' ').''; echo ''.$parentTitle.''; echo ''.$Page->position().''; echo ''.$Url->filters('page').'/'.$Page->key().''; diff --git a/admin/views/new-page.php b/admin/views/new-page.php index 9f1f00b6..9319170e 100644 --- a/admin/views/new-page.php +++ b/admin/views/new-page.php @@ -44,8 +44,10 @@ echo '
    '; // Tabs, general and advanced mode echo ''; + echo '
      '; // ---- GENERAL TAB ---- @@ -72,6 +74,13 @@ echo '
      '; echo ''; + // ---- IMAGES TAB ---- + echo '
    • '; + + HTML::uploader(); + + echo '
    • '; + // ---- ADVANCED TAB ---- echo '
    • '; diff --git a/admin/views/new-post.php b/admin/views/new-post.php index e1a24a91..3d89fb99 100644 --- a/admin/views/new-post.php +++ b/admin/views/new-post.php @@ -44,6 +44,7 @@ echo '
      '; // Tabs, general and advanced mode echo ''; @@ -73,6 +74,13 @@ echo '
      '; echo '
    • '; + // ---- IMAGES TAB ---- + echo '
    • '; + + HTML::uploader(); + + echo '
    • '; + // ---- ADVANCED TAB ---- echo '
    • '; diff --git a/admin/views/user-password.php b/admin/views/user-password.php new file mode 100644 index 00000000..d51fa456 --- /dev/null +++ b/admin/views/user-password.php @@ -0,0 +1,55 @@ +$L->g('Change password'), 'icon'=>'key')); + +HTML::formOpen(array('id'=>'edit-user-profile-form','class'=>'uk-form-horizontal')); + + // Security token + HTML::formInputHidden(array( + 'name'=>'tokenCSRF', + 'value'=>$Security->getToken() + )); + + // Hidden field username + HTML::formInputHidden(array( + 'name'=>'username', + 'value'=>$_user['username'] + )); + + HTML::legend(array('value'=>$L->g('New password'))); + + HTML::formInputText(array( + 'name'=>'usernameDisable', + 'label'=>$L->g('Username'), + 'value'=>$_user['username'], + 'class'=>'uk-width-1-2 uk-form-medium', + 'disabled'=>true, + 'tip'=>'' + )); + + HTML::formInputPassword(array( + 'name'=>'new_password', + 'label'=>$L->g('New password'), + 'value'=>'', + 'class'=>'uk-width-1-2 uk-form-medium', + 'tip'=>'' + )); + + HTML::formInputPassword(array( + 'name'=>'confirm_password', + 'label'=>$L->g('Confirm password'), + 'value'=>'', + 'class'=>'uk-width-1-2 uk-form-medium', + 'tip'=>'' + )); + + echo '
      +
      + + '.$L->g('Cancel').' +
      +
      '; + +HTML::formClose(); + +?> \ No newline at end of file diff --git a/content/README b/content/README.md similarity index 100% rename from content/README rename to content/README.md diff --git a/install.php b/install.php index 44c01f7e..7da52d20 100644 --- a/install.php +++ b/install.php @@ -309,10 +309,10 @@ function install($adminPassword, $email, $timezoneOffset) file_put_contents(PATH_DATABASES.'site.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX); + // File users.php $salt = getRandomString(); $passwordHash = sha1($adminPassword.$salt); - // File users.php $data = array( 'admin'=>array( 'firstName'=>'', @@ -329,7 +329,11 @@ function install($adminPassword, $email, $timezoneOffset) file_put_contents(PATH_DATABASES.'users.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX); // File security.php + $randomKey = getRandomString(); + $randomKey = sha1($randomKey); + $data = array( + 'key1'=>$randomKey, 'minutesBlocked'=>5, 'numberFailuresAllowed'=>10, 'blackList'=>array() @@ -408,7 +412,7 @@ Content: ### '.$Language->get('Whats next').' - '.$Language->get('Manage your Bludit from the admin panel').' -- '.$Language->get('Follow Bludit on').' [Twitter](https://twitter.com/bludit) / [Facebook](https://www.facebook.com/pages/Bludit/239255789455913) / [Google+](https://plus.google.com/+Bluditcms) +- '.$Language->get('Follow Bludit on').' [Twitter](https://twitter.com/bludit) / [Facebook](https://www.facebook.com/bluditcms) / [Google+](https://plus.google.com/+Bluditcms) - '.$Language->get('Visit the support forum').' - '.$Language->get('Read the documentation for more information').' - '.$Language->get('Share with your friends and enjoy'); @@ -424,9 +428,9 @@ function checkPOST($args) global $Language; // Check empty password - if(empty($args['password'])) + if( strlen($args['password']) < 6 ) { - return '
      '.$Language->g('The password field is empty').'
      '; + return '
      '.$Language->g('Password must be at least 6 characters long').'
      '; } // Check invalid email @@ -484,14 +488,12 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' ) - - - + + - - - + + diff --git a/kernel/abstract/dbjson.class.php b/kernel/abstract/dbjson.class.php index 2b7aec1d..a792164d 100644 --- a/kernel/abstract/dbjson.class.php +++ b/kernel/abstract/dbjson.class.php @@ -97,4 +97,4 @@ class dbJSON return unserialize($data); } -} +} \ No newline at end of file diff --git a/kernel/ajax/uploader.php b/kernel/ajax/uploader.php new file mode 100644 index 00000000..312c2d56 --- /dev/null +++ b/kernel/ajax/uploader.php @@ -0,0 +1,35 @@ +0, + 'filename'=>$tmpName, + 'date'=>date("F d Y H:i:s.", filemtime(PATH_UPLOADS.$tmpName)) +))); + +?> \ No newline at end of file diff --git a/kernel/boot/init.php b/kernel/boot/init.php index 5a88b2c8..e9471d91 100644 --- a/kernel/boot/init.php +++ b/kernel/boot/init.php @@ -48,14 +48,20 @@ if(!defined('JSON_PRETTY_PRINT')) { define('JSON_PRETTY_PRINT', 128); } +// Alert status ok +define('ALERT_STATUS_OK', 0); + +// Alert status fail +define('ALERT_STATUS_FAIL', 1); + // Salt length define('SALT_LENGTH', 8); // Page brake string define('PAGE_BREAK', ''); -// No parent character -define('NO_PARENT_CHAR', '—'); +// No parent character, md5('No parent') +define('NO_PARENT_CHAR', '3849abb4cb7abd24c2d8dac17b216f17'); // Post per page on Manage->Posts define('POSTS_PER_PAGE_ADMIN', 10); diff --git a/kernel/boot/rules/70.pages.php b/kernel/boot/rules/70.pages.php index 17706471..50d93add 100644 --- a/kernel/boot/rules/70.pages.php +++ b/kernel/boot/rules/70.pages.php @@ -4,7 +4,10 @@ // Variables // ============================================================================ +// Array with all pages. $pages = array(); + +// Array with all pages, order by parent. $pagesParents = array(NO_PARENT_CHAR=>array()); // ============================================================================ @@ -33,12 +36,14 @@ function build_page($key) // Page object, content from FILE. $Page = new Page($key); if( !$Page->isValid() ) { + Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the page from file with key: '.$key); return false; } // Page database, content from DATABASE JSON. $db = $dbPages->getDb($key); if( !$db ) { + Log::set(__METHOD__.LOG_SEP.'Error occurred when trying build the page from database with key: '.$key); return false; } @@ -63,7 +68,6 @@ function build_page($key) $user = $dbUsers->getDb( $Page->username() ); $Page->setField('authorFirstName', $user['firstName'], false); - $Page->setField('authorLastName', $user['lastName'], false); } @@ -86,9 +90,12 @@ function build_all_pages() if($Page!==false) { + // --- Order pages by parents --- + // Generate all posible parents. if( $Page->parentKey()===false ) { + // Add the parent key in the dbPages $dbPages->addParentKey($Page->key()); $pagesParents[NO_PARENT_CHAR][$Page->key()] = $Page; @@ -98,33 +105,27 @@ function build_all_pages() $pagesParents[$Page->parentKey()][$Page->key()] = $Page; } - // $pages array + // --- All pages in 1 array --- $pages[$Page->key()] = $Page; } } - // ======== Order pages ======== + // ======== Sort pages ======== - // DEBUG: No me gusta esta forma de ordenar + $tmpNoParents = $pagesParents[NO_PARENT_CHAR]; + unset($pagesParents[NO_PARENT_CHAR]); - // Order children + // Sort children + $tmpPageWithParent = array(); + foreach($pagesParents as $parentKey=>$childrenPages) + { + $tmpPageWithParent[$parentKey] = $childrenPages; + uasort($tmpPageWithParent[$parentKey], 'orderChildren'); + } + + // Sort parents $tmp = array(); - foreach($pagesParents as $parentKey=>$childrenPages) - { - $tmp[$parentKey] = $childrenPages; - uasort($tmp[$parentKey], 'orderChildren'); - } - - if(isset($tmp[NO_PARENT_CHAR])) - { - $tmpNoParents = $tmp[NO_PARENT_CHAR]; - unset($tmp[NO_PARENT_CHAR]); - } - - $pagesParents = $tmp; - - // Order parents. - foreach($pagesParents as $parentKey=>$childrenPages) + foreach($tmpNoParents as $parentKey=>$childrenPages) { // DEBUG: Workaround, Esto es un bug, cuando se usa el Cli mode // DEBUG: Se genera un padre sin index.txt y adentro hay un hijo @@ -133,7 +134,7 @@ function build_all_pages() } } - $pagesParents = array(NO_PARENT_CHAR=>$tmpNoParents) + $tmp; + $pagesParents = array(NO_PARENT_CHAR=>$tmp) + $tmpPageWithParent; } // ============================================================================ diff --git a/kernel/boot/rules/99.paginator.php b/kernel/boot/rules/99.paginator.php index a6dc929a..31b99f2b 100644 --- a/kernel/boot/rules/99.paginator.php +++ b/kernel/boot/rules/99.paginator.php @@ -20,7 +20,7 @@ Paginator::set('postPerPage', $postPerPage); // Number of posts Paginator::set('numberOfPosts', $numberOfPosts); -$numberOfPages = (int) ceil($numberOfPosts / $postPerPage) -1; +$numberOfPages = (int) max(ceil($numberOfPosts / $postPerPage) -1, 0); Paginator::set('numberOfPages', $numberOfPages); $showOlder = $numberOfPages > $currentPage; diff --git a/kernel/dblanguage.class.php b/kernel/dblanguage.class.php index 58a999cc..6cb9bd11 100644 --- a/kernel/dblanguage.class.php +++ b/kernel/dblanguage.class.php @@ -93,6 +93,7 @@ class dbLanguage extends dbJSON foreach($files as $file) { + $t = new dbJSON($file, false); $native = $t->db['language-data']['native']; $locale = basename($file, '.json'); diff --git a/kernel/dbpages.class.php b/kernel/dbpages.class.php index af815b1d..410553ad 100644 --- a/kernel/dbpages.class.php +++ b/kernel/dbpages.class.php @@ -289,7 +289,7 @@ class dbPages extends dbJSON return $newKey; } - // Return an array with all page's databases. + // Return an array with all databases. public function getAll() { return $this->db; @@ -320,6 +320,14 @@ class dbPages extends dbJSON return $tmp; } + public function count() + { + $count = parent::count(); + + // DEBUG: Less than - 1 because the error page. + return $count - 1; + } + public function regenerateCli() { $db = $this->db; diff --git a/kernel/dbposts.class.php b/kernel/dbposts.class.php index 113d8dff..b78a2cb2 100644 --- a/kernel/dbposts.class.php +++ b/kernel/dbposts.class.php @@ -96,7 +96,7 @@ class dbPosts extends dbJSON // Generate the database key. $key = $this->generateKey($args['slug']); - // The user is always the who is loggued. + // The user is always who is loggued. $args['username'] = Session::get('username'); if( Text::isEmpty($args['username']) ) { return false; diff --git a/kernel/helpers/alert.class.php b/kernel/helpers/alert.class.php index 6b7bd9b6..b0d11bf2 100644 --- a/kernel/helpers/alert.class.php +++ b/kernel/helpers/alert.class.php @@ -2,21 +2,25 @@ class Alert { - // new - public static function set($value, $key='alert') + // Status, 0 = OK, 1 = Fail + public static function set($value, $status=ALERT_STATUS_OK, $key='alert') { Session::set('defined', true); - + Session::set('alertStatus', $status); Session::set($key, $value); } public static function get($key='alert') { Session::set('defined', false); - return Session::get($key); } + public static function status() + { + return Session::get('alertStatus'); + } + public static function p($key='alert') { echo self::get($key); diff --git a/kernel/helpers/email.class.php b/kernel/helpers/email.class.php index 102088d5..0f248049 100644 --- a/kernel/helpers/email.class.php +++ b/kernel/helpers/email.class.php @@ -15,9 +15,9 @@ class Email { BLUDIT - -
      -
      BLUDIT
      + +
      +
      BLUDIT
      '.$args['message'].'
      diff --git a/kernel/helpers/filesystem.class.php b/kernel/helpers/filesystem.class.php index e5a3310e..a05fef82 100644 --- a/kernel/helpers/filesystem.class.php +++ b/kernel/helpers/filesystem.class.php @@ -16,7 +16,7 @@ class Filesystem { return $directories; } - public static function listFiles($path, $regex='*', $extension) + public static function listFiles($path, $regex='*', $extension='*', $sortByDate=false) { $files = glob($path.$regex.'.'.$extension); @@ -24,6 +24,10 @@ class Filesystem { return array(); } + if($sortByDate) { + usort($files, create_function('$a,$b', 'return filemtime($b) - filemtime($a);')); + } + return $files; } diff --git a/kernel/js/functions.php b/kernel/js/functions.php index 23cd40d0..cb6c5c67 100644 --- a/kernel/js/functions.php +++ b/kernel/js/functions.php @@ -5,6 +5,7 @@ echo ''; // Hack for Bludit @@ -85,11 +88,19 @@ class pluginsimpleMDE extends Plugin { toolbarGuideIcon: true, autofocus: false, lineWrapping: true, + autoDownloadFontAwesome: false, indentWithTabs: true, tabSize: '.$this->getDbField('tabSize').', spellChecker: false, toolbar: ['.Sanitize::htmlDecode($this->getDbField('toolbar')).'] - });'; + });'; + + $html .= '$("#jsaddImage").on("click", function() { + var filename = $("#jsimageList option:selected" ).text(); + var text = simplemde.value(); + simplemde.value(text + "![alt text]("+filename+")" + "\n"); + });'; + $html .= '}); '; } diff --git a/plugins/tags/languages/pl_PL.json b/plugins/tags/languages/pl_PL.json new file mode 100644 index 00000000..604d1c54 --- /dev/null +++ b/plugins/tags/languages/pl_PL.json @@ -0,0 +1,12 @@ +{ + "plugin-data": + { + "name": "Lista tagów", + "description": "Wyświetla wszystkie tagi w postaci listy.", + "author": "Bludit", + "email": "", + "website": "https://github.com/dignajar/bludit-plugins", + "version": "0.3", + "releaseDate": "2015-10-02" + } +} \ No newline at end of file