Merge branch 'dignajar/master'

This commit is contained in:
Frédéric K 2015-08-15 00:12:58 +02:00
commit 7227a55044
17 changed files with 378 additions and 22 deletions

View File

@ -0,0 +1,26 @@
<?php defined('BLUDIT') or die('Bludit CMS.');
// ============================================================================
// Check role
// ============================================================================
if($Login->role()!=='admin') {
Alert::set($Language->g('you-do-not-have-sufficient-permissions'));
Redirect::page('admin', 'dashboard');
}
// ============================================================================
// Functions
// ============================================================================
// ============================================================================
// Main before POST
// ============================================================================
// ============================================================================
// POST Method
// ============================================================================
// ============================================================================
// Main after POST
// ============================================================================

View File

@ -140,6 +140,7 @@ div.dashboardBox .nav {
div.dashboardBox .nav a { div.dashboardBox .nav a {
padding: 0 !important; padding: 0 !important;
display: inline-block; display: inline-block;
margin-left: 8px;
} }
div.dashboardBox i.iconContent { div.dashboardBox i.iconContent {
@ -154,6 +155,11 @@ div.dashboardBox div.bigContent {
font-weight: bold; font-weight: bold;
} }
div.dashboardBox span {
display: inline-block !important;
padding: 3px 6px;
}
div.dashboardBox h2 { div.dashboardBox h2 {
color: #666; color: #666;
font-size: 1.1em; font-size: 1.1em;
@ -189,6 +195,7 @@ div.dashboardBox ul.menu li.description:last-child {
margin-bottom: 0 !important; margin-bottom: 0 !important;
} }
/* ----------- FORMS ----------- */ /* ----------- FORMS ----------- */
form h4 { form h4 {

View File

@ -63,11 +63,11 @@
{ {
foreach($_draftPosts as $Post) foreach($_draftPosts as $Post)
{ {
echo '<li>('.$Language->g('Post').') <a href="'.HTML_PATH_ADMIN_ROOT.'edit-post/'.$Post->key().'">'.($Post->title()?$Post->title():'['.$Language->g('Empty title').'] ').'</a></li>'; echo '<li><span class="label label-outline label-blue smaller">'.$Language->g('Post').'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-post/'.$Post->key().'">'.($Post->title()?$Post->title():'['.$Language->g('Empty title').'] ').'</a></li>';
} }
foreach($_draftPages as $Page) foreach($_draftPages as $Page)
{ {
echo '<li>('.$Language->g('Page').') <a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.($Page->title()?$Page->title():'['.$Language->g('Empty title').'] ').'</a></li>'; echo '<li><span class="label label-outline label-green smaller">'.$Language->g('Page').'</span><a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.($Page->title()?$Page->title():'['.$Language->g('Empty title').'] ').'</a></li>';
} }
} }
?> ?>
@ -75,7 +75,5 @@
</nav> </nav>
</div> </div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -24,7 +24,7 @@
} }
echo '<tr>'; echo '<tr>';
echo '<td>'.($Page->parentKey()?NO_PARENT_CHAR:'').'<a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.($Page->published()?'':'['.$Language->g('Draft').'] ').($Page->title()?$Page->title():'['.$Language->g('Empty title').'] ').'</a></td>'; echo '<td>'.($Page->parentKey()?NO_PARENT_CHAR:'').'<a href="'.HTML_PATH_ADMIN_ROOT.'edit-page/'.$Page->key().'">'.($Page->published()?'':'<span class="label label-outline label-red smaller">'.$Language->g('Draft').'</span> ').($Page->title()?$Page->title():'<span class="label label-outline label-blue smaller">'.$Language->g('Empty title').'</span> ').'</a></td>';
echo '<td>'.$parentTitle.'</td>'; echo '<td>'.$parentTitle.'</td>';
echo '</tr>'; echo '</tr>';
} }

View File

@ -16,7 +16,7 @@
foreach($posts as $Post) foreach($posts as $Post)
{ {
echo '<tr>'; echo '<tr>';
echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-post/'.$Post->key().'">'.($Post->published()?'':'<span class="label label-outline label-red smaller">'.$Language->g('Draft').'</span> ').($Post->title()?$Post->title():'['.$Language->g('Empty title').'] ').'</a></td>'; echo '<td><a href="'.HTML_PATH_ADMIN_ROOT.'edit-post/'.$Post->key().'">'.($Post->published()?'':'<span class="label label-outline label-red smaller">'.$Language->g('Draft').'</span> ').($Post->title()?$Post->title():'<span class="label label-outline label-blue smaller">'.$Language->g('Empty title').'</span> ').'</a></td>';
echo '<td>'.$Post->dateCreated().'</td>'; echo '<td>'.$Post->dateCreated().'</td>';
echo '<td>'.$Post->timeago().'</td>'; echo '<td>'.$Post->timeago().'</td>';
echo '</tr>'; echo '</tr>';

View File

@ -3,12 +3,12 @@
<?php <?php
foreach($themes as $theme) foreach($themes as $theme)
{ {
$installed = ''; $installedCSS = '';
if($theme['dirname']==$Site->theme()) { if($theme['dirname']==$Site->theme()) {
$installed = 'themeBoxInstalled'; $installedCSS = 'themeBoxInstalled';
} }
echo '<div class="themeBox '.$installed.'">'; echo '<div class="themeBox '.$installedCSS.'">';
echo '<p class="name">'.$theme['name'].'</p>'; echo '<p class="name">'.$theme['name'].'</p>';
echo '<p>'.$theme['description'].'</p>'; echo '<p>'.$theme['description'].'</p>';

View File

@ -74,7 +74,7 @@ function build_page($key)
$user = $dbUsers->getDb( $Page->username() ); $user = $dbUsers->getDb( $Page->username() );
$Page->setField('authorFirstName', $user['firstName'], false); $Page->setField('authorFirstName', $user['firstName'], false);
$Page->setField('authorLastName', $user['lastName'], false); $Page->setField('authorLastName', $user['lastName'], false);
} }
@ -167,14 +167,13 @@ if( ($Url->whereAmI()==='page') && ($Url->notFound()===false) )
// Default homepage // Default homepage
if($Url->notFound()===false) if($Url->notFound()===false)
{ {
if( ($Site->homepage()!=='home') && ($Url->whereAmI()==='home') ) if( Text::isNotEmpty($Site->homepage()) && ($Url->whereAmI()==='home') )
{ {
$Url->setWhereAmI('page'); $Url->setWhereAmI('page');
$Page = build_page( $Site->homepage() ); $Page = build_page( $Site->homepage() );
if($Page===false) if($Page===false) {
{
$Url->setWhereAmI('home'); $Url->setWhereAmI('home');
} }
} }

View File

@ -4,7 +4,8 @@ class Security extends dbJSON
{ {
private $dbFields = array( private $dbFields = array(
'minutesBlocked'=>5, 'minutesBlocked'=>5,
'numberFailures'=>10 'numberFailuresAllowed'=>10,
'blackList'=>array('numberFailures', 'lastFailure')
); );
function __construct() function __construct()
@ -12,14 +13,47 @@ class Security extends dbJSON
parent::__construct(PATH_DATABASES.'security.php'); parent::__construct(PATH_DATABASES.'security.php');
} }
public function isBlocked()
{
$ip = $this->getUserIp();
if(!isset($this->db['blackList'][$ip])) {
return false;
}
$currentTime = time();
$userBlack = $this->db['blackList'][$ip];
$numberFailures = $userBlack['numberFailures'];
$lastFailure = $userBlack['lastFailure'];
// Check if the IP is expired, then is not blocked.
if($currentTime > $lastFailure + $this->db['minutesBlocked']) {
return false;
}
// The IP has more failures than number of failures, then the IP is blocked.
if($numberFailures >= $this->db['numberFailuresAllowed']) {
return true;
}
// Otherwise the IP is not blocked.
return false;
}
public function addLoginFail() public function addLoginFail()
{ {
$ip = $this->getUserIp(); $ip = $this->getUserIp();
$currentTime = time();
$numberFailures = 1;
if(isset($this->db['blackList'][$ip])) {
$numberFailures = $userBlack['numberFailures'];
$numberFailures = $numberFailures + 1;
}
$this->db['blackList'][$ip] = array('lastFailure'=>$currentTime, 'numberFailures'=>$numberFailures);
// Save the database // Save the database
$this->db[$ip] = (int)$this->db[$ip] + 1;
if( $this->save() === false ) { if( $this->save() === false ) {
Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.'); Log::set(__METHOD__.LOG_SEP.'Error occurred when trying to save the database file.');
return false; return false;

149
languages/zh_TW.json Normal file
View File

@ -0,0 +1,149 @@
{
"language-data":
{
"native": "Traditional Chinese (Taiwan)",
"english-name": "Traditional Chinese",
"last-update": "2015-08-09",
"author": "Ethan Chen",
"email": "ethan42411@gmail.com",
"website": "http://single4.ml"
},
"username": "使用者名稱",
"password": "使用者密碼",
"confirm-password": "確認密碼",
"editor": "作者",
"dashboard": "主頁面",
"role": "角色",
"post": "文章",
"posts": "文章",
"users": "使用者",
"administrator": "管理員",
"add": "新增",
"cancel": "取消",
"content": "內容",
"title": "標題",
"no-parent": "沒有繼承頁面",
"edit-page": "編輯頁面",
"edit-post": "編輯文章",
"add-a-new-user": "新增使用者",
"parent": "繼承頁面",
"friendly-url": "友善網址",
"description": "簡介",
"posted-by": "發表由",
"tags": "標籤",
"position": "位置",
"save": "儲存",
"draft": "草稿",
"delete": "刪除",
"registered": "已註冊",
"Notifications": "通知",
"profile": "個人檔案",
"email": "Email",
"settings": "設定",
"general": "一般設定",
"advanced": "進階設定",
"regional": "區域",
"about": "關於",
"login": "登入",
"logout": "登出",
"manage": "管理",
"themes": "佈景主題",
"prev-page": "上一頁",
"next-page": "下一頁",
"configure-plugin": "設定延伸模組",
"confirm-delete-this-action-cannot-be-undone": "確認刪除? 這個動作不可復原",
"site-title": "網站標題",
"site-slogan": "網站標語",
"site-description": "網站簡介",
"footer-text": "頁尾文字",
"posts-per-page": "每頁文章數",
"site-url": "網站網址",
"writting-settings": "撰寫設定",
"url-filters": "網址過濾器",
"page": "頁面",
"pages": "頁面",
"home": "首頁",
"welcome-back": "歡迎回來",
"language": "語言",
"website": "網站",
"timezone": "時區",
"locale": "區域",
"new-post": "新文章",
"html-and-markdown-code-supported": "支援HTML與Markdown程式碼",
"new-page": "新頁面",
"manage-posts": "管理文章",
"published-date": "發表日期",
"modified-date": "修改日期",
"empty-title": "空白標題",
"plugins": "延伸模組",
"install-plugin": "安裝延伸模組",
"uninstall-plugin": "移除延伸模組",
"new-password": "新密碼",
"edit-user": "編輯使用者",
"publish-now": "立即發表",
"first-name": "名",
"last-name": "姓",
"bludit-version": "Bludit版本",
"powered-by": "Powered by",
"recent-posts": "最新文章",
"manage-pages": "管理頁面",
"advanced-options": "進階設定",
"user-deleted": "使用者已刪除",
"page-added-successfully": "頁面已成功新增",
"post-added-successfully": "文章已成功新增",
"the-post-has-been-deleted-successfully": "頁面已成功被刪除",
"the-page-has-been-deleted-successfully": "頁面已成功被刪除",
"username-or-password-incorrect": "使用者帳號或密碼不正確",
"database-regenerated": "資料庫已經重建",
"the-changes-have-been-saved": "變更已經儲存",
"enable-more-features-at": "啟用更多功能在",
"username-already-exists": "使用者名稱已經存在",
"username-field-is-empty": "使用者名稱欄位為空白",
"the-password-and-confirmation-password-do-not-match":"使用者密碼與確認密碼不符",
"user-has-been-added-successfully": "使用者已新增成功",
"you-do-not-have-sufficient-permissions": "您沒有權限存取此頁面,請聯絡管理員",
"settings-advanced-writting-settings": "設定->進階設定->撰寫設定",
"new-posts-and-pages-synchronized": "新文章與頁面已經同步完成",
"you-can-choose-the-users-privilege": "您可以選擇使用者的權限,作者角色只能撰寫頁面與文章",
"email-will-not-be-publicly-displayed": "Email將不會被公開顯示建議用於復原密碼或是通知",
"use-this-field-to-name-your-site": "使用這個欄位來填寫您的網站名稱,它將會被顯示在每一個頁面的最上方",
"use-this-field-to-add-a-catchy-prhase": "使用這個欄位來幫您的網站添加一個可以朗朗上口的標語吧",
"you-can-add-a-site-description-to-provide": "您可以新增一段簡短的簡介來介紹您的網站",
"you-can-add-a-small-text-on-the-bottom": "您可以在每一頁的頁尾放置一些短短的文字,例如: 版權、所有人、日期...",
"number-of-posts-to-show-per-page": "每一頁會顯示幾篇文章的數量",
"the-url-of-your-site": "網站的網址",
"add-or-edit-description-tags-or": "新增或編輯簡介、標籤或是修改友善網址",
"select-your-sites-language": "選擇您所使用的語言",
"select-a-timezone-for-a-correct": "選擇正確的時區來顯示時間",
"you-can-use-this-field-to-define-a-set-of": "您可以使用此欄位來定義相關的語言、國家與特別的參數",
"you-can-modify-the-url-which-identifies":"您可以修改網址來讓文章或頁面的網址可以更接近人類所了解的字詞不能超過150個字",
"this-field-can-help-describe-the-content": "這個欄位可以幫助快速理解內容不能超過150個字",
"write-the-tags-separeted-by-comma": "撰寫使用逗號分隔的標籤,例如: 標籤1, 標籤2, 標籤3",
"delete-the-user-and-all-its-posts":"刪除使用者與他所發表的文章",
"delete-the-user-and-associate-its-posts-to-admin-user": "刪除使用者,並將他所發表的文章關連至管理員權限的使用者",
"read-more": "繼續越讀",
"show-blog": "顯示部落格",
"default-home-page": "預設首頁",
"version": "版本",
"there-are-no-drafts": "沒有草稿",
"create-a-new-article-for-your-blog":"為您的網站建立一篇新文章",
"create-a-new-page-for-your-website":"為您的網站建立一個新頁面",
"invite-a-friend-to-collaborate-on-your-website":"邀請朋友來慶祝您的新網站開張",
"change-your-language-and-region-settings":"更改您所使用的語言與地區設定",
"language-and-timezone":"語言與時區",
"author": "作者",
"start-here": "從這裡開始",
"install-theme": "安裝佈景主題",
"first-post": "第一篇文章",
"congratulations-you-have-successfully-installed-your-bludit": "恭喜您已經成功安裝您的**Bludit**",
"whats-next": "接下來",
"manage-your-bludit-from-the-admin-panel": "透過[admin area](./admin/)管理您的Bludit",
"follow-bludit-on": "Follow Bludit on",
"visit-the-support-forum": "拜訪[forum](http://forum.bludit.com)來取得支援",
"read-the-documentation-for-more-information": "閱讀[documentation](http://docs.bludit.com)來獲得更多資訊",
"share-with-your-friends-and-enjoy": "分享給您的朋友們",
"the-page-has-not-been-found": "此頁面不存在",
"error": "錯誤"
}

View File

@ -0,0 +1,12 @@
{
"plugin-data":
{
"name": "Disqus comment system",
"description": "Disqus is a blog comment hosting service for web sites. It's necesary to register on Disqus.com before using this plugin.",
"author": "Bludit",
"email": "",
"website": "http://www.bludit.com",
"version": "0.1",
"releaseDate": "2015-08-02"
}
}

65
plugins/disqus/plugin.php Normal file
View File

@ -0,0 +1,65 @@
<?php
class pluginDisqus extends Plugin {
public function init()
{
$this->dbFields = array(
'shortname'=>''
);
}
public function form()
{
global $Language;
$html = '<div>';
$html .= '<label>Disqus shortname</label>';
$html .= '<input name="shortname" id="jsshortname" type="text" value="'.$this->getDbField('shortname').'">';
$html .= '</div>';
return $html;
}
public function postEnd()
{
$html = '<div id="disqus_thread"></div>';
return $html;
}
public function pageEnd()
{
return $this->postEnd();
}
public function siteHead()
{
$html = '<style>#disqus_thread { margin: 20px 0 }</style>';
return $html;
}
public function siteBodyEnd()
{
global $Url;
if( ($Url->whereAmI()!='post') && ($Url->whereAmI()!='page') ) {
return '';
}
$html = '
<script type="text/javascript">
var disqus_shortname = "'.$this->getDbField('shortname').'";
(function() {
var dsq = document.createElement("script"); dsq.type = "text/javascript"; dsq.async = true;
dsq.src = "//" + disqus_shortname + ".disqus.com/embed.js";
(document.getElementsByTagName("head")[0] || document.getElementsByTagName("body")[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>';
return $html;
}
}

View File

@ -0,0 +1,15 @@
{
"plugin-data":
{
"name": "維護模式",
"description": "設定您的網站為維護模式,但是您依然可以登入到管理介面",
"author": "Bludit",
"email": "",
"website": "http://www.bludit.com",
"version": "0.1",
"releaseDate": "2015-08-02"
},
"enable-maintence-mode": "啟用維護模式",
"message": "訊息"
}

View File

@ -0,0 +1,12 @@
{
"plugin-data":
{
"name": "開放社交關係圖",
"description": "開放社交關係圖協定可以讓任何網頁變成豐富的物件",
"author": "Bludit",
"email": "",
"website": "http://www.bludit.com",
"version": "0.1",
"releaseDate": "2015-08-02"
}
}

View File

@ -0,0 +1,15 @@
{
"plugin-data":
{
"name": "頁面列表",
"description": "顯示所有頁面的列表",
"author": "Bludit",
"email": "",
"website": "http://www.bludit.com",
"version": "0.1",
"releaseDate": "2015-08-02"
},
"home": "首頁",
"show-home-link": "顯示首頁連結"
}

View File

@ -47,28 +47,28 @@ class pluginPages extends Plugin {
foreach($parents as $parent) foreach($parents as $parent)
{ {
if($Site->homepage()!==$parent->key()) //if($Site->homepage()!==$parent->key())
{ {
// Print the parent // Print the parent
$html .= '<li><a class="parent" href="'.$parent->permalink().'">'.$parent->title().'</a></li>'; $html .= '<li><a class="parent" href="'.$parent->permalink().'">'.$parent->title().'</a>';
// Check if the parent hash children // Check if the parent has children
if(isset($pagesParents[$parent->key()])) if(isset($pagesParents[$parent->key()]))
{ {
$children = $pagesParents[$parent->key()]; $children = $pagesParents[$parent->key()];
// Print the children // Print the children
$html .= '<li><ul>'; $html .= '<ul>';
foreach($children as $child) foreach($children as $child)
{ {
$html .= '<li><a class="children" href="'.$child->permalink().'">'.$child->title().'</a></li>'; $html .= '<li><a class="children" href="'.$child->permalink().'">'.$child->title().'</a></li>';
} }
$html .= '</ul></li>'; $html .= '</ul>';
} }
} }
} }
$html .= '</ul>'; $html .= '</li></ul>';
$html .= '</div>'; $html .= '</div>';
$html .= '</div>'; $html .= '</div>';

View File

@ -0,0 +1,12 @@
{
"plugin-data":
{
"name": "Tinymce",
"description": "Tinymce是一個簡單易使用的HTML編輯器有著非常多的延伸模組與高自訂性",
"author": "Bludit",
"email": "",
"website": "http://www.bludit.com",
"version": "0.1",
"releaseDate": "2015-08-02"
}
}

View File

@ -64,6 +64,12 @@ code {
letter-spacing: 0.1em; letter-spacing: 0.1em;
} }
.content {
padding-top: 3em;
margin-right: 30px;
margin-left: 30px;
}
#layout { #layout {
padding: 0; padding: 0;
} }
@ -268,6 +274,12 @@ div.plugin-content ul > li > ul > li {
margin: 0; margin: 0;
} }
div.plugin-content ul > li > ul > li:before {
color: #777;
content: "—";
padding-right: 5px;
}
div.plugin-content ul > li > ul > li > a { div.plugin-content ul > li > ul > li > a {
color: #777; color: #777;
} }