New features
This commit is contained in:
parent
59c247809d
commit
d8fc681b3c
|
@ -1,5 +1,14 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// ============================================================================
|
||||
// Check role
|
||||
// ============================================================================
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set('You do not have sufficient permissions to access this page, contact the administrator.');
|
||||
Redirect::page('admin', 'dashboard');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Functions
|
||||
// ============================================================================
|
||||
|
@ -45,3 +54,7 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
|||
Redirect::page('admin', 'users');
|
||||
}
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main
|
||||
// ============================================================================
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// ============================================================================
|
||||
// Functions
|
||||
// ============================================================================
|
||||
|
||||
function editUser($args)
|
||||
{
|
||||
global $dbUsers;
|
||||
|
@ -21,15 +25,38 @@ function editUser($args)
|
|||
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// POST Method
|
||||
// ============================================================================
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
|
||||
if($Login->role()!=='admin')
|
||||
{
|
||||
$_POST['username'] = $Login->username();
|
||||
unset($_POST['role']);
|
||||
}
|
||||
|
||||
if( editUser($_POST) ) {
|
||||
Alert::set('User saved successfuly.');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main
|
||||
// ============================================================================
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
$layout['parameters'] = $Login->username();
|
||||
}
|
||||
|
||||
$_user = $dbUsers->get($layout['parameters']);
|
||||
|
||||
// If the user doesn't exist, redirect to the users list.
|
||||
if($_user===false)
|
||||
if($_user===false) {
|
||||
Redirect::page('admin', 'users');
|
||||
}
|
||||
|
||||
$_user['username'] = $layout['parameters'];
|
|
@ -9,4 +9,8 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
|||
{
|
||||
Redirect::page('admin', 'dashboard');
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert::set('Login failed');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
if( $Login->logout())
|
||||
{
|
||||
Redirect::home();
|
||||
}
|
|
@ -1,5 +1,14 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// ============================================================================
|
||||
// Check role
|
||||
// ============================================================================
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set('You do not have sufficient permissions to access this page, contact the administrator.');
|
||||
Redirect::page('admin', 'dashboard');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Functions
|
||||
// ============================================================================
|
||||
|
@ -28,3 +37,7 @@ if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
|||
{
|
||||
setSettings($_POST);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main
|
||||
// ============================================================================
|
||||
|
|
|
@ -1,6 +1,23 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.');
|
||||
|
||||
// ============================================================================
|
||||
// Check role
|
||||
// ============================================================================
|
||||
|
||||
if($Login->role()!=='admin') {
|
||||
Alert::set('You do not have sufficient permissions to access this page, contact the administrator.');
|
||||
Redirect::page('admin', 'dashboard');
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// POST Method
|
||||
// ============================================================================
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
$Site->set($_POST);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// Main
|
||||
// ============================================================================
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
a {
|
||||
text-decoration: none;
|
||||
color: #333;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #2672ec !important;
|
||||
text-decoration: none !important;
|
||||
}
|
||||
|
||||
/* ----------- FONTS AWESOME ----------- */
|
||||
.fa-right {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
/* ----------- ----------- */
|
||||
div.main {
|
||||
text-align: center;
|
||||
margin: 30px 0;
|
||||
}
|
||||
h1.title {
|
||||
font-weight: lighter;
|
||||
font-size: 4em;
|
||||
}
|
||||
|
|
@ -22,7 +22,7 @@
|
|||
<script>
|
||||
$(document).ready(function() {
|
||||
<?php
|
||||
if( !Alert::displayed() ) {
|
||||
if( Alert::defined() ) {
|
||||
echo '$("#alert").message();';
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Your page title</title>
|
||||
<title>Bludit Login</title>
|
||||
|
||||
<link rel="stylesheet" href="./css/kube.min.css">
|
||||
<link rel="stylesheet" href="./css/default.css">
|
||||
|
@ -19,7 +19,7 @@
|
|||
<nav class="navbar nav-fullwidth">
|
||||
<h1>Bludit</h1>
|
||||
<ul>
|
||||
<li><a href="#">Home</a></li>
|
||||
<li><a href="<?php echo HTML_PATH_ROOT ?>">Home</a></li>
|
||||
</ul>
|
||||
</nav>
|
||||
</div>
|
||||
|
@ -27,17 +27,19 @@
|
|||
<div class="units-row">
|
||||
|
||||
<!-- CONTENT -->
|
||||
<div class="unit-centered unit-40">
|
||||
<div class="unit-centered unit-40" style="max-width: 500px">
|
||||
<div id="content">
|
||||
|
||||
<div class="tools-alert">
|
||||
Bender! Ship! Stop bickering or I'm going to come back there and change your opinions manually! Take me to your leader!
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
if(Alert::defined()) {
|
||||
echo '<div class="tools-alert">'.Alert::get().'</div>';
|
||||
}
|
||||
|
||||
// Load view
|
||||
if( Sanitize::pathFile(PATH_ADMIN_VIEWS, $layout['view'].'.php') )
|
||||
if( Sanitize::pathFile(PATH_ADMIN_VIEWS, $layout['view'].'.php') ) {
|
||||
include(PATH_ADMIN_VIEWS.$layout['view'].'.php');
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
|
|
|
@ -24,13 +24,13 @@
|
|||
<option value="editor">Editor</option>
|
||||
<option value="admin">Administrator</option>
|
||||
</select>
|
||||
<div class="forms-desc">Where you from?</div>
|
||||
<div class="forms-desc">Small and concise description of the field ???</div>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Email
|
||||
<input type="text" name="email" class="width-50">
|
||||
<div class="forms-desc">Email will not be publicly displayed.</div>
|
||||
<div class="forms-desc">Email will not be publicly displayed. Recommended for recovery password and notifications.</div>
|
||||
</label>
|
||||
|
||||
<input type="submit" class="btn btn-blue" value="Add" name="add-user">
|
||||
|
|
|
@ -26,7 +26,11 @@
|
|||
<input type="text" name="lastName" class="width-50" value="<?php echo $_user['lastName'] ?>">
|
||||
</label>
|
||||
|
||||
<label for="country">
|
||||
<?php
|
||||
if($Login->username()==='admin')
|
||||
{
|
||||
?>
|
||||
<label for="role">
|
||||
Role
|
||||
<select name="role" class="width-50">
|
||||
<?php
|
||||
|
@ -36,8 +40,11 @@
|
|||
}
|
||||
?>
|
||||
</select>
|
||||
<div class="forms-desc">Small and concise description of the field ???</div>
|
||||
</label>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<input type="submit" class="btn btn-blue" value="Save" name="user-profile">
|
||||
<a href="<?php echo HTML_PATH_ADMIN_ROOT.'users' ?>" class="btn">Cancel</a>
|
||||
</form>
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<h2 class="title">Login</h2>
|
||||
|
||||
<form method="post" action="<?php echo HTML_PATH_ADMIN_ROOT.'login' ?>" class="forms" autocomplete="">
|
||||
<form method="post" action="<?php echo HTML_PATH_ADMIN_ROOT.'login' ?>" class="forms" autocomplete="off">
|
||||
<label>
|
||||
<input type="text" name="username" placeholder="Username" class="width-100">
|
||||
<input type="text" name="username" placeholder="Username" class="width-100" autocomplete="off">
|
||||
</label>
|
||||
<label>
|
||||
<input type="password" name="password" placeholder="Password" class="width-100">
|
||||
<input type="password" name="password" placeholder="Password" class="width-100" autocomplete="off">
|
||||
</label>
|
||||
<p>
|
||||
<button class="btn btn-blue width-100">Log in</button>
|
||||
|
|
|
@ -24,7 +24,7 @@
|
|||
}
|
||||
|
||||
echo '<tr>';
|
||||
echo '<td>'.($Page->parentKey()?NO_PARENT_CHAR:'').'<a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.(empty($Page->published())?'[DRAFT] ':'').$Page->title().'</a></td>';
|
||||
echo '<td>'.($Page->parentKey()?NO_PARENT_CHAR:'').'<a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.($Page->published()?'':'[DRAFT] ').$Page->title().'</a></td>';
|
||||
echo '<td>'.$parentTitle.'</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
foreach($posts as $Post)
|
||||
{
|
||||
echo '<tr>';
|
||||
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-post/'.$Post->key().'">'.(empty($Post->published())?'[DRAFT] ':'').(empty($Post->title())?'[Empty title] ':$Post->title()).'</a></td>';
|
||||
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-post/'.$Post->key().'">'.($Post->published()?'':'[DRAFT] ').($Post->title()?$Post->title():'[Empty title] ').'</a></td>';
|
||||
echo '<td>'.$Post->date().'</td>';
|
||||
echo '<td>'.$Post->timeago().'</td>';
|
||||
echo '</tr>';
|
||||
|
|
|
@ -18,16 +18,19 @@
|
|||
<label>
|
||||
Site title
|
||||
<input type="text" name="title" class="width-50" value="<?php echo $Site->title() ?>">
|
||||
<div class="forms-desc">Small and concise description of the field ???</div>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Site description
|
||||
<input type="text" name="description" class="width-50" value="<?php echo $Site->description() ?>">
|
||||
<div class="forms-desc">Small and concise description of the field ???</div>
|
||||
</label>
|
||||
|
||||
<label>
|
||||
Footer text
|
||||
<input type="text" name="footer" class="width-50" value="<?php echo $Site->footer() ?>">
|
||||
<div class="forms-desc">Small and concise description of the field ???</div>
|
||||
</label>
|
||||
|
||||
<input type="submit" class="btn" value="Save" name="form-general">
|
||||
|
@ -56,6 +59,7 @@
|
|||
<label>
|
||||
Site URL
|
||||
<input type="text" name="url" class="width-50" value="<?php echo $Site->url() ?>">
|
||||
<div class="forms-desc">Small and concise description of the field ???</div>
|
||||
</label>
|
||||
|
||||
<h4>Writting Settings</h4>
|
||||
|
@ -103,19 +107,24 @@
|
|||
Language
|
||||
<select name="language" class="width-50">
|
||||
<?php
|
||||
$htmlOptions = array('English'=>'english', 'Español'=>'espanol');
|
||||
$htmlOptions = array('English'=>'english');
|
||||
foreach($htmlOptions as $text=>$value) {
|
||||
echo '<option value="'.$value.'"'.( ($Site->language()===$value)?' selected="selected"':'').'>'.$text.'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<div class="forms-desc">Select a language for your site.</div>
|
||||
<div class="forms-desc">Small and concise description of the field ???</div>
|
||||
</label>
|
||||
|
||||
<label for="timezone">
|
||||
Timezone
|
||||
<select name="timezone" class="width-50">
|
||||
<option value="America/Argentina/Buenos_Aires">America/Argentina/Buenos_Aires</option>
|
||||
<?php
|
||||
$htmlOptions = Date::timezoneList();
|
||||
foreach($htmlOptions as $text=>$value) {
|
||||
echo '<option value="'.$value.'"'.( ($Site->timezone()===$value)?' selected="selected"':'').'>'.$text.'</option>';
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<div class="forms-desc">Select a timezone for a correct date/time display on your site.</div>
|
||||
</label>
|
||||
|
@ -123,6 +132,7 @@
|
|||
<label>
|
||||
Locale
|
||||
<input type="text" name="locale" class="width-50" value="<?php echo $Site->locale() ?>">
|
||||
<div class="forms-desc">Small and concise description of the field ???</div>
|
||||
</label>
|
||||
|
||||
<input type="submit" class="btn" value="Save" name="form-regional">
|
||||
|
@ -135,5 +145,5 @@
|
|||
<!-- ===================================== -->
|
||||
|
||||
<div id="about">
|
||||
<p><i class="fa fa-pencil-square-o"></i> Bludit version 0.1</p>
|
||||
<p><i class="fa fa-pencil-square-o"></i> Bludit version <?php echo BLUDIT_VERSION.' ('.BLUDIT_RELEASE_DATE.')' ?></p>
|
||||
</div>
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.'); ?>
|
||||
{
|
||||
"error": {
|
||||
"description": "Error page",
|
||||
"username": "admin",
|
||||
"tags": "",
|
||||
"status": "published",
|
||||
"unixTimeCreated": 1430686755,
|
||||
"unixTimeModified": 0,
|
||||
"position": 0
|
||||
}
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.'); ?>
|
||||
{
|
||||
"title": "",
|
||||
"description": ""
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.'); ?>
|
||||
[]
|
|
@ -1,18 +0,0 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.'); ?>
|
||||
{
|
||||
"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\/"
|
||||
}
|
|
@ -1,13 +0,0 @@
|
|||
<?php defined('BLUDIT') or die('Bludit CMS.'); ?>
|
||||
{
|
||||
"admin": {
|
||||
"firstName": "",
|
||||
"lastName": "",
|
||||
"twitter": "",
|
||||
"role": "admin",
|
||||
"password": "7607d34033344d9a4615a8795d865ec4a47851e7",
|
||||
"salt": "adr32t",
|
||||
"email": "",
|
||||
"registered": 1430686755
|
||||
}
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
title: How to make a new page
|
||||
content:
|
||||
## Advance mode
|
||||
You can make new page editing the filesystem.
|
||||
- Create a directory on /content/pages/
|
||||
- The directory name is the uri for the new page
|
||||
- Create a new file called index.txt inside of the new directory
|
||||
- Edit the file index.txt
|
||||
- Add two variables, Tite: and Content:
|
||||
|
||||
### Example
|
||||
- Create the directory /content/pages/test
|
||||
- Create the file index.txt on /content/pages/test/index.txt
|
||||
- Edit the file index.txt
|
||||
- Add the variables
|
||||
```
|
||||
Title: My new page
|
||||
Content:
|
||||
This is an example of a new page, hello world!
|
||||
```
|
|
@ -1,34 +0,0 @@
|
|||
title: How to make post
|
||||
content:
|
||||
There are two method to make a post. The easy mode with graphic interfaces and the advanced mode, if you choose the second option check the [variables for posts and pages](../../content/variables-for-posts-and-pages).
|
||||
|
||||
---
|
||||
|
||||
## Easy mode
|
||||
Admin area / GUI.
|
||||
|
||||
---
|
||||
|
||||
## Advanced mode
|
||||
You can make new post editing the filesystem.
|
||||
- Create a directory on `/content/posts/`
|
||||
- The directory name is the uri for the new post
|
||||
- Create a new file called `index.txt` inside of the new directory
|
||||
- Edit the file `index.txt`
|
||||
- Add two variables, Tite: and Content:
|
||||
|
||||
### Example
|
||||
- Create the directory `/content/posts/test`
|
||||
- Create the file `index.txt` on `/content/posts/test/index.txt`
|
||||
- Edit the file `index.txt`
|
||||
- Add the variables
|
||||
|
||||
```
|
||||
Title: New post test
|
||||
|
||||
Content:
|
||||
Hello Lorem
|
||||
It is a long establishedfact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
|
||||
|
||||
It is a long establishedfact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
|
||||
```
|
|
@ -1,31 +0,0 @@
|
|||
title: Variables for posts and pages
|
||||
content:
|
||||
|
||||
There are many fields/variables to make a post or a page. Each field ends on two dots(:).
|
||||
|
||||
The last field needs to be Content:.
|
||||
|
||||
- Title: the title for the post/page.
|
||||
- Status: with this field you can change bettewen published and draft.
|
||||
- Unixstamp: you can define the publish time/date in unix time stamp, this need to be in UTC-0/GMT.
|
||||
- Username: the owner username. Needs to be a valid username.
|
||||
- Author: the author's name.
|
||||
- Content: the content for the post/page, support HTML and Markdown code.
|
||||
|
||||
### Post example
|
||||
```
|
||||
Title: New post test
|
||||
Status: published
|
||||
Unixstamp: 1425340270
|
||||
Username: diego
|
||||
Author: Diego Najar
|
||||
Content:
|
||||
# HTML and Markdown code support
|
||||
|
||||
## Some Markdown code
|
||||
**Black Lorem** Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
|
||||
|
||||
## Some HTML code
|
||||
<strong>It is a long established</strong> fact that a reader will be distracted by the readable content of a page when looking at its layout. The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using 'Content here, content here', making it look like readable English. Many desktop publishing packages and web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).
|
||||
|
||||
```
|
|
@ -1,2 +0,0 @@
|
|||
Title: Error
|
||||
Content: The page has not been found.
|
|
@ -1,43 +0,0 @@
|
|||
Title: Installation guide
|
||||
Content:
|
||||
You only need upload the files to the server.
|
||||
|
||||
1. Download the latest version from http://www.bludit.com
|
||||
2. Extract the zip file into a directory like `bludit`.
|
||||
3. Upload the directory `bludit` on your hosting.
|
||||
4. Done!
|
||||
|
||||
---
|
||||
|
||||
## Installation on GNU/Linux
|
||||
If you have a local webserver with GNU/Linux or you have a Hosting with SSH enabled, you can install with this simples commands.
|
||||
|
||||
```
|
||||
$ wget http://www.bludit.com/bludit_latest.zip
|
||||
$ unzip bludit_latest.zip
|
||||
$ mv bludit /WEBSERVER_DIRECTORY/
|
||||
```
|
||||
|
||||
If you don’t have the command wget, you can try with the command curl.
|
||||
```
|
||||
$ curl --remote-name http://www.bludit.com/bludit_latest.zip
|
||||
```
|
||||
|
||||
I recommend you check which user are running your webserver, because you need to set read/write permissions to the directory `content`. For example if you are running Apache you can do this:
|
||||
```
|
||||
$ sudo ps axo user | egrep '(apache|httpd)' | uniq
|
||||
```
|
||||
|
||||
Now you can set the username to the directory `content`. And fix some permissions to the files and directories.
|
||||
```
|
||||
$ cd /WEBSERVER_DIRECTORY/bludit
|
||||
$ sudo chown -R USERNAME:USERNAME content
|
||||
$ sudo find . -type f | xargs chmod 664
|
||||
$ sudo find . -type d | xargs chmod 775
|
||||
```
|
||||
|
||||
Other way, but I don’t recommend it, is setting the permissions for all read/write/execute (777).
|
||||
```
|
||||
$ cd /WEBSERVER_DIRECTORY/bludit
|
||||
$ sudo find content -type d | xargs chmod 777
|
||||
```
|
|
@ -1,9 +0,0 @@
|
|||
Title: Requirements
|
||||
Content:
|
||||
You only need a Webserver with PHP support.
|
||||
|
||||
- PHP 5.3 or higher.
|
||||
- PHP module [mbstring](http://php.net/manual/en/book.mbstring.php) for full UTF-8 support.
|
||||
- Webserver:
|
||||
* Apache with module [mod_rewrite](http://httpd.apache.org/docs/current/mod/mod_rewrite.html)
|
||||
* Ngnix with module [ngx_http_rewrite_module](http://nginx.org/en/docs/http/ngx_http_rewrite_module.html)
|
|
@ -1,27 +0,0 @@
|
|||
Title: Homepage
|
||||
Content:
|
||||
|
||||
Getting started
|
||||
- [Requirements](../../getting-started/requirements)
|
||||
- [Installation guide](../../getting-started/installation-guide)
|
||||
- [Update guide](../../)
|
||||
- [Backup guide](../../)
|
||||
|
||||
Content
|
||||
- [How to make a post](../../content/how-to-make-a-post)
|
||||
- [How to make a page](../../content/how-to-make-a-page)
|
||||
|
||||
Themes
|
||||
- [Making a basic theme](./content/how-to-make-a-post)
|
||||
- [Constants and Variables](./content/how-to-make-a-post)
|
||||
- [Objects for themes](./content/how-to-make-a-post)
|
||||
|
||||
Plugins
|
||||
- [Making a basic theme](./content/how-to-make-a-post)
|
||||
- [Constants and Variables](./content/how-to-make-a-post)
|
||||
- [Objects for themes](./content/how-to-make-a-post)
|
||||
|
||||
General
|
||||
- [Databases](./content/how-to-make-a-post)
|
||||
- [Filesystem and structure](./content/how-to-make-a-post)
|
||||
- [Troubleshooting](../../troubleshooting)
|
|
@ -1,83 +0,0 @@
|
|||
Title: Theme variables
|
||||
|
||||
Content:
|
||||
|
||||
## $pages arrays
|
||||
This array cotains all pages published. Each item from the array is a `Page Object`
|
||||
|
||||
---
|
||||
|
||||
## Array $posts
|
||||
|
||||
---
|
||||
|
||||
## Site object
|
||||
The object Site have all the information from the database /content/databases/site.php.
|
||||
|
||||
By default there is an object $Site, whith the next methods.
|
||||
|
||||
Print the site title
|
||||
<pre><code data-language="php">echo $Site->title();</code></pre>
|
||||
|
||||
Print the site slogan
|
||||
<pre><code data-language="php">echo $Site->slogan();</code></pre>
|
||||
|
||||
---
|
||||
|
||||
## Page object
|
||||
|
||||
By default if the user filter by a particular page there will be an object $Page. To check if the user is filtering by a page you can uses the object $Url and the method `whereAmI()`.
|
||||
<pre><code data-language="php">if( $Url->whereAmI()==='page' )
|
||||
{
|
||||
echo 'The page filtered is '.$Page->title();
|
||||
}
|
||||
{
|
||||
echo 'The user is not watching a particular page';
|
||||
}
|
||||
</code></pre>
|
||||
|
||||
And here there are the methods for the object $Page.
|
||||
|
||||
Print the page title
|
||||
<pre><code data-language="php">echo $Page->title();</code></pre>
|
||||
|
||||
Print the page content
|
||||
<pre><code data-language="php">echo $Page->content();</code></pre>
|
||||
|
||||
Print the page username
|
||||
<pre><code data-language="php">echo $Page->username();</code></pre>
|
||||
|
||||
Get the date in unix timestamp
|
||||
<pre><code data-language="php">$time = $Page->unixstamp();
|
||||
|
||||
// Format time
|
||||
echo date('Y-m-d', $time);
|
||||
</code></pre>
|
||||
|
||||
Print the page date, according to locale settings and format settings.
|
||||
<pre><code data-language="php">echo $Page->date();</code></pre>
|
||||
|
||||
Print the page date with a different format.
|
||||
<pre><code data-language="php">$format = 'Y-m-d';
|
||||
|
||||
echo $Page->date($format);
|
||||
</code></pre>
|
||||
|
||||
Time ago
|
||||
<pre><code data-language="php">echo $Page->timeago();</code></pre>
|
||||
|
||||
Get the slug url.
|
||||
<pre><code data-language="php">$slug = $Page->slug();</code></pre>
|
||||
|
||||
Get the page permalink.
|
||||
<pre><code data-language="php">$permalink = $Page->permalink();</code></pre>
|
||||
|
||||
Get the page status, this method returns TRUE if the page is published, FALSE otherwise.
|
||||
<pre><code data-language="php">if( $Page->published() )
|
||||
{
|
||||
echo 'Page published';
|
||||
}
|
||||
else
|
||||
{
|
||||
echo 'Page draft';
|
||||
}</code></pre>
|
|
@ -1,16 +0,0 @@
|
|||
Title: Troubleshooting
|
||||
Content:
|
||||
|
||||
### Setup permissions
|
||||
Nibbleblog uses as database flat files, they are stored in the “content” directory which needs permissions to write by the webserver. Nibbleblog try to assign these permissions automatically, but if it fails in the process will alert the user to make the changes manually.
|
||||
|
||||
#### Change permissions with Filezilla and FTP
|
||||
1. Connect to the server via ftp.
|
||||
2. Right click on content directory.
|
||||
3. Select file permissions.
|
||||
4. Set the number 755 if dosen't work try with the number 777.
|
||||
|
||||
#### Change permissions from GNU/Linux terminal
|
||||
```
|
||||
$ chmod -R 777 content
|
||||
```
|
|
@ -1,12 +0,0 @@
|
|||
Title: Lorem text
|
||||
Username: admin
|
||||
Content:
|
||||
This is an interactive demo of Parsedown.
|
||||
|
||||
Here's how it works:
|
||||
|
||||
1. Type some Markdown text on the left
|
||||
2. Hit *Parse*
|
||||
3. See your text parsed to on the right
|
||||
|
||||
Tip: when scrolling hold `⇧` to sync scroll position.
|
|
@ -1,7 +0,0 @@
|
|||
Title: Lorem titulo
|
||||
Content:
|
||||
## Subtitle 1
|
||||
Faucibus sed lobortis aliquam lorem blandit. Lorem eu nunc metus col. Commodo id in arcu ante lorem ipsum sed accumsan erat praesent faucibus commodo ac mi lacus. Adipiscing mi ac commodo. Vis aliquet tortor ultricies non ante erat nunc integer eu ante ornare amet commetus vestibulum blandit integer in curae ac faucibus integer non. Adipiscing cubilia elementum.
|
||||
|
||||
## Subtitle 2
|
||||
Faucibus sed lobortis aliquam lorem blandit. Lorem eu nunc metus col. Commodo id in arcu ante lorem ipsum sed accumsan erat praesent faucibus commodo ac mi lacus. Adipiscing mi ac commodo. Vis aliquet tortor ultricies non ante erat nunc integer eu ante ornare amet commetus vestibulum blandit integer in curae ac faucibus integer non. Adipiscing cubilia elementum.
|
|
@ -1,6 +0,0 @@
|
|||
Title: Lorem China Clone指出
|
||||
|
||||
Content:
|
||||
Faucibus sed lobortis aliquam lorem blandit. Lorem eu nunc metus col. Commodo id in arcu ante lorem ipsum sed accumsan erat praesent faucibus commodo ac mi lacus. Adipiscing mi ac commodo. Vis aliquet tortor ultricies non ante erat nunc integer eu ante ornare amet commetus vestibulum blandit integer in curae ac faucibus integer non. Adipiscing cubilia elementum.
|
||||
|
||||
Faucibus sed lobortis aliquam lorem blandit. Lorem eu nunc metus col. Commodo id in arcu ante lorem ipsum sed accumsan erat praesent faucibus commodo ac mi lacus. Adipiscing mi ac commodo. Vis aliquet tortor ultricies non ante erat nunc integer eu ante ornare amet commetus vestibulum blandit integer in curae ac faucibus integer non. Adipiscing cubilia elementum.
|
14
index.php
14
index.php
|
@ -1,5 +1,19 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
* Bludit
|
||||
* http://www.bludit.com
|
||||
* Author Diego Najar
|
||||
* All Bludit code is released under the GNU General Public License.
|
||||
*/
|
||||
|
||||
// Check installation
|
||||
if( !file_exists('content/databases/site.php') )
|
||||
{
|
||||
header('Location:./install.php');
|
||||
exit('<a href="./install.php">First, install Bludit</a>');
|
||||
}
|
||||
|
||||
// DEBUG:
|
||||
$loadTime = microtime(true);
|
||||
|
||||
|
|
225
install.php
225
install.php
|
@ -9,36 +9,107 @@ define('PATH_POSTS', PATH_CONTENT.'posts/');
|
|||
define('PATH_PAGES', PATH_CONTENT.'pages/');
|
||||
define('PATH_DATABASES', PATH_CONTENT.'databases/');
|
||||
define('PATH_PLUGINS_DATABASES', PATH_CONTENT.'databases/plugins/');
|
||||
define('DOMAIN', getenv('HTTP_HOST'));
|
||||
|
||||
$base = (dirname(getenv('SCRIPT_NAME'))=='/')?'/':dirname(getenv('SCRIPT_NAME')).'/';
|
||||
define('HTML_PATH_ROOT', $base);
|
||||
|
||||
//
|
||||
if(!defined('JSON_PRETTY_PRINT')) {
|
||||
define('JSON_PRETTY_PRINT', 128);
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// FUNCTIONS
|
||||
// ============================================================================
|
||||
|
||||
// Generate a random string
|
||||
// Thanks, http://stackoverflow.com/questions/4356289/php-random-string-generator
|
||||
function getRandomString($length = 10) {
|
||||
return substr(str_shuffle("0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"), 0, $length);
|
||||
}
|
||||
|
||||
function alreadyInstalled()
|
||||
{
|
||||
return file_exists(PATH_DATABASES.'site.php');
|
||||
}
|
||||
|
||||
function checkSystem()
|
||||
{
|
||||
$stdOut = array();
|
||||
$dirpermissions = 0755;
|
||||
$phpModules = array();
|
||||
|
||||
if(function_exists('get_loaded_extensions'))
|
||||
{
|
||||
$phpModules = get_loaded_extensions();
|
||||
}
|
||||
|
||||
if(!version_compare(phpversion(), '5.2', '>'))
|
||||
{
|
||||
$errorText = 'Current PHP version '.phpversion().', but you need > 5.3';
|
||||
error_log($errorText, 0);
|
||||
array_push($stdOut, $errorText);
|
||||
}
|
||||
|
||||
if(!in_array('dom', $phpModules))
|
||||
{
|
||||
$errorText = 'PHP module DOM does not exist';
|
||||
error_log($errorText, 0);
|
||||
array_push($stdOut, $errorText);
|
||||
}
|
||||
|
||||
if(!in_array('json', $phpModules))
|
||||
{
|
||||
$errorText = 'PHP module JSON does not exist';
|
||||
error_log($errorText, 0);
|
||||
array_push($stdOut, $errorText);
|
||||
}
|
||||
|
||||
if(!@mkdir(PATH_POSTS, $dirpermissions, false))
|
||||
{
|
||||
$errorText = 'Writing test on content directory failed';
|
||||
error_log($errorText, 0);
|
||||
array_push($stdOut, $errorText);
|
||||
}
|
||||
|
||||
@rmdir(PATH_POSTS);
|
||||
|
||||
return $stdOut;
|
||||
}
|
||||
|
||||
function install($adminPassword, $email)
|
||||
{
|
||||
$stdOut = array();
|
||||
|
||||
// ============================================================================
|
||||
// Create directories
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
// 7=read,write,execute | 5=read,execute
|
||||
$dirpermissions = 0755;
|
||||
$firstPostSlug = 'first-post';
|
||||
|
||||
if(mkdir(PATH_POSTS.'welcome', $dirpermissions, true))
|
||||
if(!mkdir(PATH_POSTS.$firstPostSlug, $dirpermissions, true))
|
||||
{
|
||||
$errorText = 'Error when trying to created the directory=>'.PATH_POSTS;
|
||||
$errorText = 'Error when trying to created the directory=>'.PATH_POSTS.$firstPostSlug;
|
||||
error_log($errorText, 0);
|
||||
}
|
||||
|
||||
if(mkdir(PATH_PAGES.'error', $dirpermissions, true))
|
||||
if(!mkdir(PATH_PAGES.'error', $dirpermissions, true))
|
||||
{
|
||||
$errorText = 'Error when trying to created the directory=>'.PATH_PAGES;
|
||||
$errorText = 'Error when trying to created the directory=>'.PATH_PAGES.'error';
|
||||
error_log($errorText, 0);
|
||||
}
|
||||
|
||||
if(mkdir(PATH_PLUGINS_DATABASES, $dirpermissions, true))
|
||||
if(!mkdir(PATH_PLUGINS_DATABASES, $dirpermissions, true))
|
||||
{
|
||||
$errorText = 'Error when trying to created the directory=>'.PATH_PLUGINS_DATABASES;
|
||||
error_log($errorText, 0);
|
||||
}
|
||||
|
||||
//
|
||||
// ============================================================================
|
||||
// Create files
|
||||
//
|
||||
// ============================================================================
|
||||
|
||||
$dataHead = "<?php defined('BLUDIT') or die('Bludit CMS.'); ?>".PHP_EOL;
|
||||
|
||||
|
@ -59,7 +130,7 @@ file_put_contents(PATH_DATABASES.'pages.php', $dataHead.json_encode($data, JSON_
|
|||
|
||||
// File posts.php
|
||||
$data = array(
|
||||
'welcome'=>array(
|
||||
$firstPostSlug=>array(
|
||||
'description'=>'Welcome to Bludit',
|
||||
'username'=>'admin',
|
||||
'status'=>'published',
|
||||
|
@ -75,10 +146,10 @@ file_put_contents(PATH_DATABASES.'posts.php', $dataHead.json_encode($data, JSON_
|
|||
$data = array(
|
||||
'title'=>'Bludit CMS',
|
||||
'description'=>'',
|
||||
'footer'=>'Footer text - 2015',
|
||||
'footer'=>'Footer text - ©2015',
|
||||
'language'=>'english',
|
||||
'locale'=>'en_EN',
|
||||
'timezone'=>'America/Argentina/Buenos_Aires',
|
||||
'timezone'=>'UTC',
|
||||
'theme'=>'pure',
|
||||
'adminTheme'=>'default',
|
||||
'homepage'=>'',
|
||||
|
@ -87,11 +158,15 @@ $data = array(
|
|||
'uriPage'=>'/',
|
||||
'uriTag'=>'/tag/',
|
||||
'advancedOptions'=>'false',
|
||||
'url'=>'http:/localhost/cms/bludit-bitbucket/'
|
||||
'url'=>'http://'.DOMAIN.HTML_PATH_ROOT
|
||||
);
|
||||
|
||||
file_put_contents(PATH_DATABASES.'site.php', $dataHead.json_encode($data, JSON_PRETTY_PRINT), LOCK_EX);
|
||||
|
||||
$salt = getRandomString();
|
||||
$passwordHash = sha1($adminPassword.$salt);
|
||||
$registered = time();
|
||||
|
||||
// File users.php
|
||||
$data = array(
|
||||
'admin'=>array(
|
||||
|
@ -99,10 +174,10 @@ $data = array(
|
|||
'lastName'=>'',
|
||||
'twitter'=>'',
|
||||
'role'=>'admin',
|
||||
'password'=>'7607d34033344d9a4615a8795d865ec4a47851e7',
|
||||
'salt'=>'adr32t',
|
||||
'email'=>'',
|
||||
'registered'=>1430686755
|
||||
'password'=>$passwordHash,
|
||||
'salt'=>$salt,
|
||||
'email'=>$email,
|
||||
'registered'=>$registered
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -115,18 +190,120 @@ 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
|
||||
$data = 'title: First post
|
||||
Content:
|
||||
Congrats you have installed Bludit!
|
||||
===
|
||||
|
||||
What next:
|
||||
- Administrate your Bludit from the Admin Area
|
||||
- Follow Bludit on Twitter / Facebook / Google+
|
||||
Congratulations, you have installed **Bludit** successfully!
|
||||
---
|
||||
|
||||
What\'s next:
|
||||
---
|
||||
- Administrate your Bludit from the [Admin Area](./admin/)
|
||||
- Follow Bludit on [Twitter](https://twitter.com/bludit) / 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);
|
||||
file_put_contents(PATH_POSTS.$firstPostSlug.'/index.txt', $data, LOCK_EX);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// ============================================================================
|
||||
// MAIN
|
||||
// ============================================================================
|
||||
|
||||
if( alreadyInstalled() )
|
||||
{
|
||||
exit('Bludit already installed');
|
||||
}
|
||||
|
||||
if( $_SERVER['REQUEST_METHOD'] == 'POST' )
|
||||
{
|
||||
if(install($_POST['password'],$_POST['email']))
|
||||
{
|
||||
if(!headers_sent())
|
||||
{
|
||||
header("Location:".HTML_PATH_ROOT, TRUE, 302);
|
||||
exit;
|
||||
}
|
||||
|
||||
exit('<meta http-equiv="refresh" content="0; url="'.HTML_PATH_ROOT.'" />');
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!doctype html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<base href="admin/themes/default/">
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Bludit Installer</title>
|
||||
|
||||
<link rel="stylesheet" href="./css/kube.min.css">
|
||||
<link rel="stylesheet" href="./css/installer.css">
|
||||
|
||||
<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">
|
||||
<h1 class="title">Bludit Installer</h1>
|
||||
<p>Welcome to the Bludit installer</p>
|
||||
|
||||
<?php
|
||||
$system = checkSystem();
|
||||
|
||||
if(empty($system))
|
||||
{
|
||||
?>
|
||||
|
||||
<p>Complete the form, choose a password for the username <strong>admin</strong></p>
|
||||
<div class="unit-centered unit-40">
|
||||
<form method="post" action="" class="forms" autocomplete="off">
|
||||
|
||||
<label>
|
||||
<input type="text" value="admin" disabled="disabled" class="width-100">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="password" name="password" placeholder="Password" class="width-100" autocomplete="off">
|
||||
</label>
|
||||
|
||||
<label>
|
||||
<input type="text" name="email" placeholder="Email" class="width-100" autocomplete="off">
|
||||
</label>
|
||||
|
||||
<p>
|
||||
<button class="btn btn-blue width-100">Install</button>
|
||||
</p>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
else
|
||||
{
|
||||
echo '<div class="unit-centered unit-40">';
|
||||
echo '<table class="table-stripped">';
|
||||
|
||||
foreach ($system as $value)
|
||||
{
|
||||
echo '<tr><td>'.$value.'</td></tr>';
|
||||
}
|
||||
|
||||
echo '</table>';
|
||||
echo '</div';
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -14,6 +14,15 @@ $layout['controller'] = $layout['view'] = $layout['slug'] = $explodeSlug[0];
|
|||
unset($explodeSlug[0]);
|
||||
$layout['parameters'] = implode('/', $explodeSlug);
|
||||
|
||||
// Disable Magic Quotes
|
||||
// Thanks, http://stackoverflow.com/questions/517008/how-to-turn-off-magic-quotes-on-shared-hosting
|
||||
if ( in_array( strtolower( ini_get( 'magic_quotes_gpc' ) ), array( '1', 'on' ) ) )
|
||||
{
|
||||
$_POST = array_map('stripslashes', $_POST);
|
||||
$_GET = array_map('stripslashes', $_GET);
|
||||
$_COOKIE = array_map('stripslashes', $_COOKIE);
|
||||
}
|
||||
|
||||
// AJAX
|
||||
if( $Login->isLogged() && ($layout['slug']==='ajax') )
|
||||
{
|
||||
|
|
|
@ -26,6 +26,19 @@ define('PATH_ADMIN_VIEWS', PATH_ROOT.'admin/views/');
|
|||
// Log separator
|
||||
define('LOG_SEP', ' | ');
|
||||
|
||||
// JSON pretty print
|
||||
if(!defined('JSON_PRETTY_PRINT')) {
|
||||
define('JSON_PRETTY_PRINT', 128);
|
||||
}
|
||||
|
||||
// Salt length
|
||||
define('SALT_LENGTH', 8);
|
||||
|
||||
// Bludit version
|
||||
define('BLUDIT_VERSION', '0.1 beta1');
|
||||
define('BLUDIT_CODENAME', '');
|
||||
define('BLUDIT_RELEASE_DATE', '2015-05-13');
|
||||
|
||||
//
|
||||
define('NO_PARENT_CHAR', '—');
|
||||
|
||||
|
@ -102,6 +115,8 @@ else {
|
|||
|
||||
define('HTML_PATH_THEMES', HTML_PATH_ROOT.'themes/');
|
||||
define('HTML_PATH_THEME', HTML_PATH_ROOT.'themes/'.$Site->theme().'/');
|
||||
define('HTML_PATH_THEME_CSS', HTML_PATH_THEME.'css/');
|
||||
define('HTML_PATH_THEME_JS', HTML_PATH_THEME.'js/');
|
||||
define('HTML_PATH_ADMIN_THEME', HTML_PATH_ROOT.'admin/themes/'.$Site->adminTheme().'/');
|
||||
define('HTML_PATH_ADMIN_ROOT', HTML_PATH_ROOT.'admin/');
|
||||
|
||||
|
|
|
@ -55,12 +55,18 @@ function buildPost($key)
|
|||
return $Post;
|
||||
}
|
||||
|
||||
function build_posts_per_page($draftPosts=false)
|
||||
function build_posts_per_page($pageNumber=0, $amount=5, $draftPosts=false)
|
||||
{
|
||||
global $dbPosts;
|
||||
global $posts;
|
||||
global $Url;
|
||||
|
||||
$list = $dbPosts->getPage(0, 5, $draftPosts);
|
||||
$list = $dbPosts->getPage($pageNumber, $amount, $draftPosts);
|
||||
|
||||
// There are not post for the pageNumber then NotFound page
|
||||
if(empty($list)) {
|
||||
$Url->setNotFound(true);
|
||||
}
|
||||
|
||||
foreach($list as $slug=>$db)
|
||||
{
|
||||
|
@ -98,10 +104,10 @@ else
|
|||
{
|
||||
if($Url->whereAmI()==='admin') {
|
||||
// Build post for admin area with drafts
|
||||
build_posts_per_page(true);
|
||||
build_posts_per_page($Url->pageNumber(), $Site->postsPerPage(), true);
|
||||
}
|
||||
else
|
||||
{
|
||||
build_posts_per_page();
|
||||
build_posts_per_page($Url->pageNumber(), $Site->postsPerPage(), false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,9 +6,9 @@ class dbUsers extends dbJSON
|
|||
'firstName'=> array('inFile'=>false, 'value'=>''),
|
||||
'lastName'=> array('inFile'=>false, 'value'=>''),
|
||||
'username'=> array('inFile'=>false, 'value'=>''),
|
||||
'role'=> array('inFile'=>false, 'value'=>''),
|
||||
'role'=> array('inFile'=>false, 'value'=>'editor'),
|
||||
'password'=> array('inFile'=>false, 'value'=>''),
|
||||
'salt'=> array('inFile'=>false, 'value'=>''),
|
||||
'salt'=> array('inFile'=>false, 'value'=>'!Pink Floyd!Welcome to the machine!'),
|
||||
'email'=> array('inFile'=>false, 'value'=>''),
|
||||
'registered'=> array('inFile'=>false, 'value'=>0)
|
||||
);
|
||||
|
@ -24,7 +24,6 @@ class dbUsers extends dbJSON
|
|||
if($this->userExists($username))
|
||||
{
|
||||
$user = $this->db[$username];
|
||||
$user['username'] = $username;
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
@ -45,25 +44,37 @@ class dbUsers extends dbJSON
|
|||
|
||||
public function set($args)
|
||||
{
|
||||
$username = Sanitize::html($args['username']);
|
||||
$dataForDb = array();
|
||||
|
||||
$user = $this->get($args['username']);
|
||||
|
||||
if($user===false)
|
||||
{
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to get the username '.$args['username']);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Verify arguments with the database fields.
|
||||
foreach($args as $field=>$value)
|
||||
{
|
||||
if( isset($this->dbFields[$field]) )
|
||||
{
|
||||
// Sanitize or not.
|
||||
if($this->dbFields[$field]['sanitize']=='html') {
|
||||
// Sanitize if will be saved on database.
|
||||
$tmpValue = Sanitize::html($value);
|
||||
}
|
||||
else {
|
||||
$tmpValue = $value;
|
||||
}
|
||||
|
||||
$this->db[$username][$field] = $tmpValue;
|
||||
// Set type
|
||||
settype($tmpValue, gettype($this->dbFields[$field]['value']));
|
||||
|
||||
$user[$field] = $tmpValue;
|
||||
}
|
||||
}
|
||||
|
||||
$this->save();
|
||||
// Save the database
|
||||
$this->db[$args['username']] = $user;
|
||||
if( $this->save() === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -78,8 +89,8 @@ class dbUsers extends dbJSON
|
|||
// If the user send the field.
|
||||
if( isset($args[$field]) )
|
||||
{
|
||||
// Sanitize or not.
|
||||
if($options['sanitize']=='html') {
|
||||
// Sanitize if will be saved on database.
|
||||
if( !$options['inFile'] ) {
|
||||
$tmpValue = Sanitize::html($args[$field]);
|
||||
}
|
||||
else {
|
||||
|
@ -92,6 +103,10 @@ class dbUsers extends dbJSON
|
|||
$tmpValue = $options['value'];
|
||||
}
|
||||
|
||||
// Set type
|
||||
settype($tmpValue, gettype($options['value']));
|
||||
|
||||
// Save on database
|
||||
$dataForDb[$field] = $tmpValue;
|
||||
}
|
||||
|
||||
|
@ -104,12 +119,15 @@ class dbUsers extends dbJSON
|
|||
$dataForDb['registered'] = Date::unixTime();
|
||||
|
||||
// Password
|
||||
$dataForDb['salt'] = helperText::randomText(8);
|
||||
$dataForDb['salt'] = helperText::randomText(SALT_LENGTH);
|
||||
$dataForDb['password'] = sha1($dataForDb['password'].$dataForDb['salt']);
|
||||
|
||||
// Save the database
|
||||
$this->db[$dataForDb['username']] = $dataForDb;
|
||||
$this->save();
|
||||
if( $this->save() === false ) {
|
||||
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -5,21 +5,21 @@ class Alert {
|
|||
// new
|
||||
public static function set($value, $key='alert')
|
||||
{
|
||||
Session::set('displayed', false);
|
||||
Session::set('defined', true);
|
||||
|
||||
Session::set($key, $value);
|
||||
}
|
||||
|
||||
public static function get($key='alert')
|
||||
{
|
||||
Session::set('displayed', true);
|
||||
Session::set('defined', false);
|
||||
|
||||
return Session::get($key);
|
||||
}
|
||||
|
||||
public static function displayed()
|
||||
public static function defined()
|
||||
{
|
||||
return Session::get('displayed');
|
||||
return Session::get('defined');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -37,27 +37,10 @@ class Date {
|
|||
}
|
||||
}
|
||||
|
||||
// Old
|
||||
|
||||
public static function set_locale($string)
|
||||
{
|
||||
if(setlocale(LC_ALL,$string.'.UTF-8')!==false)
|
||||
return true;
|
||||
|
||||
if(setlocale(LC_ALL,$string.'.UTF8')!==false)
|
||||
return true;
|
||||
|
||||
return setlocale(LC_ALL,$string);
|
||||
}
|
||||
|
||||
public static function set_timezone($string)
|
||||
{
|
||||
return(date_default_timezone_set($string));
|
||||
}
|
||||
|
||||
// DEBUG: Check this function, need to be more fast
|
||||
// Return array('Africa/Abidjan'=>'Africa/Abidjan (GMT+0)', ..., 'Pacific/Wallis'=>'Pacific/Wallis (GMT+12)');
|
||||
// PHP supported list. http://php.net/manual/en/timezones.php
|
||||
public static function get_timezones()
|
||||
public static function timezoneList()
|
||||
{
|
||||
$tmp = array();
|
||||
|
||||
|
@ -76,12 +59,29 @@ class Date {
|
|||
|
||||
$text = str_replace("_"," ",$timezone_identifier);
|
||||
|
||||
$tmp[$timezone_identifier]=$text.' ('.$hours.':'.$mins.')';
|
||||
$tmp[$text.' ('.$hours.':'.$mins.')'] = $timezone_identifier;
|
||||
}
|
||||
|
||||
return($tmp);
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
// Old
|
||||
|
||||
public static function set_locale($string)
|
||||
{
|
||||
if(setlocale(LC_ALL,$string.'.UTF-8')!==false)
|
||||
return true;
|
||||
|
||||
if(setlocale(LC_ALL,$string.'.UTF8')!==false)
|
||||
return true;
|
||||
|
||||
return setlocale(LC_ALL,$string);
|
||||
}
|
||||
|
||||
public static function set_timezone($string)
|
||||
{
|
||||
return(date_default_timezone_set($string));
|
||||
}
|
||||
|
||||
|
||||
// Format a GMT/UTC+0 date/time
|
||||
|
|
|
@ -17,4 +17,10 @@ class Redirect {
|
|||
{
|
||||
self::url(HTML_PATH_ROOT.$base.'/'.$page);
|
||||
}
|
||||
|
||||
public static function home()
|
||||
{
|
||||
self::url(HTML_PATH_ROOT);
|
||||
}
|
||||
|
||||
}
|
|
@ -50,6 +50,8 @@ class Session {
|
|||
unset($_SESSION);
|
||||
|
||||
self::$started = false;
|
||||
|
||||
return !isset($_SESSION);
|
||||
}
|
||||
|
||||
public static function set($key, $value)
|
||||
|
|
|
@ -37,16 +37,25 @@ class helperText {
|
|||
return $text;
|
||||
}
|
||||
|
||||
public static function cleanUrl($string, $separator = '-')
|
||||
public static function cleanUrl($text, $separator='-')
|
||||
{
|
||||
$accents_regex = '~&([a-z]{1,2})(?:acute|cedil|circ|grave|lig|orn|ring|slash|th|tilde|uml);~i';
|
||||
$special_cases = array( '&' => 'and');
|
||||
$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);
|
||||
$string = preg_replace("/[$separator]+/u", "$separator", $string);
|
||||
return $string;
|
||||
// Delete characters
|
||||
$text = str_replace(array("“", "”", "!", "*", "'", """, "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]", "|"),'',$text);
|
||||
$text = preg_replace('![^\\pL\d]+!u', $separator, $text);
|
||||
|
||||
// Remove spaces
|
||||
$text = str_replace(' ',$separator, $text);
|
||||
|
||||
//remove any additional characters that might appear after translit
|
||||
//$text = preg_replace('![^-\w]+!', '', $text);
|
||||
|
||||
// Replace multiple dashes
|
||||
$text = preg_replace('/-{2,}/', $separator, $text);
|
||||
|
||||
// Make a string lowercase
|
||||
$text = self::lowercase($text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
// Replace all occurrences of the search string with the replacement string.
|
||||
|
@ -212,45 +221,6 @@ class helperText {
|
|||
return( strcmp($value1, $value2) == 0 );
|
||||
}
|
||||
|
||||
// Clean text for URL
|
||||
public static function clean_url($text, $spaces='-', $translit=false)
|
||||
{
|
||||
// Delete characters
|
||||
$text = str_replace(array("“", "”", "!", "*", "'", """, "(", ")", ";", ":", "@", "&", "=", "+", "$", ",", "/", "?", "%", "#", "[", "]", "|"),'',$text);
|
||||
$text = preg_replace('![^\\pL\d]+!u', '-', $text);
|
||||
|
||||
// Translit
|
||||
if($translit!=false)
|
||||
{
|
||||
$text = str_replace(array_keys($translit),array_values($translit),$text);
|
||||
}
|
||||
if (function_exists('iconv'))
|
||||
{
|
||||
$ret = iconv('utf-8', 'us-ascii//TRANSLIT//IGNORE', $text);
|
||||
if ($ret!==false){ //iconv might return false on error
|
||||
$text = $ret;
|
||||
}
|
||||
}
|
||||
|
||||
// Replace spaces by $spaces
|
||||
$text = str_replace(' ',$spaces,$text);
|
||||
|
||||
//remove any additional characters that might appear after translit
|
||||
$text = preg_replace('![^-\w]+!', '', $text);
|
||||
|
||||
// Replace multiple dashes
|
||||
$text = preg_replace('/-{2,}/', '-', $text);
|
||||
|
||||
// Make a string lowercase
|
||||
$text = self::str2lower($text);
|
||||
|
||||
return $text;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static function replace_assoc(array $replace, $text)
|
||||
{
|
||||
return str_replace(array_keys($replace), array_values($replace), $text);
|
||||
|
|
|
@ -2,6 +2,89 @@
|
|||
|
||||
class Theme {
|
||||
|
||||
// NEW
|
||||
|
||||
public static function css($files, $path=HTML_PATH_THEME_CSS, $echo=true)
|
||||
{
|
||||
if(!is_array($files)) {
|
||||
$files = array($files);
|
||||
}
|
||||
|
||||
$tmp = '';
|
||||
foreach($files as $file) {
|
||||
$tmp .= '<link rel="stylesheet" type="text/css" href="'.$path.$file.'">'.PHP_EOL;
|
||||
}
|
||||
|
||||
if($echo) {
|
||||
echo $tmp;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public static function javascript($files, $path=HTML_PATH_THEME_JS, $echo=true)
|
||||
{
|
||||
if(!is_array($files)) {
|
||||
$files = array($files);
|
||||
}
|
||||
|
||||
$tmp = '';
|
||||
foreach($files as $file) {
|
||||
$tmp .= '<script src="'.$path.$file.'"></script>'.PHP_EOL;
|
||||
}
|
||||
|
||||
if($echo) {
|
||||
echo $tmp;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public static function title($title, $echo=true)
|
||||
{
|
||||
$tmp = '<title>'.$title.'</title>'.PHP_EOL;
|
||||
|
||||
if($echo) {
|
||||
echo $tmp;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public static function description($description, $echo=true)
|
||||
{
|
||||
$tmp = '<meta name="description" content="'.$description.'">'.PHP_EOL;
|
||||
|
||||
if($echo) {
|
||||
echo $tmp;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public static function viewport($content='width=device-width, initial-scale=1.0', $echo=true)
|
||||
{
|
||||
$tmp = '<meta name="viewport" content="'.$content.'">'.PHP_EOL;
|
||||
|
||||
if($echo) {
|
||||
echo $tmp;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public static function charset($charset, $echo=true)
|
||||
{
|
||||
$tmp = '<meta charset="'.$charset.'">'.PHP_EOL;
|
||||
|
||||
if($echo) {
|
||||
echo $tmp;
|
||||
}
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
// OLD
|
||||
public static function plugins($type)
|
||||
{
|
||||
global $plugins;
|
||||
|
@ -12,7 +95,8 @@ class Theme {
|
|||
}
|
||||
}
|
||||
|
||||
// OLD
|
||||
|
||||
|
||||
public static function url($relative = true)
|
||||
{
|
||||
if($relative)
|
||||
|
@ -21,29 +105,9 @@ class Theme {
|
|||
return BLOG_URL;
|
||||
}
|
||||
|
||||
public static function css($files, $path=HTML_THEME_CSS)
|
||||
{
|
||||
if(!is_array($files))
|
||||
$files = array($files);
|
||||
|
||||
$tmp = '';
|
||||
foreach($files as $file)
|
||||
$tmp .= '<link rel="stylesheet" type="text/css" href="'.$path.$file.'">'.PHP_EOL;
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public static function javascript($files, $path=HTML_THEME_JS)
|
||||
{
|
||||
if(!is_array($files))
|
||||
$files = array($files);
|
||||
|
||||
$tmp = '';
|
||||
foreach($files as $file)
|
||||
$tmp .= '<script src="'.$path.$file.'"></script>'.PHP_EOL;
|
||||
|
||||
return $tmp;
|
||||
}
|
||||
|
||||
public static function jquery($path=JS_JQUERY)
|
||||
{
|
||||
|
|
|
@ -91,4 +91,9 @@ class Login {
|
|||
return sha1($agent);
|
||||
}
|
||||
|
||||
public function logout()
|
||||
{
|
||||
return Session::destroy();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -8,14 +8,19 @@ class Url
|
|||
private $slug;
|
||||
private $filters; // Filters for the URI
|
||||
private $notFound;
|
||||
private $parameters;
|
||||
|
||||
function __construct()
|
||||
{
|
||||
// Decodes any %## encoding in the given string. Plus symbols ('+') are decoded to a space character.
|
||||
$this->uri = urldecode($_SERVER['REQUEST_URI']);
|
||||
$decode = urldecode($_SERVER['REQUEST_URI']);
|
||||
|
||||
// URI Lowercase
|
||||
//$this->uri = helperText::lowercase($this->uri);
|
||||
// Parse, http://php.net/parse_url
|
||||
$parse = parse_url($decode);
|
||||
|
||||
$this->uri = $parse['path'];
|
||||
|
||||
$this->parameters = $_GET;
|
||||
|
||||
$this->uriStrlen = helperText::length($this->uri);
|
||||
|
||||
|
@ -104,6 +109,14 @@ class Url
|
|||
return $this->notFound;
|
||||
}
|
||||
|
||||
public function pageNumber()
|
||||
{
|
||||
if(isset($this->parameters['page'])) {
|
||||
return $this->parameters['page'];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function setNotFound($error = true)
|
||||
{
|
||||
$this->notFound = $error;
|
||||
|
|
|
@ -1,19 +1,36 @@
|
|||
<base href="<?php echo HTML_PATH_THEME ?>">
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta name="description" content="A layout example that shows off a blog page with a list of posts.">
|
||||
<?php
|
||||
Theme::charset('UTF-8');
|
||||
|
||||
<title>Blog – Layout Examples – Pure</title>
|
||||
Theme::viewport();
|
||||
|
||||
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600&subset=latin,cyrillic-ext,greek-ext,greek,vietnamese,cyrillic,latin-ext">
|
||||
<link href='http://fonts.googleapis.com/css?family=Muli:400,300' rel='stylesheet' type='text/css'>
|
||||
// <title>Site title</title>
|
||||
Theme::title( $Site->title() );
|
||||
|
||||
<link rel="stylesheet" href="css/pure-min.css">
|
||||
<link rel="stylesheet" href="css/grids-responsive-min.css">
|
||||
<link rel="stylesheet" href="css/blog.css">
|
||||
<link rel="stylesheet" href="css/rainbow.github.css">
|
||||
// <meta name="description" content="Site description">
|
||||
Theme::description( $Site->description() );
|
||||
|
||||
<script src="js/rainbow.min.js"></script>
|
||||
// <link rel="stylesheet" type="text/css" href="pure-min.css">
|
||||
// <link rel="stylesheet" type="text/css" href="grids-responsive-min.css">
|
||||
// <link rel="stylesheet" type="text/css" href="blog.css">
|
||||
// <link rel="stylesheet" type="text/css" href="rainbow.github.css">
|
||||
Theme::css(array(
|
||||
'pure-min.css',
|
||||
'grids-responsive-min.css',
|
||||
'blog.css',
|
||||
'rainbow.github.css'
|
||||
));
|
||||
|
||||
Theme::css(array(
|
||||
'http://fonts.googleapis.com/css?family=Open+Sans:400,300,600&subset=latin,cyrillic-ext,greek-ext,greek,vietnamese,cyrillic,latin-ext',
|
||||
'http://fonts.googleapis.com/css?family=Muli:400,300'
|
||||
), '');
|
||||
|
||||
// <script src="rainbow.min.js"></script>
|
||||
Theme::javascript(array(
|
||||
'rainbow.min.js'
|
||||
));
|
||||
|
||||
?>
|
||||
|
||||
<style>
|
||||
html, button, input, select, textarea,
|
||||
|
|
Loading…
Reference in New Issue