Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'flatCore-CMS/develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
patkon committed Sep 30, 2020
2 parents 4122703 + c8d6ea4 commit 259f3a2
Show file tree
Hide file tree
Showing 55 changed files with 2,128 additions and 1,484 deletions.
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

## flatCore CMS

flatCore is a lightweight Content Management System based on PHP and SQLite.
flatCore is a lightweight Content Management System based on PHP and SQLite. MySQL database support is in progress and will be released soon.

* Official Site: https://flatcore.org
* License: GNU GENERAL PUBLIC LICENSE Version 3
Expand All @@ -13,6 +13,12 @@ flatCore is a lightweight Content Management System based on PHP and SQLite.
* https://flatcore.org/documentation/
* https://flatcore.org/de/dokumentation/

### Contribution

__You are very welcome to take part in this project.__ We are happy for every contribution. Please submit your code to the develop branch, and start a pull request.

This branch will be merged into master, as soon as a new stable version is ready.

#### 3rd Party Frameworks and Plugins

+ Medoo - https://github.com/catfan/Medoo
Expand Down
79 changes: 58 additions & 21 deletions acp/acp.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,79 @@
session_start();
error_reporting(0);

require '../lib/Medoo.php';
use Medoo\Medoo;

require '../config.php';
if(is_file('../'.FC_CONTENT_DIR.'/config.php')) {
include '../'.FC_CONTENT_DIR.'/config.php';
}
require '../lib/Medoo.php';
use Medoo\Medoo;


if(isset($fc_content_files) && is_array($fc_content_files)) {
/* switch database file $fc_db_content */
include 'core/contentSwitch.php';
if(is_file('../config_database.php')) {
include '../config_database.php';
$db_type = 'mysql';

$database = new Medoo([

'database_type' => 'mysql',
'database_name' => "$database_name",
'server' => "$database_host",
'username' => "$database_user",
'password' => "$database_psw",

'charset' => 'utf8',
'port' => $database_port,

'prefix' => DB_PREFIX
]);

$db_content = $database;
$db_user = $database;
$db_statistics = $database;



} else {
$db_type = 'sqlite';

if(isset($fc_content_files) && is_array($fc_content_files)) {
/* switch database file $fc_db_content */
include 'core/contentSwitch.php';
}


define("CONTENT_DB", "../$fc_db_content");
define("USER_DB", "../$fc_db_user");
define("STATS_DB", "../$fc_db_stats");

$db_content = new Medoo([
'database_type' => 'sqlite',
'database_file' => CONTENT_DB
]);

$db_user = new Medoo([
'database_type' => 'sqlite',
'database_file' => USER_DB
]);

$db_statistics = new Medoo([
'database_type' => 'sqlite',
'database_file' => STATS_DB
]);

}

define("CONTENT_DB", "../$fc_db_content");
define("USER_DB", "../$fc_db_user");
define("STATS_DB", "../$fc_db_stats");



define("INDEX_DB", "../$fc_db_index");
define("FC_ROOT", str_replace("/acp","",FC_INC_DIR));
define("IMAGES_FOLDER", "$img_path");
define("FILES_FOLDER", "$files_path");
define("FC_SOURCE", "backend");

$db_content = new Medoo([
'database_type' => 'sqlite',
'database_file' => CONTENT_DB
]);

$db_user = new Medoo([
'database_type' => 'sqlite',
'database_file' => USER_DB
]);

$db_statistics = new Medoo([
'database_type' => 'sqlite',
'database_file' => STATS_DB
]);

require 'core/access.php';
include 'versions.php';
Expand Down
56 changes: 54 additions & 2 deletions acp/core/ajax.media.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,65 @@
session_start();
error_reporting(0);

require '../../lib/Medoo.php';
use Medoo\Medoo;

require '../../config.php';

define("CONTENT_DB", "../../$fc_db_content");

if(is_file('../../config_database.php')) {
include '../../config_database.php';
$db_type = 'mysql';

$database = new Medoo([

'database_type' => 'mysql',
'database_name' => "$database_name",
'server' => "$database_host",
'username' => "$database_user",
'password' => "$database_psw",

'charset' => 'utf8',
'port' => $database_port,

'prefix' => DB_PREFIX
]);

$db_content = $database;
$db_user = $database;
$db_statistics = $database;



} else {
$db_type = 'sqlite';

if(isset($fc_content_files) && is_array($fc_content_files)) {
/* switch database file $fc_db_content */
include 'core/contentSwitch.php';
}


define("CONTENT_DB", "../../$fc_db_content");

$db_content = new Medoo([
'database_type' => 'sqlite',
'database_file' => CONTENT_DB
]);


}





define("FC_ROOT", str_replace("/acp","",FC_INC_DIR));
define("IMAGES_FOLDER", "../$img_path");
define("FILES_FOLDER", "../$files_path");
define("FC_SOURCE", "backend");



require_once 'access.php';
require_once 'functions.php';
Expand Down Expand Up @@ -67,7 +120,6 @@

$media_data = fc_get_media_data($realpath,$set_lang);


$form_tpl = str_replace('{form_action}', "#", $form_tpl);
$form_tpl = str_replace('{filename}', $media_filename, $form_tpl);
$form_tpl = str_replace('{file}', $media_filename, $form_tpl);
Expand Down
16 changes: 15 additions & 1 deletion acp/core/dashboard.checks.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@
'../'.FC_CONTENT_DIR.'/SQLite/',
'../'.FC_CONTENT_DIR.'/SQLite/content.sqlite3',
'../'.FC_CONTENT_DIR.'/SQLite/flatTracker.sqlite3',
'../'.FC_CONTENT_DIR.'/SQLite/user.sqlite3'
'../'.FC_CONTENT_DIR.'/SQLite/user.sqlite3',
'../'.FC_CONTENT_DIR.'/SQLite/index.sqlite3'
);

