mirror of
https://github.com/sruupl/batflat.git
synced 2026-02-26 13:00:44 +01:00
@@ -82,7 +82,7 @@ class Admin extends Main
|
||||
private function loadLanguage($language)
|
||||
{
|
||||
$this->lang['name'] = $language;
|
||||
|
||||
|
||||
foreach (glob(MODULES.'/*/lang/admin/'.$language.'.ini') as $file) {
|
||||
$base = str_replace($language, 'en_english', $file);
|
||||
$module = str_replace([MODULES.'/', '/lang/admin/'.$language.'.ini'], null, $file);
|
||||
@@ -142,7 +142,7 @@ class Admin extends Main
|
||||
{
|
||||
$nav = [];
|
||||
$modules = $this->module->getArray();
|
||||
|
||||
|
||||
if ($this->getUserInfo('access') != 'all') {
|
||||
$modules = array_intersect_key($modules, array_fill_keys(explode(',', $this->getUserInfo('access')), null));
|
||||
}
|
||||
@@ -207,7 +207,7 @@ class Admin extends Main
|
||||
{
|
||||
$file = MODULES.'/'.$dir.'/Info.php';
|
||||
$core = $this;
|
||||
|
||||
|
||||
if (file_exists($file)) {
|
||||
return include($file);
|
||||
} else {
|
||||
@@ -241,7 +241,7 @@ class Admin extends Main
|
||||
if (method_exists($this->module->{$name}, $method)) {
|
||||
return call_user_func_array([$this->module->{$name}, $method], array_values($params));
|
||||
}
|
||||
|
||||
|
||||
$this->setNotify('failure', $this->lang['general']['unknown_method']);
|
||||
return false;
|
||||
}
|
||||
@@ -274,7 +274,7 @@ class Admin extends Main
|
||||
|
||||
$row = $this->db('users')->where('username', $username)->oneArray();
|
||||
|
||||
if (count($row) && password_verify(trim($password), $row['password'])) {
|
||||
if ($row && count($row) && password_verify(trim($password), $row['password'])) {
|
||||
// Reset fail attempts for this IP
|
||||
$this->db('login_attempts')->where('ip', $_SERVER['REMOTE_ADDR'])->save(['attempts' => 0]);
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ abstract class Main
|
||||
* @var array
|
||||
*/
|
||||
public $lang = [];
|
||||
|
||||
|
||||
/**
|
||||
* Templates instance
|
||||
*
|
||||
@@ -95,13 +95,13 @@ abstract class Main
|
||||
|
||||
$this->settings = new Settings($this);
|
||||
date_default_timezone_set($this->settings->get('settings.timezone'));
|
||||
|
||||
|
||||
$this->tpl = new Templates($this);
|
||||
$this->router = new Router;
|
||||
|
||||
$this->append(base64_decode('PG1ldGEgbmFtZT0iZ2VuZXJhdG9yIiBjb250ZW50PSJCYXRmbGF0IiAvPg=='), 'header');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* New instance of QueryBuilder
|
||||
*
|
||||
@@ -309,7 +309,7 @@ abstract class Main
|
||||
}
|
||||
setcookie('batflat_remember', null, -1, '/');
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -329,7 +329,7 @@ abstract class Main
|
||||
self::$userCache = $this->db('users')->where('id', $id)->oneArray();
|
||||
}
|
||||
|
||||
return self::$userCache[$field];
|
||||
return self::$userCache ? self::$userCache[$field] : null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -374,7 +374,7 @@ abstract class Main
|
||||
$core->db('modules')->save(['dir' => $name, 'sequence' => $order]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
redirect(url());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,51 +1,51 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is part of Batflat ~ the lightweight, fast and easy CMS
|
||||
*
|
||||
* @author Paweł Klockiewicz <klockiewicz@sruu.pl>
|
||||
* @author Wojciech Król <krol@sruu.pl>
|
||||
* @copyright 2017 Paweł Klockiewicz, Wojciech Król <Sruu.pl>
|
||||
* @license https://batflat.org/license
|
||||
* @link https://batflat.org
|
||||
*/
|
||||
/**
|
||||
* This file is part of Batflat ~ the lightweight, fast and easy CMS
|
||||
*
|
||||
* @author Paweł Klockiewicz <klockiewicz@sruu.pl>
|
||||
* @author Wojciech Król <krol@sruu.pl>
|
||||
* @copyright 2017 Paweł Klockiewicz, Wojciech Król <Sruu.pl>
|
||||
* @license https://batflat.org/license
|
||||
* @link https://batflat.org
|
||||
*/
|
||||
|
||||
if (!version_compare(PHP_VERSION, '5.5.0', '>=')) {
|
||||
exit("Batflat requires at least <b>PHP 5.5</b>");
|
||||
}
|
||||
if (!version_compare(PHP_VERSION, '5.5.0', '>=')) {
|
||||
exit("Batflat requires at least <b>PHP 5.5</b>");
|
||||
}
|
||||
|
||||
// Admin cat name
|
||||
define('ADMIN', 'admin');
|
||||
// Admin cat name
|
||||
define('ADMIN', 'admin');
|
||||
|
||||
// Themes path
|
||||
define('THEMES', BASE_DIR . '/themes');
|
||||
// Themes path
|
||||
define('THEMES', BASE_DIR . '/themes');
|
||||
|
||||
// Modules path
|
||||
define('MODULES', BASE_DIR . '/inc/modules');
|
||||
// Modules path
|
||||
define('MODULES', BASE_DIR . '/inc/modules');
|
||||
|
||||
// Uploads path
|
||||
define('UPLOADS', BASE_DIR . '/uploads');
|
||||
// Uploads path
|
||||
define('UPLOADS', BASE_DIR . '/uploads');
|
||||
|
||||
// Lock files
|
||||
define('FILE_LOCK', false);
|
||||
// Lock files
|
||||
define('FILE_LOCK', false);
|
||||
|
||||
// Basic modules
|
||||
define('BASIC_MODULES', serialize([
|
||||
8 => 'settings',
|
||||
0 => 'dashboard',
|
||||
2 => 'pages',
|
||||
3 => 'navigation',
|
||||
7 => 'users',
|
||||
1 => 'blog',
|
||||
4 => 'galleries',
|
||||
5 => 'snippets',
|
||||
6 => 'modules',
|
||||
9 => 'contact',
|
||||
10 => 'langswitcher',
|
||||
11 => 'devbar',
|
||||
]));
|
||||
// Basic modules
|
||||
define('BASIC_MODULES', serialize([
|
||||
8 => 'settings',
|
||||
0 => 'dashboard',
|
||||
2 => 'pages',
|
||||
3 => 'navigation',
|
||||
7 => 'users',
|
||||
1 => 'blog',
|
||||
4 => 'galleries',
|
||||
5 => 'snippets',
|
||||
6 => 'modules',
|
||||
9 => 'contact',
|
||||
10 => 'langswitcher',
|
||||
11 => 'devbar',
|
||||
]));
|
||||
|
||||
// HTML beautifier
|
||||
define('HTML_BEAUTY', false);
|
||||
// HTML beautifier
|
||||
define('HTML_BEAUTY', false);
|
||||
|
||||
// Developer mode
|
||||
define('DEV_MODE', false);
|
||||
// Developer mode
|
||||
define('DEV_MODE', false);
|
||||
@@ -60,8 +60,9 @@ function createSlug($text)
|
||||
$text = str_replace('.', '-', trim($text));
|
||||
$text = iconv('utf-8', 'ascii//translit', $text);
|
||||
$text = preg_replace('#[^a-z0-9\-]#si', '', $text);
|
||||
$text = str_replace('\'', '', $text);
|
||||
|
||||
return strtolower(str_replace('\'', '', $text));
|
||||
return strtolower($text ? $text : '-');
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,7 +25,7 @@ class Admin extends AdminModule
|
||||
$this->lang('settings') => 'settings'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* list of posts
|
||||
*/
|
||||
@@ -59,12 +59,12 @@ class Admin extends AdminModule
|
||||
} else {
|
||||
$lang = $this->settings('settings.lang_site');
|
||||
}
|
||||
|
||||
|
||||
// pagination
|
||||
$totalRecords = count($this->db('blog')->where('lang', $lang)->toArray());
|
||||
$pagination = new \Inc\Core\Lib\Pagination($page, $totalRecords, 10, url([ADMIN, 'blog', 'manage', '%d']));
|
||||
$this->assign['pagination'] = $pagination->nav();
|
||||
|
||||
|
||||
// list
|
||||
$this->assign['newURL'] = url([ADMIN, 'blog', 'add']);
|
||||
$this->assign['postCount'] = 0;
|
||||
@@ -73,7 +73,7 @@ class Admin extends AdminModule
|
||||
->limit($pagination->offset().', '.$pagination->getRecordsPerPage())
|
||||
->desc('published_at')->desc('created_at')
|
||||
->toArray();
|
||||
|
||||
|
||||
$this->assign['posts'] = [];
|
||||
if ($totalRecords) {
|
||||
$this->assign['postCount'] = $totalRecords;
|
||||
@@ -86,7 +86,7 @@ class Admin extends AdminModule
|
||||
$fullname = $this->core->getUserInfo('fullname', $row['user_id'], true);
|
||||
$username = $this->core->getUserInfo('username', $row['user_id'], true);
|
||||
$row['user'] = !empty($fullname) ? $fullname.' ('.$username.')' : $username;
|
||||
|
||||
|
||||
$row['comments'] = $row['comments'] ? $this->lang('comments_on') : $this->lang('comments_off');
|
||||
|
||||
switch ($row['status']) {
|
||||
@@ -116,7 +116,7 @@ class Admin extends AdminModule
|
||||
|
||||
return $this->draw('manage.html', ['blog' => $this->assign]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* add new post
|
||||
*/
|
||||
@@ -124,8 +124,8 @@ class Admin extends AdminModule
|
||||
{
|
||||
return $this->getEdit(null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* edit post
|
||||
*/
|
||||
@@ -155,7 +155,7 @@ class Admin extends AdminModule
|
||||
} else {
|
||||
$blog = $this->db('blog')->where('id', $id)->oneArray();
|
||||
}
|
||||
|
||||
|
||||
if (!empty($blog)) {
|
||||
$this->assign['langs'] = $this->_getLanguages($blog['lang'], 'selected');
|
||||
$this->assign['form'] = htmlspecialchars_array($blog);
|
||||
@@ -163,7 +163,7 @@ class Admin extends AdminModule
|
||||
$this->assign['form']['date'] = date("Y-m-d\TH:i", $blog['published_at']);
|
||||
|
||||
$tags_array = $this->db('blog_tags')->leftJoin('blog_tags_relationship', 'blog_tags.id = blog_tags_relationship.tag_id')->where('blog_tags_relationship.blog_id', $blog['id'])->select(['blog_tags.name'])->toArray();
|
||||
|
||||
|
||||
$this->assign['form']['tags'] = $tags_array;
|
||||
$this->assign['users'] = $this->db('users')->toArray();
|
||||
$this->assign['author'] = $this->core->getUserInfo('id', $blog['user_id'], true);
|
||||
@@ -175,7 +175,7 @@ class Admin extends AdminModule
|
||||
redirect(url([ADMIN, 'blog', 'manage']));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Save post
|
||||
*
|
||||
@@ -191,7 +191,7 @@ class Admin extends AdminModule
|
||||
} else {
|
||||
$tags = [];
|
||||
}
|
||||
|
||||
|
||||
unset($_POST['tags']);
|
||||
|
||||
// redirect location
|
||||
@@ -250,7 +250,7 @@ class Admin extends AdminModule
|
||||
$_POST['cover_photo'] = $_POST['slug'].".".$img->getInfos('type');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!$id) { // new
|
||||
$_POST['created_at'] = strtotime(date('Y-m-d H:i:s'));
|
||||
|
||||
@@ -268,7 +268,7 @@ class Admin extends AdminModule
|
||||
$blogId = $id ? $id : $this->db()->pdo()->lastInsertId();
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Attach or create new tag
|
||||
foreach ($tags as $tag) {
|
||||
if (preg_match("/[`~!@#$%^&*()_|+\-=?;:\'\",.<>\{\}\[\]\\\/]+/", $tag)) {
|
||||
@@ -300,7 +300,7 @@ class Admin extends AdminModule
|
||||
|
||||
redirect($location);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Remove post
|
||||
*
|
||||
@@ -395,7 +395,7 @@ class Admin extends AdminModule
|
||||
|
||||
if (isset($_FILES['file']['tmp_name'])) {
|
||||
$img = new \Inc\Core\Lib\Image;
|
||||
|
||||
|
||||
if ($img->load($_FILES['file']['tmp_name'])) {
|
||||
$imgPath = $dir.'/'.time().'.'.$img->getInfos('type');
|
||||
$img->save($imgPath);
|
||||
@@ -448,7 +448,7 @@ class Admin extends AdminModule
|
||||
if ($this->settings('settings.lang_admin') != 'en_english') {
|
||||
$this->core->addJS(url('inc/jscripts/wysiwyg/lang/'.$this->settings('settings.lang_admin').'.js'));
|
||||
}
|
||||
|
||||
|
||||
// HTML & MARKDOWN EDITOR
|
||||
$this->core->addCSS(url('/inc/jscripts/editor/markitup.min.css'));
|
||||
$this->core->addCSS(url('/inc/jscripts/editor/markitup.highlight.min.css'));
|
||||
@@ -459,7 +459,7 @@ class Admin extends AdminModule
|
||||
$this->core->addJS(url('/inc/jscripts/editor/markitup.highlight.min.js'));
|
||||
$this->core->addJS(url('/inc/jscripts/editor/sets/html/set.min.js'));
|
||||
$this->core->addJS(url('/inc/jscripts/editor/sets/markdown/set.min.js'));
|
||||
|
||||
|
||||
// ARE YOU SURE?
|
||||
$this->core->addJS(url('inc/jscripts/are-you-sure.min.js'));
|
||||
|
||||
|
||||
@@ -112,7 +112,7 @@ class Admin extends AdminModule
|
||||
|
||||
// list of parents
|
||||
$this->assign['navs'] = $this->_getParents($lang, $row['nav'], $row['parent'], $row['id']);
|
||||
|
||||
|
||||
$this->assign['title'] = $this->lang('edit_link');
|
||||
return $this->draw('form.link.html', ['navigation' => $this->assign]);
|
||||
} else {
|
||||
@@ -126,7 +126,7 @@ class Admin extends AdminModule
|
||||
public function postSaveLink($id = null)
|
||||
{
|
||||
unset($_POST['save']);
|
||||
|
||||
|
||||
// check if it's an external link
|
||||
if ($_POST['page']) {
|
||||
$fields = ['name', 'page', 'lang', 'parent'];
|
||||
@@ -219,7 +219,7 @@ class Admin extends AdminModule
|
||||
redirect(url([ADMIN, 'navigation', 'manage']));
|
||||
}
|
||||
|
||||
return $this->draw('form.nav.html', ['navigation', $this->assign]);
|
||||
return $this->draw('form.nav.html', ['navigation' => $this->assign]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -24,7 +24,7 @@ class Admin extends AdminModule
|
||||
$this->lang('add_new') => 'add'
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* list of pages
|
||||
*/
|
||||
@@ -48,7 +48,7 @@ class Admin extends AdminModule
|
||||
$rows = $this->db('pages')->where('lang', $lang)
|
||||
->limit($pagination->offset().', '.$pagination->getRecordsPerPage())
|
||||
->toArray();
|
||||
|
||||
|
||||
$this->assign['list'] = [];
|
||||
if (count($rows)) {
|
||||
foreach ($rows as $row) {
|
||||
@@ -61,11 +61,11 @@ class Admin extends AdminModule
|
||||
$this->assign['list'][] = $row;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$this->assign['langs'] = $this->_getLanguages($lang);
|
||||
return $this->draw('manage.html', ['pages' => $this->assign]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* add new page
|
||||
*/
|
||||
@@ -73,14 +73,14 @@ class Admin extends AdminModule
|
||||
{
|
||||
$this->assign['editor'] = $this->settings('settings', 'editor');
|
||||
$this->_addHeaderFiles();
|
||||
|
||||
|
||||
// Unsaved data with failure
|
||||
if (!empty($e = getRedirectData())) {
|
||||
$this->assign['form'] = ['title' => isset_or($e['title'], ''), 'desc' => isset_or($e['desc'], ''), 'content' => isset_or($e['content'], ''), 'slug' => isset_or($e['slug'], '')];
|
||||
} else {
|
||||
$this->assign['form'] = ['title' => '', 'desc' => '', 'content' => '', 'slug' => '', 'markdown' => 0];
|
||||
}
|
||||
|
||||
|
||||
$this->assign['title'] = $this->lang('new_page');
|
||||
$this->assign['langs'] = $this->_getLanguages($this->settings('settings.lang_site'), 'selected');
|
||||
$this->assign['templates'] = $this->_getTemplates(isset_or($e['template'], 'index.html'));
|
||||
@@ -88,8 +88,8 @@ class Admin extends AdminModule
|
||||
|
||||
return $this->draw('form.html', ['pages' => $this->assign]);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* edit page
|
||||
*/
|
||||
@@ -99,13 +99,13 @@ class Admin extends AdminModule
|
||||
$this->_addHeaderFiles();
|
||||
|
||||
$page = $this->db('pages')->where('id', $id)->oneArray();
|
||||
|
||||
|
||||
if (!empty($page)) {
|
||||
// Unsaved data with failure
|
||||
if (!empty($e = getRedirectData())) {
|
||||
$page = array_merge($page, ['title' => isset_or($e['title'], ''), 'desc' => isset_or($e['desc'], ''), 'content' => isset_or($e['content'], ''), 'slug' => isset_or($e['slug'], '')]);
|
||||
}
|
||||
|
||||
|
||||
$this->assign['form'] = htmlspecialchars_array($page);
|
||||
$this->assign['form']['content'] = $this->tpl->noParse($this->assign['form']['content']);
|
||||
|
||||
@@ -119,7 +119,7 @@ class Admin extends AdminModule
|
||||
redirect(url([ADMIN, 'pages', 'manage']));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* save data
|
||||
*/
|
||||
@@ -142,7 +142,7 @@ class Admin extends AdminModule
|
||||
if (!isset($_POST['markdown'])) {
|
||||
$_POST['markdown'] = 0;
|
||||
}
|
||||
|
||||
|
||||
if (empty($_POST['slug'])) {
|
||||
$_POST['slug'] = createSlug($_POST['title']);
|
||||
} else {
|
||||
@@ -173,7 +173,7 @@ class Admin extends AdminModule
|
||||
|
||||
redirect($location);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* remove page
|
||||
*/
|
||||
@@ -204,7 +204,7 @@ class Admin extends AdminModule
|
||||
|
||||
if (isset($_FILES['file']['tmp_name'])) {
|
||||
$img = new \Inc\Core\Lib\Image;
|
||||
|
||||
|
||||
if ($img->load($_FILES['file']['tmp_name'])) {
|
||||
$imgPath = $dir.'/'.time().'.'.$img->getInfos('type');
|
||||
$img->save($imgPath);
|
||||
@@ -229,7 +229,7 @@ class Admin extends AdminModule
|
||||
echo $this->draw(MODULES.'/pages/js/admin/pages.js');
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* list of theme's templates
|
||||
* @param string $selected
|
||||
@@ -239,7 +239,7 @@ class Admin extends AdminModule
|
||||
{
|
||||
$theme = $this->settings('settings', 'theme');
|
||||
$tpls = glob(THEMES.'/'.$theme.'/*.html');
|
||||
|
||||
|
||||
$result = [];
|
||||
foreach ($tpls as $tpl) {
|
||||
if ($selected == basename($tpl)) {
|
||||
@@ -260,7 +260,7 @@ class Admin extends AdminModule
|
||||
if ($this->settings('settings', 'lang_admin') != 'en_english') {
|
||||
$this->core->addJS(url('inc/jscripts/wysiwyg/lang/'.$this->settings('settings', 'lang_admin').'.js'));
|
||||
}
|
||||
|
||||
|
||||
// HTML & MARKDOWN EDITOR
|
||||
$this->core->addCSS(url('/inc/jscripts/editor/markitup.min.css'));
|
||||
$this->core->addCSS(url('/inc/jscripts/editor/markitup.highlight.min.css'));
|
||||
@@ -271,7 +271,7 @@ class Admin extends AdminModule
|
||||
$this->core->addJS(url('/inc/jscripts/editor/markitup.highlight.min.js'));
|
||||
$this->core->addJS(url('/inc/jscripts/editor/sets/html/set.min.js'));
|
||||
$this->core->addJS(url('/inc/jscripts/editor/sets/markdown/set.min.js'));
|
||||
|
||||
|
||||
// ARE YOU SURE?
|
||||
$this->core->addJS(url('inc/jscripts/are-you-sure.min.js'));
|
||||
|
||||
|
||||
4
inc/modules/searchbox/lang/it_italian.ini
Normal file
4
inc/modules/searchbox/lang/it_italian.ini
Normal file
@@ -0,0 +1,4 @@
|
||||
placeholder = "Cerca per..."
|
||||
results_for = "Risultati trovati per '%s' "
|
||||
too_short_phrase = "La parole inserite sono troppo corte! Inserisci una frase che contenga almeno %d caratteri."
|
||||
no_results = "Non sono stati trovati risultati'%s'."
|
||||
Reference in New Issue
Block a user