From 59c247809d87cf5cf1664d4b61b9d73b7d9b5edd Mon Sep 17 00:00:00 2001 From: Diego Najar Date: Thu, 7 May 2015 01:00:01 +0000 Subject: [PATCH] New features --- .gitignore | 1 + index.php | 2 + install.php | 93 ++++++++++++++++++++++------------- kernel/helpers/text.class.php | 17 +++++-- kernel/login.class.php | 2 +- 5 files changed, 77 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index e43b0f98..0d0138c9 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .DS_Store +content/ diff --git a/index.php b/index.php index feea1bf4..5c196e97 100644 --- a/index.php +++ b/index.php @@ -13,6 +13,8 @@ define('PATH_BOOT', PATH_ROOT.'kernel/boot/'); // Init require(PATH_BOOT.'init.php'); + + // Admin area if($Url->whereAmI()==='admin') { diff --git a/install.php b/install.php index 14f30a39..b151e39c 100644 --- a/install.php +++ b/install.php @@ -18,7 +18,7 @@ define('PATH_PLUGINS_DATABASES', PATH_CONTENT.'databases/plugins/'); // 7=read,write,execute | 5=read,execute $dirpermissions = 0755; -if(mkdir(PATH_POSTS, $dirpermissions, true)) +if(mkdir(PATH_POSTS.'welcome', $dirpermissions, true)) { $errorText = 'Error when trying to created the directory=>'.PATH_POSTS; error_log($errorText, 0); @@ -45,39 +45,49 @@ $dataHead = "".PHP_EOL; // File pages.php $data = array( 'error'=>array( - "description"=>"Error page", - "username"=>"admin", - "tags"=>"", - "status"=>"published", - "unixTimeCreated"=>1430686755, - "unixTimeModified"=>0, - "position"=>0 + 'description'=>'Error page', + 'username'=>'admin', + 'tags'=>'', + 'status'=>'published', + 'unixTimeCreated'=>1430686755, + 'unixTimeModified'=>0, + 'position'=>0 ) ); file_put_contents(PATH_DATABASES.'pages.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX); // File posts.php -$data = array(); +$data = array( + 'welcome'=>array( + 'description'=>'Welcome to Bludit', + 'username'=>'admin', + 'status'=>'published', + 'tags'=>'welcome, bludit, cms', + 'allowComments'=>false, + 'unixTimeCreated'=>1430875199, + 'unixTimeModified'=>0 + ) +); file_put_contents(PATH_DATABASES.'posts.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX); // File site.php $data = array( - "title"=>"Bludit CMS", - "description"=>"", - "footer"=>"Footer text - 2015", - "language"=>"english", - "locale"=>"en_EN", - "timezone"=>"America/Argentina/Buenos_Aires", - "theme"=>"pure", - "adminTheme"=>"default", - "homepage"=>"", - "postsperpage"=>"6", - "uriPost"=>"/post/", - "uriPage"=>"/", - "uriTag"=>"/tag/", - "advancedOptions"=>"false", - "url"=>"http:/localhost/cms/bludit-bitbucket/" + 'title'=>'Bludit CMS', + 'description'=>'', + 'footer'=>'Footer text - 2015', + 'language'=>'english', + 'locale'=>'en_EN', + 'timezone'=>'America/Argentina/Buenos_Aires', + 'theme'=>'pure', + 'adminTheme'=>'default', + 'homepage'=>'', + 'postsperpage'=>'6', + 'uriPost'=>'/post/', + 'uriPage'=>'/', + 'uriTag'=>'/tag/', + 'advancedOptions'=>'false', + 'url'=>'http:/localhost/cms/bludit-bitbucket/' ); file_put_contents(PATH_DATABASES.'site.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX); @@ -85,21 +95,38 @@ file_put_contents(PATH_DATABASES.'site.php', $dataHead.json_encode($data, JSON_P // File users.php $data = array( 'admin'=>array( - "firstName"=>"", - "lastName"=>"", - "twitter"=>"", - "role"=>"admin", - "password"=>"7607d34033344d9a4615a8795d865ec4a47851e7", - "salt"=>"adr32t", - "email"=>"", - "registered"=>1430686755 + 'firstName'=>'', + 'lastName'=>'', + 'twitter'=>'', + 'role'=>'admin', + 'password'=>'7607d34033344d9a4615a8795d865ec4a47851e7', + 'salt'=>'adr32t', + 'email'=>'', + 'registered'=>1430686755 ) ); file_put_contents(PATH_DATABASES.'users.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX); // File index.txt for error page -$data = "Title: Error".PHP_EOL."Content: The page has not been found."; +$data = 'Title: Error +Content: The page has not been found.'; + file_put_contents(PATH_PAGES.'error/index.txt', $data, LOCK_EX); +// File index.txt for welcome post +$data = 'title: Welcome +Content: +Congrats you have installed Bludit! +=== + +What next: +- Administrate your Bludit from the Admin Area +- Follow Bludit on Twitter / Facebook / Google+ +- Visit the forum for support +- Read the documentation for more information +- Share with your friend :D'; + +file_put_contents(PATH_POSTS.'welcome/index.txt', $data, LOCK_EX); + ?> \ No newline at end of file diff --git a/kernel/helpers/text.class.php b/kernel/helpers/text.class.php index 68db4fa5..74116839 100644 --- a/kernel/helpers/text.class.php +++ b/kernel/helpers/text.class.php @@ -41,7 +41,7 @@ class helperText { { $accents_regex = '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i'; $special_cases = array( '&' => 'and'); - $string = mb_strtolower( trim( $string ), 'UTF-8' ); + $string = self::lowercase( trim( $string ), 'UTF-8' ); $string = str_replace( array_keys($special_cases), array_values( $special_cases), $string ); $string = preg_replace( $accents_regex, '$1', htmlentities( $string, ENT_QUOTES, 'UTF-8' ) ); $string = preg_replace("/[^a-z0-9]/u", "$separator", $string); @@ -74,9 +74,18 @@ class helperText { // Returns the portion of string specified by the start and length parameters. public static function cut($string, $start, $length) { - if(MB_STRING) - return mb_substr($string, $start, $length, 'UTF-8'); - return substr($string, $start, $length); + if(MB_STRING) { + $cut = mb_substr($string, $start, $length, 'UTF-8'); + } + else { + $cut = substr($string, $start, $length); + } + + if(empty($cut)) { + return ''; + } + + return $cut; } // Return string length diff --git a/kernel/login.class.php b/kernel/login.class.php index be94885f..571c1b2e 100644 --- a/kernel/login.class.php +++ b/kernel/login.class.php @@ -33,7 +33,7 @@ class Login { { $username = Session::get('username'); - return (!empty($username)) { + if(!empty($username)) { return true; } }