foreach($writable_items as $f) {
Expand All @@ -37,6 +38,19 @@
continue;
}

if($db_type !== 'sqlite') {
if($f == '../'.FC_CONTENT_DIR.'/SQLite/content.sqlite3') {
continue;
}
if($f == '../'.FC_CONTENT_DIR.'/SQLite/flatTracker.sqlite3') {
continue;
}
if($f == '../'.FC_CONTENT_DIR.'/SQLite/user.sqlite3') {
continue;
}
}


if(!is_writable($f)) {
echo '<div class="alert alert-danger">'.$lang['alert_not_writable'].' <strong>'.$f.'</strong></div>';
}
Expand Down
1 change: 1 addition & 0 deletions acp/core/dashboard.system.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
echo '<div class="tab-pane fade" id="config">';
echo '<table class="table table-sm">';
echo '<tr><td>Server:</td><td>' . $_SERVER['SERVER_NAME'] . ' (PHP '.phpversion().')</td></tr>';
echo '<tr><td>Database:</td><td>'.$db_type.'</td></tr>';
echo '<tr><td>'.$lang['prefs_cms_domain'].'</td><td>' . $prefs_cms_domain . '</td></tr>';
echo '<tr><td>'.$lang['prefs_cms_ssl_domain'].'</td><td>' . $prefs_cms_ssl_domain . '</td></tr>';
echo '<tr><td>'.$lang['prefs_cms_base'].'</td><td>' . $prefs_cms_base . '</td></tr>';
Expand Down
21 changes: 9 additions & 12 deletions acp/core/files.browser.php
Original file line number Diff line number Diff line change
Expand Up @@ -393,14 +393,17 @@ function delete_folder($dir) {
$_SESSION['media_filter_string'] = $add_keyword_filter;
}

$dbh = new PDO("sqlite:".CONTENT_DB);
//$dbh = new PDO("sqlite:".CONTENT_DB);

$sql_cnt = "SELECT count(*) AS 'all' FROM fc_media WHERE media_file LIKE '%$disk%' AND (media_lang LIKE '$languagePack' OR media_lang IS NULL) ".$_SESSION['media_filter_string'];
$sth = $dbh->prepare($sql_cnt);
$sth->execute();
$all_files = $sth->fetch();
//$sth = $dbh->prepare($sql_cnt);
//$sth->execute();
//$all_files = $sth->fetch();
$all_files = $db_content->query($sql_cnt)->fetch();
$nbr_of_files = $all_files['all'];



