Update
This commit is contained in:
+6
-6
@@ -7,16 +7,16 @@
|
|||||||
const BLOG_RAN = true;
|
const BLOG_RAN = true;
|
||||||
|
|
||||||
// Tytuł bloga
|
// Tytuł bloga
|
||||||
const BLOG_TITLE = "nowy blog";
|
const BLOG_TITLE = "Nowy blog";
|
||||||
|
|
||||||
// Opis bloga
|
// Opis bloga
|
||||||
const BLOG_DESC = "o niczym";
|
const BLOG_DESC = "Jest to nowy blog";
|
||||||
|
|
||||||
// Autor bloga/Nazwa wyświetlana dla głównego administratora bloga
|
// Autor bloga/Nazwa wyświetlana dla głównego administratora bloga
|
||||||
const BLOG_AUTHOR = "Krzysiek Smaga";
|
const BLOG_AUTHOR = "Krzysztof Smaga";
|
||||||
|
|
||||||
// Tagi bloga
|
// Tagi bloga
|
||||||
const BLOG_TAGS = "asdf, sadf, wr";
|
const BLOG_TAGS = "nowy, blog, zero";
|
||||||
|
|
||||||
// Domena bloga
|
// Domena bloga
|
||||||
const BLOG_DOMAIN = "http://localhost";
|
const BLOG_DOMAIN = "http://localhost";
|
||||||
@@ -38,7 +38,7 @@
|
|||||||
const DB_PASS = "";
|
const DB_PASS = "";
|
||||||
|
|
||||||
// Baza danych dla bloga
|
// Baza danych dla bloga
|
||||||
const DB_NAME = "blog_now";
|
const DB_NAME = "blogengine";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* KONFIGURACJA NARZĘDZIA SERWEROWEGO
|
* KONFIGURACJA NARZĘDZIA SERWEROWEGO
|
||||||
@@ -81,4 +81,4 @@
|
|||||||
const MAIL_PORT = "";
|
const MAIL_PORT = "";
|
||||||
|
|
||||||
// Wymaga SSL'a
|
// Wymaga SSL'a
|
||||||
const MAIL_SSL = 0;
|
const MAIL_SSL = 1;
|
||||||
+1
-1
@@ -11,7 +11,7 @@
|
|||||||
if(!isset($_SESSION['uToken_BE']))
|
if(!isset($_SESSION['uToken_BE']))
|
||||||
header("location: be_login.php");
|
header("location: be_login.php");
|
||||||
|
|
||||||
$site = ($_GET['s'] ?? "home");
|
$site = ($_GET['s'] ?? "_home");
|
||||||
|
|
||||||
$elements = array();
|
$elements = array();
|
||||||
$dashboard_tabs_dir = "vendor/blog-engine/php/Dashboard/Tabs";
|
$dashboard_tabs_dir = "vendor/blog-engine/php/Dashboard/Tabs";
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
$postcon->CreatePost($_POST['title'], $_POST['content'], $_POST['name'], $_POST['tags'], $_POST['comments_status'], (isset($_POST['now_time']) ? true : $_POST['add_time']), "public");
|
$postcon->CreatePost($_POST['title'], $_POST['content'], $_POST['name'], $_POST['tags'], $_POST['comments_status'], (isset($_POST['now_time']) ? true : $_POST['add_time']), "public");
|
||||||
|
|
||||||
if(isset($_POST['draft']))
|
if(isset($_POST['draft']))
|
||||||
$postcon->DraftPost($_POST['draft'], $_POST['title'], $_POST['content'], $_POST['name'], $_POST['tags'], $_POST['comments_status']);
|
$postcon->DraftPost($_POST['draft'], $_POST['title'], $_POST['content'], $_POST['name'], $_POST['tags'], $_POST['comments_status'], (isset($_POST['now_time']) ? true : $_POST['add_time']));
|
||||||
|
|
||||||
if(isset($_POST['delete']))
|
if(isset($_POST['delete']))
|
||||||
$postcon->DeletePost($_POST['delete']);
|
$postcon->DeletePost($_POST['delete']);
|
||||||
|
|||||||
+8
-8
@@ -99,18 +99,18 @@
|
|||||||
if(pathinfo($file, PATHINFO_EXTENSION) == "html") {
|
if(pathinfo($file, PATHINFO_EXTENSION) == "html") {
|
||||||
$name = basename($file);
|
$name = basename($file);
|
||||||
$site = file_get_contents($file);
|
$site = file_get_contents($file);
|
||||||
foreach (array_keys($this->dictionary->page_tags) as $page_tag) {
|
foreach (array_keys($this->dictionary->PageTags()) as $page_tag) {
|
||||||
if ($page_tag == "{CSS}") {
|
if ($page_tag == "{CSS}") {
|
||||||
for ($j = 2; $j < count($this->csss); $j++)
|
for ($j = 2; $j < count($this->csss); $j++)
|
||||||
$this->dictionary->page_tags[$page_tag] .= "\n <link rel='stylesheet' href='$folder/css/{$this->csss[$j]}?v{$this->version}' />";
|
$this->dictionary->PageTags()[$page_tag] .= "\n <link rel='stylesheet' href='$folder/css/{$this->csss[$j]}?v{$this->version}' />";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($page_tag == "{JS}") {
|
if ($page_tag == "{JS}") {
|
||||||
for ($j = 2; $j < count($this->jss); $j++)
|
for ($j = 2; $j < count($this->jss); $j++)
|
||||||
$this->dictionary->page_tags[$page_tag] .= "\n <script src='$folder/js/{$this->jss[$j]}?v{$this->version}'></script>";
|
$this->dictionary->PageTags()[$page_tag] .= "\n <script src='$folder/js/{$this->jss[$j]}?v{$this->version}'></script>";
|
||||||
}
|
}
|
||||||
|
|
||||||
$site = str_replace($page_tag, $this->dictionary->page_tags[$page_tag], $site);
|
$site = str_replace($page_tag, $this->dictionary->PageTags()[$page_tag], $site);
|
||||||
}
|
}
|
||||||
|
|
||||||
$site = str_replace("<body>", "<body>\n<?php echo \$topbar; ?>", $site);
|
$site = str_replace("<body>", "<body>\n<?php echo \$topbar; ?>", $site);
|
||||||
@@ -174,21 +174,21 @@
|
|||||||
switch($type){
|
switch($type){
|
||||||
case "dev":
|
case "dev":
|
||||||
foreach ($json["dev"]["css"] as $css){
|
foreach ($json["dev"]["css"] as $css){
|
||||||
$this->dictionary->page_tags["{CSS}"] .= "\n <link rel='stylesheet' href='$css' />";
|
$this->dictionary->PageTags()["{CSS}"] .= "\n <link rel='stylesheet' href='$css' />";
|
||||||
echo "* Dodano '$css' do styli w '$type'!\n";
|
echo "* Dodano '$css' do styli w '$type'!\n";
|
||||||
}
|
}
|
||||||
foreach ($json["dev"]["js"] as $js){
|
foreach ($json["dev"]["js"] as $js){
|
||||||
$this->dictionary->page_tags["{JS}"] .= "\n <script src='$js'></script>";
|
$this->dictionary->PageTags()["{JS}"] .= "\n <script src='$js'></script>";
|
||||||
echo "* Dodano '$js' do skryptów w '$type'!\n";
|
echo "* Dodano '$js' do skryptów w '$type'!\n";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "pub":
|
case "pub":
|
||||||
foreach ($json["pub"]["css"] as $css){
|
foreach ($json["pub"]["css"] as $css){
|
||||||
$this->dictionary->page_tags["{CSS}"] .= "\n <link rel='stylesheet' href='$css' />";
|
$this->dictionary->PageTags()["{CSS}"] .= "\n <link rel='stylesheet' href='$css' />";
|
||||||
echo "* Dodano '$css' do styli w '$type'!\n";
|
echo "* Dodano '$css' do styli w '$type'!\n";
|
||||||
}
|
}
|
||||||
foreach ($json["pub"]["js"] as $js){
|
foreach ($json["pub"]["js"] as $js){
|
||||||
$this->dictionary->page_tags["{JS}"] .= "\n <script src='$js'></script>";
|
$this->dictionary->PageTags()["{JS}"] .= "\n <script src='$js'></script>";
|
||||||
echo "* Dodano '$js' do skryptów w '$type'!\n";
|
echo "* Dodano '$js' do skryptów w '$type'!\n";
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
+6
-11
@@ -2,23 +2,18 @@
|
|||||||
<html lang="pl">
|
<html lang="pl">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Witaj świecie! - Kwiatowy Blog</title>
|
<title>Witaj świecie! - Nowy blog</title>
|
||||||
|
|
||||||
<link rel='stylesheet' href='vendor/blog-engine/blog.css' />
|
|
||||||
<link rel='stylesheet' href='dev/css/style.css?v3.2' />
|
|
||||||
|
|
||||||
<meta name="author" content="Krzysiek Smaga">
|
<meta name="author" content="Krzysztof Smaga">
|
||||||
<meta name="keywords" content="nowy, pierwszy, super">
|
<meta name="keywords" content="nowy, blog, zero">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php (isset($_SESSION['uToken_BE'])?include $topbar:""); ?>
|
<?php echo $topbar; ?>
|
||||||
<h1>Kwiatowy Blog</h1>
|
<h1>Nowy blog</h1>
|
||||||
<p>dsfsadf</p>
|
<p>Jest to nowy blog</p>
|
||||||
<a href="be_login.php">Zaloguj się do panelu</a>
|
<a href="be_login.php">Zaloguj się do panelu</a>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script src='vendor/blog-engine/blog.js'></script>
|
|
||||||
<script src='vendor/blog-engine/js/jquery-3.7.0.min.js'></script>
|
|
||||||
<script src='dev/js/script.js?v3.2'></script>
|
|
||||||
</html>
|
</html>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>{POST_TITLE} - Nowy blog</title>
|
||||||
|
|
||||||
|
|
||||||
|
<meta name="author" content="Krzysztof Smaga">
|
||||||
|
<meta name="keywords" content="nowy, blog, zero">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<?php echo $topbar; ?>
|
||||||
|
<h1>Nowy blog</h1>
|
||||||
|
<p>Jest to nowy blog</p>
|
||||||
|
|
||||||
|
<h3>{POST_TITLE}</h3>
|
||||||
|
<h5>Dodano {POST_ADDED} przez {POST_AUTHOR}</h5>
|
||||||
|
<p>{POST_CONTENT}</p>
|
||||||
|
<p>{POST_VIEWS}</p>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
@@ -3,10 +3,42 @@
|
|||||||
require "vendor/blog-engine/php/Authentication/AuthController.php";
|
require "vendor/blog-engine/php/Authentication/AuthController.php";
|
||||||
require "vendor/blog-engine/php/Posts/PostController.php";
|
require "vendor/blog-engine/php/Posts/PostController.php";
|
||||||
|
|
||||||
use BlogEngine\Posts\PostController;
|
|
||||||
use BlogEngine\Authentication\AuthController;
|
use BlogEngine\Authentication\AuthController;
|
||||||
|
use BlogEngine\Posts\PostController;
|
||||||
|
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
$auth = new AuthController();
|
$auth = new AuthController();
|
||||||
$conn = $auth->Connection();
|
$site = "";
|
||||||
|
|
||||||
|
if(file_exists("_config.php")){
|
||||||
|
$topbar = "";
|
||||||
|
if($_SERVER['SERVER_PORT'] == DEV_PORT) {
|
||||||
|
if(isset($_SESSION['uToken_BE'])){
|
||||||
|
if($auth->CheckRole($_SESSION['uToken_BE']) == "administrator")
|
||||||
|
require "vendor/blog-engine/php/Sites/Views/be-topbar.php";
|
||||||
|
}
|
||||||
|
$site = file_get_contents("dev/post.html");
|
||||||
|
} else if($_SERVER['SERVER_PORT'] == PUB_PORT) {
|
||||||
|
if(isset($_SESSION['uToken_BE'])){
|
||||||
|
if($auth->CheckRole($_SESSION['uToken_BE']) == "administrator")
|
||||||
|
require "vendor/blog-engine/php/Sites/Views/be-topbar.php";
|
||||||
|
}
|
||||||
|
$site = file_get_contents("public/post.html");
|
||||||
|
} else
|
||||||
|
echo "<h1>Uruchom ponownie serwer</h1>";
|
||||||
|
} else
|
||||||
|
require "be_firstrun.php";
|
||||||
|
|
||||||
|
if(isset($_GET['id'])){
|
||||||
|
$post = new PostController($auth);
|
||||||
|
$data = $post->DownloadSinglePost($_GET['id']);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
echo $post->ConvertToSite($data, $site);
|
||||||
|
print_r($data);
|
||||||
|
} else {
|
||||||
|
header("location: index.php?no_post");
|
||||||
|
}
|
||||||
|
?>
|
||||||
+8
-8
@@ -2,23 +2,23 @@
|
|||||||
<html lang="pl">
|
<html lang="pl">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Witaj świecie! - Kwiatowy Blog</title>
|
<title>Witaj świecie! - Nowy blog</title>
|
||||||
|
|
||||||
<link rel='stylesheet' href='vendor/blog-engine/blog.css' />
|
<link rel='stylesheet' href='vendor/blog-engine/blog.css' />
|
||||||
<link rel='stylesheet' href='public/css/style.css?v3.1' />
|
<link rel='stylesheet' href='public/css/style.css?v4.3' />
|
||||||
|
|
||||||
<meta name="author" content="Krzysiek Smaga">
|
<meta name="author" content="Krzysztof Smaga">
|
||||||
<meta name="keywords" content="nowy, pierwszy, super">
|
<meta name="keywords" content="nowy, blog, zero">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<?php include $topbar; ?>
|
<?php echo $topbar; ?>
|
||||||
<h1>Kwiatowy Blog</h1>
|
<h1>Nowy blog</h1>
|
||||||
<p>dsfsadf</p>
|
<p>Jest to nowy blog</p>
|
||||||
<a href="be_login.php">Zaloguj się do panelu</a>
|
<a href="be_login.php">Zaloguj się do panelu</a>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script src='vendor/blog-engine/blog.js'></script>
|
<script src='vendor/blog-engine/blog.js'></script>
|
||||||
<script src='vendor/blog-engine/js/jquery-3.7.0.min.js'></script>
|
<script src='vendor/blog-engine/js/jquery-3.7.0.min.js'></script>
|
||||||
<script src='public/js/script.js?v3.1'></script>
|
<script src='public/js/script.js?v4.3'></script>
|
||||||
</html>
|
</html>
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>{POST_TITLE} - Nowy blog</title>
|
||||||
|
|
||||||
|
<link rel='stylesheet' href='vendor/blog-engine/blog.css' />
|
||||||
|
<link rel='stylesheet' href='public/css/style.css?v4.3' />
|
||||||
|
<link rel='stylesheet' href='public/css/style.css?v4.3' />
|
||||||
|
|
||||||
|
<meta name="author" content="Krzysztof Smaga">
|
||||||
|
<meta name="keywords" content="nowy, blog, zero">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<?php echo $topbar; ?>
|
||||||
|
<h1>Nowy blog</h1>
|
||||||
|
<p>Jest to nowy blog</p>
|
||||||
|
|
||||||
|
<h3>{POST_TITLE}</h3>
|
||||||
|
<h5>{POST_INFORMATION}</h5>
|
||||||
|
<p>{POST_CONTENT}</p>
|
||||||
|
<p>{POST_VIEWS}</p>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<script src='vendor/blog-engine/blog.js'></script>
|
||||||
|
<script src='vendor/blog-engine/js/jquery-3.7.0.min.js'></script>
|
||||||
|
<script src='public/js/script.js?v4.3'></script>
|
||||||
|
<script src='public/js/script.js?v4.3'></script>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>{POST_TITLE} - {TITLE}</title>
|
||||||
|
{CSS}
|
||||||
|
{FAVICON}
|
||||||
|
<meta name="author" content="{AUTHOR}">
|
||||||
|
<meta name="keywords" content="{KEYWORDS}">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>{TITLE}</h1>
|
||||||
|
<p>{DESCRIPTION}</p>
|
||||||
|
|
||||||
|
<h3>{POST_TITLE}</h3>
|
||||||
|
<h5>Dodano {POST_ADDED} przez {POST_AUTHOR}</h5>
|
||||||
|
<p>{POST_CONTENT}</p>
|
||||||
|
<p>{POST_VIEWS}</p>
|
||||||
|
</body>
|
||||||
|
{JS}
|
||||||
|
</html>
|
||||||
Vendored
+1
-1
@@ -51,7 +51,7 @@
|
|||||||
<form method='POST' action='blog_panel/be_post.php'>
|
<form method='POST' action='blog_panel/be_post.php'>
|
||||||
<button class='btn btn-primary ms-2' type='submit' name='edit' value='{$post['ID']}'>Edytuj</button>
|
<button class='btn btn-primary ms-2' type='submit' name='edit' value='{$post['ID']}'>Edytuj</button>
|
||||||
</form>
|
</form>
|
||||||
<form method='POST' action='be_panel.php'>
|
<form method='POST' action='vendor/blog-engine/php/Posts/Calls/PostManagement.php'>
|
||||||
<div class='d-flex'>
|
<div class='d-flex'>
|
||||||
<button class='btn btn-primary ms-2' type='submit' name='see' value='{$post['ID']}'>Zobacz</button>
|
<button class='btn btn-primary ms-2' type='submit' name='see' value='{$post['ID']}'>Zobacz</button>
|
||||||
<button class='btn btn-danger ms-2' type='submit' name='delete' value='{$post['ID']}'>Usuń</button>
|
<button class='btn btn-danger ms-2' type='submit' name='delete' value='{$post['ID']}'>Usuń</button>
|
||||||
|
|||||||
+12
-2
@@ -18,10 +18,15 @@ namespace BlogEngine\Database {
|
|||||||
|
|
||||||
public function Close($conn) { mysqli_close($conn); }
|
public function Close($conn) { mysqli_close($conn); }
|
||||||
|
|
||||||
function Insert($into, $values){
|
function Insert($into, $values) : bool{
|
||||||
$conn = $this->Connection();
|
$conn = $this->Connection();
|
||||||
mysqli_query($conn, "INSERT INTO {$into} VALUES({$values})");
|
if(mysqli_query($conn, "INSERT INTO {$into} VALUES({$values})")){
|
||||||
$this->Close($conn);
|
$this->Close($conn);
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
$this->Close($conn);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function CreateTable($name, $columns){
|
function CreateTable($name, $columns){
|
||||||
@@ -194,5 +199,10 @@ namespace BlogEngine\Database {
|
|||||||
error_log("Nie ma dostępnego folderu \"Tables\". Zatrzymywanie tworzenia bazy!");
|
error_log("Nie ma dostępnego folderu \"Tables\". Zatrzymywanie tworzenia bazy!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function Log($content, $log_level = 'Information', $id_user = null){
|
||||||
|
$ip_address = file_get_contents("https://api.ipify.org");
|
||||||
|
$this->Insert("logs(ip_address, content, log_level, created_by)", "'$ip_address', '$content', '$log_level', $id_user");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -419,5 +419,61 @@
|
|||||||
"is_string": false
|
"is_string": false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
],
|
||||||
|
"logs": [
|
||||||
|
{
|
||||||
|
"column_name": "id_log",
|
||||||
|
"datatype": "INT",
|
||||||
|
"primary_key": true,
|
||||||
|
"auto_increment": true,
|
||||||
|
"not_null": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"column_name": "ip_address",
|
||||||
|
"datatype": "VARCHAR",
|
||||||
|
"length": 15,
|
||||||
|
"not_null": true,
|
||||||
|
"default": {
|
||||||
|
"value": "127.0.0.1",
|
||||||
|
"is_string": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"column_name": "content",
|
||||||
|
"datatype": "TEXT",
|
||||||
|
"not_null": true,
|
||||||
|
"default": {
|
||||||
|
"value": "Some unknown error",
|
||||||
|
"is_string": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"column_name": "log_level",
|
||||||
|
"datatype": "ENUM",
|
||||||
|
"enum_data": ["Debug", "Information", "Warning", "Error", "Critical"],
|
||||||
|
"not_null": true,
|
||||||
|
"default": {
|
||||||
|
"value": "Warning",
|
||||||
|
"is_string": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"column_name": "created_at",
|
||||||
|
"datatype": "DATETIME",
|
||||||
|
"not_null": true,
|
||||||
|
"default": {
|
||||||
|
"value": "NOW()",
|
||||||
|
"is_string": false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"column_name": "created_by",
|
||||||
|
"datatype": "INT",
|
||||||
|
"not_null": false,
|
||||||
|
"foreign_key": {
|
||||||
|
"references": "users",
|
||||||
|
"column": "id_user"
|
||||||
|
}
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
+15
-1
@@ -1,8 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace BlogEngine {
|
namespace BlogEngine {
|
||||||
|
if(!defined("BLOG_TITLE"))
|
||||||
require "_config.php";
|
require "_config.php";
|
||||||
|
|
||||||
class Dictionary {
|
class Dictionary {
|
||||||
public $page_tags = [
|
public function PageTags() : array {
|
||||||
|
return [
|
||||||
"{POSTS}" => "",
|
"{POSTS}" => "",
|
||||||
"{LINKS}" => "",
|
"{LINKS}" => "",
|
||||||
"{FAVICON}" => (BLOG_ICON != ""?"<link rel='icon' type='image/png' href='" . BLOG_ICON . "' sizes='any'>":""),
|
"{FAVICON}" => (BLOG_ICON != ""?"<link rel='icon' type='image/png' href='" . BLOG_ICON . "' sizes='any'>":""),
|
||||||
@@ -14,4 +17,15 @@ namespace BlogEngine {
|
|||||||
"{CSS}" => ""
|
"{CSS}" => ""
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function BlogTags() : array {
|
||||||
|
return [
|
||||||
|
"{POST_TITLE}" => "title",
|
||||||
|
"{POST_AUTHOR}" => "author",
|
||||||
|
"{POST_CONTENT}" => "content",
|
||||||
|
"{POST_ADDED}" => "added_at",
|
||||||
|
"{POST_VIEWS}" => "views"
|
||||||
|
];
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,26 @@
|
|||||||
|
<?php
|
||||||
|
require "../../../../../_config.php";
|
||||||
|
require "../../Authentication/AuthController.php";
|
||||||
|
require "../PostController.php";
|
||||||
|
|
||||||
|
use BlogEngine\Posts\PostController;
|
||||||
|
use BlogEngine\Authentication\AuthController;
|
||||||
|
|
||||||
|
session_start();
|
||||||
|
|
||||||
|
$auth = new AuthController();
|
||||||
|
$conn = $auth->Connection();
|
||||||
|
|
||||||
|
$postcon = new PostController($auth);
|
||||||
|
|
||||||
|
if(isset($_POST['see'])){
|
||||||
|
header("location: /post.php?id={$_POST['see']}");
|
||||||
|
}
|
||||||
|
|
||||||
|
if(isset($_POST['delete'])){
|
||||||
|
if($postcon->DeletePost($_POST['delete'])){
|
||||||
|
header("location: /be_panel.php?s=posts");
|
||||||
|
$auth->Log("Usunięto post o ID: {$_POST['delete']}", "Information", $auth->GetID($_SESSION['uToken_BE']));
|
||||||
|
} else
|
||||||
|
$auth->Log("Nie udało się usunąć posta o ID: {$_POST['delete']}.", "Error", $auth->GetID($_SESSION['uToken_BE']));
|
||||||
|
}
|
||||||
+51
-4
@@ -29,7 +29,7 @@ namespace BlogEngine\Posts {
|
|||||||
header("location: ../../../be_panel.php?s=posts");
|
header("location: ../../../be_panel.php?s=posts");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function DraftPost($id = 0, $title = '', $content = '', $name = '', $tags = [], $commentStatus = ''){
|
public function DraftPost($id = 0, $title = '', $content = '', $name = '', $tags = [], $commentStatus = '', $add_time = true){
|
||||||
$srv = $this->auth->Connection();
|
$srv = $this->auth->Connection();
|
||||||
|
|
||||||
$date = (is_bool($add_time)?"NOW":Date("'Y-m-d H:i:s'", strtotime($add_time)));
|
$date = (is_bool($add_time)?"NOW":Date("'Y-m-d H:i:s'", strtotime($add_time)));
|
||||||
@@ -38,7 +38,7 @@ namespace BlogEngine\Posts {
|
|||||||
if($id == 0){
|
if($id == 0){
|
||||||
$id = mysqli_fetch_row(mysqli_query($srv, "SELECT MAX(id_post) FROM posts;"))[0] + 1;
|
$id = mysqli_fetch_row(mysqli_query($srv, "SELECT MAX(id_post) FROM posts;"))[0] + 1;
|
||||||
|
|
||||||
$insert_post = "INSERT INTO posts VALUES($last_id_post, $id_user, '$name', '$title', '$content', 'draft', '$commentStatus', 0, $date, null);";
|
$insert_post = "INSERT INTO posts VALUES($id, $id_user, '$name', '$title', '$content', 'draft', '$commentStatus', 0, NOW(), null);";
|
||||||
mysqli_query($srv, $insert_post);
|
mysqli_query($srv, $insert_post);
|
||||||
|
|
||||||
foreach ($tags as $tag){
|
foreach ($tags as $tag){
|
||||||
@@ -104,7 +104,7 @@ namespace BlogEngine\Posts {
|
|||||||
return $response;
|
return $response;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function DownloadPost($year, $month, $date, $name) : array {
|
public function DownloadPost($year, $month, $day, $name) : array {
|
||||||
$srv = $this->auth->Connection();
|
$srv = $this->auth->Connection();
|
||||||
$post = array();
|
$post = array();
|
||||||
|
|
||||||
@@ -133,7 +133,54 @@ namespace BlogEngine\Posts {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return post;
|
return $post;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function DownloadSinglePost($id) {
|
||||||
|
$srv = $this->auth->Connection();
|
||||||
|
$post = [];
|
||||||
|
|
||||||
|
$get_post = "SELECT users.display_name AS autor, posts.title AS tytul, posts.content AS tresc, posts.views AS wyswietlenia, posts.added_at AS dodano, (SELECT GROUP_CONCAT(CONCAT(comments.author, ';;', comments.content, ';;', comments.added_at)) FROM comments WHERE comments.id_post = posts.id_post GROUP BY comments.id_comment) AS komentarze FROM posts, users WHERE users.id_user = posts.id_user AND id_post ={$id};";
|
||||||
|
$res_post = mysqli_query($srv, $get_post);
|
||||||
|
|
||||||
|
if($row = mysqli_fetch_row($res_post)){
|
||||||
|
$post = [
|
||||||
|
"author" => $row[0],
|
||||||
|
"title" => $row[1],
|
||||||
|
"content" => $row[2],
|
||||||
|
"views" => $row[3],
|
||||||
|
"added_at" => $row[4],
|
||||||
|
"comments" => array()
|
||||||
|
];
|
||||||
|
|
||||||
|
if($row[5] != ""){
|
||||||
|
$comments = mb_split("||||", $row[5]);
|
||||||
|
|
||||||
|
foreach($comments as $comment){
|
||||||
|
$data = mb_split(";;", $comment);
|
||||||
|
array_push($post[0]["Komentarze"], [
|
||||||
|
"Autor" => $data[0],
|
||||||
|
"Tresc" => $data[1],
|
||||||
|
"Dodano" => $data[2]
|
||||||
|
]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->auth->Close($srv);
|
||||||
|
return $post;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function ConvertToSite($data, $site) : string{
|
||||||
|
require "vendor/blog-engine/php/Dictionary.php";
|
||||||
|
$dictionary = new \BlogEngine\Dictionary;
|
||||||
|
|
||||||
|
foreach(array_keys($dictionary->BlogTags()) as $tag){
|
||||||
|
$site = str_replace($tag, $data[$dictionary->BlogTags()[$tag]], $site);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $site;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user