$files_per_page = 36;
$show_numbers = 9;
$start = 0;
Expand Down Expand Up @@ -433,21 +436,15 @@ function delete_folder($dir) {
$where_sql .= " (media_file like '%$disk%')";
$where_sql .= " AND (media_lang LIKE '$languagePack' OR media_lang IS NULL)";

$limit_sql = "LIMIT '$start','$files_per_page' ";
$limit_sql = "LIMIT $start,$files_per_page ";


$sql = "SELECT * FROM fc_media $where_sql ".$_SESSION['media_filter_string']." $order_sql $limit_sql";
$sth = $dbh->prepare($sql);
$sth->execute();
$get_files = $sth->fetchAll(PDO::FETCH_ASSOC);

$dbh = null;
$get_files = $db_content->query($sql)->fetchAll(PDO::FETCH_ASSOC);

$cnt_pages = ceil($nbr_of_files/$files_per_page);

$cnt_get_files = count($get_files);


$pag_backlink = '<a class="btn btn-fc '.$disable_prev_start.'" href="acp.php?tn=filebrowser&start='.$prev_start.'">'.$icon['angle_double_left'].'</a>';
$pag_forwardlink = '<a class="btn btn-fc '.$disable_next_start.'" href="acp.php?tn=filebrowser&start='.$next_start.'">'.$icon['angle_double_right'].'</a>';

Expand Down
79 changes: 68 additions & 11 deletions acp/core/files.upload-script.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,63 @@
session_start();
error_reporting(0);

require '../../config.php';
define("CONTENT_DB", "../../$fc_db_content");
require '../../lib/Medoo.php';
use Medoo\Medoo;

if($_SESSION['user_class'] != "administrator"){
header("location:../index.php");
die("PERMISSION DENIED!");
}

require '../../config.php';
if(is_file('../../'.FC_CONTENT_DIR.'/config.php')) {
include '../../'.FC_CONTENT_DIR.'/config.php';
}

if(is_file('../../config_database.php')) {
include '../../config_database.php';
$db_type = 'mysql';

$database = new Medoo([

'database_type' => 'mysql',
'database_name' => "$database_name",
'server' => "$database_host",
'username' => "$database_user",
'password' => "$database_psw",

'charset' => 'utf8',
'port' => $database_port,

'prefix' => DB_PREFIX
]);

$db_content = $database;
$db_user = $database;
$db_statistics = $database;



} else {
$db_type = 'sqlite';

if(isset($fc_content_files) && is_array($fc_content_files)) {
/* switch database file $fc_db_content */
include 'core/contentSwitch.php';
}


define("CONTENT_DB", "../../$fc_db_content");

$db_content = new Medoo([
'database_type' => 'sqlite',
'database_file' => CONTENT_DB
]);
}




if($_POST['csrf_token'] !== $_SESSION['token']) {
die('Error: CSRF Token is invalid');
}
Expand Down Expand Up @@ -247,16 +296,24 @@ function clean_filename($prefix,$suffix) {


function fc_write_media_data_name($filename,$filesize,$time,$mediatype) {

global $db_content;
global $languagePack;

$filename = substr($filename, 3,strlen($filename));
$dbh = new PDO("sqlite:".CONTENT_DB);
$sql = "INSERT INTO fc_media ( media_id, media_file, media_filesize, media_lastedit, media_type ) VALUES ( NULL, :media_file, :media_filesize, :media_lastedit, :media_type ) ";
$sth = $dbh->prepare($sql);
$sth->bindParam(':media_file', $filename, PDO::PARAM_STR);
$sth->bindParam(':media_filesize', $filesize, PDO::PARAM_STR);
$sth->bindParam(':media_lastedit', $time, PDO::PARAM_STR);
$sth->bindParam(':media_type', $mediatype, PDO::PARAM_STR);
$cnt_changes = $sth->execute();
$dbh = null;

$columns = [
"media_file" => "$filename",
"media_filesize" => "$filesize",
"media_lastedit" => "$time",
"media_type" => "$mediatype",
"media_lang" => "$languagePack"
];

$cnt_changes = $db_content->insert("fc_media", $columns);



}

?>
Loading

0 comments on commit 259f3a2

Please sign in to comment.