Praca, praca
Took 5 hours 39 minutes
This commit is contained in:
+14
-7
@@ -10,22 +10,19 @@
|
|||||||
const BLOG_TITLE = "Kwiatowy Blog";
|
const BLOG_TITLE = "Kwiatowy Blog";
|
||||||
|
|
||||||
// Opis bloga
|
// Opis bloga
|
||||||
const BLOG_DESC = "sdf";
|
const BLOG_DESC = "ef";
|
||||||
|
|
||||||
// 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 = "Krzysiek Smaga";
|
||||||
|
|
||||||
// Tagi bloga
|
// Tagi bloga
|
||||||
const BLOG_TAGS = "nowy, pierwszy, super";
|
const BLOG_TAGS = "kwiaty, rośliny";
|
||||||
|
|
||||||
// Domena bloga
|
// Domena bloga
|
||||||
const BLOG_DOMAIN = "http://localhost";
|
const BLOG_DOMAIN = "http://localhost";
|
||||||
|
|
||||||
// Ikona bloga (format .PNG)
|
// Ikona bloga (format .PNG)
|
||||||
const BLOG_ICON = "{BLOG_ICON}";
|
const BLOG_ICON = "";
|
||||||
|
|
||||||
// Nazwa pliku strony głównej
|
|
||||||
const BLOG_INDEX = "{BLOG_INDEX}";
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* KONFIGURACJA BAZY DANYCH
|
* KONFIGURACJA BAZY DANYCH
|
||||||
@@ -43,6 +40,16 @@
|
|||||||
// Baza danych dla bloga
|
// Baza danych dla bloga
|
||||||
const DB_NAME = "blog";
|
const DB_NAME = "blog";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* KONFIGURACJA NARZĘDZIA SERWEROWEGO
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Port, który ma używać PHP dla serwera publicznego
|
||||||
|
const PUB_PORT = "8085";
|
||||||
|
|
||||||
|
// Port, który ma używać PHP dla serwera deweloperskiego
|
||||||
|
const DEV_PORT = "8086";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* KONFIGURACJA KONTA ADMINISTRATORA
|
* KONFIGURACJA KONTA ADMINISTRATORA
|
||||||
*/
|
*/
|
||||||
@@ -51,7 +58,7 @@
|
|||||||
const ADMIN_USER = "admin";
|
const ADMIN_USER = "admin";
|
||||||
|
|
||||||
// Adres mailowy kontaktowy do głównego administratora bloga
|
// Adres mailowy kontaktowy do głównego administratora bloga
|
||||||
const ADMIN_EMAIL = "admin@blog.pl";
|
const ADMIN_EMAIL = "krzysiek-smaga@outlook.com";
|
||||||
|
|
||||||
// Hasło dla głównego administratora bloga
|
// Hasło dla głównego administratora bloga
|
||||||
const ADMIN_PASS = "root";
|
const ADMIN_PASS = "root";
|
||||||
|
|||||||
+18
-1
@@ -12,7 +12,7 @@
|
|||||||
<p>Jestem Twoim przyszłym blogiem! :D</p>
|
<p>Jestem Twoim przyszłym blogiem! :D</p>
|
||||||
<p>Ale zanim do tego dojdzie, skonfiguruj mnie. Przeprowadzę Cię przez proces konfiguracji mnie, dzięki któremu będę żył! Nie potrzeba poświęcać mi dużo czasu. Wystarczy dosłownie maks 5 minut.</p>
|
<p>Ale zanim do tego dojdzie, skonfiguruj mnie. Przeprowadzę Cię przez proces konfiguracji mnie, dzięki któremu będę żył! Nie potrzeba poświęcać mi dużo czasu. Wystarczy dosłownie maks 5 minut.</p>
|
||||||
<hr>
|
<hr>
|
||||||
<form method="POST" action="index.php">
|
<form method="POST" action="index.php" enctype="multipart/form-data">
|
||||||
<label class="form-label" for="BLOG_AUTHOR">Jak się nazywasz mój twórco?</label>
|
<label class="form-label" for="BLOG_AUTHOR">Jak się nazywasz mój twórco?</label>
|
||||||
<input class="form-control mb-3" type="text" name="BLOG_AUTHOR" placeholder="Jan Kowalski" required/>
|
<input class="form-control mb-3" type="text" name="BLOG_AUTHOR" placeholder="Jan Kowalski" required/>
|
||||||
<div id="config-blog">
|
<div id="config-blog">
|
||||||
@@ -27,6 +27,8 @@
|
|||||||
<input class="form-control mb-3" type="text" name="BLOG_TAGS" placeholder="kwiaty, rośliny, drzewa" required/>
|
<input class="form-control mb-3" type="text" name="BLOG_TAGS" placeholder="kwiaty, rośliny, drzewa" required/>
|
||||||
<label class="form-label" for="BLOG_DOMAIN">Domena bloga:</label>
|
<label class="form-label" for="BLOG_DOMAIN">Domena bloga:</label>
|
||||||
<input class="form-control mb-3" type="text" name="BLOG_DOMAIN" placeholder="https://kwiatowyblog.pl" />
|
<input class="form-control mb-3" type="text" name="BLOG_DOMAIN" placeholder="https://kwiatowyblog.pl" />
|
||||||
|
<label class="form-label" for="BLOG_ICON">Ikona bloga:</label>
|
||||||
|
<input class="form-control mb-3" type="file" name="BLOG_ICON" accept="image/png" />
|
||||||
</div>
|
</div>
|
||||||
<div id="config-db">
|
<div id="config-db">
|
||||||
<hr>
|
<hr>
|
||||||
@@ -49,6 +51,21 @@
|
|||||||
<button class="btn btn-primary mb-3" type="button" id="testConn">Testuj połączenie</button>
|
<button class="btn btn-primary mb-3" type="button" id="testConn">Testuj połączenie</button>
|
||||||
<p id="connStatus"></p>
|
<p id="connStatus"></p>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="config-dev">
|
||||||
|
<hr>
|
||||||
|
<h3>Konfiguracja narzędziowego</h3>
|
||||||
|
<p>Jeżeli chcesz korzystać z korzyści, jakie dają wbudowane narzędzia tego silnika, możesz ustawić pod siebie to, co chcesz. </p>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col">
|
||||||
|
<label class="form-label" for="PUB_PORT">Nazwa użytkownika:</label>
|
||||||
|
<input class="form-control mb-3" type="number" name="PUB_PORT" min="1" max="65535" placeholder="8080" value="8080" required>
|
||||||
|
</div>
|
||||||
|
<div class="col">
|
||||||
|
<label class="form-label" for="DEV_PORT">Hasło:</label>
|
||||||
|
<input class="form-control mb-3" type="number" name="DEV_PORT" min="1" max="65535" placeholder="8081" value="8081" required />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div id="config-admin">
|
<div id="config-admin">
|
||||||
<hr>
|
<hr>
|
||||||
<h3>Administrator bloga</h3>
|
<h3>Administrator bloga</h3>
|
||||||
|
|||||||
+1
-2
@@ -16,8 +16,7 @@
|
|||||||
header("location: be_panel.php");
|
header("location: be_panel.php");
|
||||||
else
|
else
|
||||||
header("location: index.php");
|
header("location: index.php");
|
||||||
} else
|
}
|
||||||
header("location: index.php");
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="pl">
|
<html lang="pl">
|
||||||
|
|||||||
+42
-1
@@ -1,5 +1,33 @@
|
|||||||
<?php
|
<?php
|
||||||
require "_config.php";
|
require "_config.php";
|
||||||
|
require "vendor/blog-engine/php/Authentication/AuthController.php";
|
||||||
|
use BlogEngine\Authentication\AuthController;
|
||||||
|
|
||||||
|
$auth = new AuthController();
|
||||||
|
$conn = $auth->Connection();
|
||||||
|
|
||||||
|
if(!isset($_COOKIE['uToken_BE']))
|
||||||
|
header("location: be_login.php");
|
||||||
|
|
||||||
|
$site = ($_POST['site'] ?? "home");
|
||||||
|
|
||||||
|
$elements = array();
|
||||||
|
$dashboard_tabs_dir = "vendor/blog-engine/php/Dashboard/Tabs";
|
||||||
|
$dashboard_tabs = scandir($dashboard_tabs_dir);
|
||||||
|
|
||||||
|
foreach ($dashboard_tabs as $dashboard_tab){
|
||||||
|
if(str_contains($dashboard_tab, ".php")) {
|
||||||
|
$file = "$dashboard_tabs_dir/$dashboard_tab";
|
||||||
|
$name = fgets(fopen($file, 'r'));
|
||||||
|
$name = substr($name, strlen("<!-- "), strlen($name) - (strlen("<!-- ") + strlen(" -->")));
|
||||||
|
$filename = basename($file, ".php");
|
||||||
|
|
||||||
|
array_push($elements, [
|
||||||
|
"Nazwa" => $name,
|
||||||
|
"Plik" => $filename
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="pl">
|
<html lang="pl">
|
||||||
@@ -10,6 +38,19 @@
|
|||||||
<script src="vendor/blog-engine/blog.js" defer></script>
|
<script src="vendor/blog-engine/blog.js" defer></script>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<h1 class="mt-3">Zarządzanie <?php echo BLOG_TITLE ?></h1>
|
||||||
|
<form method="POST" action="be_panel.php">
|
||||||
|
<ul class="nav nav-tabs mb-5">
|
||||||
|
<?php
|
||||||
|
foreach ($elements as $element){
|
||||||
|
$active = ($site == $element['Plik']?" active":"");
|
||||||
|
echo "<li class='nav-item'><button class='nav-link$active' name='site' value='{$element['Plik']}'>{$element['Nazwa']}</button></li>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</ul>
|
||||||
|
</form>
|
||||||
|
<?php include "$dashboard_tabs_dir/$site.php"; ?>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
<?php
|
||||||
|
require "../_config.php";
|
||||||
|
require "../vendor/blog-engine/php/Authentication/AuthController.php";
|
||||||
|
use BlogEngine\Authentication\AuthController;
|
||||||
|
|
||||||
|
$auth = new AuthController();
|
||||||
|
$conn = $auth->Connection();
|
||||||
|
|
||||||
|
$post = null;
|
||||||
|
if(isset($_POST['edit'])){
|
||||||
|
$get_post = "SELECT name, title, content, status, comments, added_at, updated_at FROM posts WHERE id_post = {$_POST['edit']}";
|
||||||
|
$res_post = mysqli_fetch_row(mysqli_query($conn, $get_post));
|
||||||
|
|
||||||
|
$post = [
|
||||||
|
"Nazwa" => $res_post[0],
|
||||||
|
"Tytuł" => $res_post[1],
|
||||||
|
"Treść" => $res_post[2],
|
||||||
|
"Status" => $res_post[3],
|
||||||
|
"Komentarze" => $res_post[4],
|
||||||
|
"Dodano" => $res_post[5],
|
||||||
|
"Zaktualizowano" => $res_post[6]
|
||||||
|
];
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="pl">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<title>Panel <?php echo BLOG_TITLE ?></title>
|
||||||
|
<link rel="stylesheet" href="../vendor/blog-engine/blog.css" />
|
||||||
|
<script src="../vendor/blog-engine/blog.js" defer></script>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container pt-3">
|
||||||
|
<h2 class="mb-5">Dodawanie posta</h2>
|
||||||
|
<form method="POST" action="be_post.php">
|
||||||
|
<div class="row mb-3">
|
||||||
|
<div class="col-md-8 d-grid">
|
||||||
|
<div class="form-floating">
|
||||||
|
<input type="text" class="form-control" id="title" name="title" placeholder="Tytuł posta" <?php if($post != null) echo "value='{$post['Tytuł']}'" ?>>
|
||||||
|
<label for="title">Tytuł posta</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4 d-grid">
|
||||||
|
<button type="submit" class="btn btn-lg btn-success" name="add">Dodaj posta</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<button type="button" id="bold_button" onclick="insertAtCursor(document.getElementById('editor'), '****', true)">Bold</button>
|
||||||
|
<button type="button" id="bold_button" onclick="insertAtCursor(document.getElementById('editor'), '**', true)">Italic</button>
|
||||||
|
<button type="button" id="bold_button" onclick="insertAtCursor(document.getElementById('editor'), '#######', true)">Header</button>
|
||||||
|
</div>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-8">
|
||||||
|
<div class="card p-3" contenteditable="true" id="editor" style="min-height: 100vh">
|
||||||
|
<?php if($post != null) echo $post['Treść'] ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col-md-4">
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
+157
-24
@@ -1,9 +1,12 @@
|
|||||||
<?php
|
<?php
|
||||||
require "vendor/blog-engine/php/Dictionary.php";
|
if(file_exists("_config.php")) {
|
||||||
|
require "vendor/blog-engine/php/Dictionary.php";
|
||||||
|
}
|
||||||
class CompileIt{
|
class CompileIt{
|
||||||
public \BlogEngine\Dictionary $dictionary;
|
public \BlogEngine\Dictionary $dictionary;
|
||||||
public function __construct(public $src = __DIR__ . "/src/", public $htmls = [], public $csss = [], public $jss = [], public $version = 0){
|
public function __construct(public $src = __DIR__ . "/src/", public $htmls = [], public $csss = [], public $jss = [], public float $version = 0){
|
||||||
$this->dictionary = new BlogEngine\Dictionary();
|
if(file_exists("_config.php"))
|
||||||
|
$this->dictionary = new BlogEngine\Dictionary();
|
||||||
|
|
||||||
// POBIERANIE ZAWARTOŚCI FOLDERU src
|
// POBIERANIE ZAWARTOŚCI FOLDERU src
|
||||||
$this->src = __DIR__ . "/src/";
|
$this->src = __DIR__ . "/src/";
|
||||||
@@ -11,28 +14,77 @@
|
|||||||
$this->csss = scandir($src . "css");
|
$this->csss = scandir($src . "css");
|
||||||
$this->jss = scandir($src . "js");
|
$this->jss = scandir($src . "js");
|
||||||
|
|
||||||
//$this->version =
|
$this->version = floatval(file_get_contents("version"));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function main() : void{
|
public function main($argv, $argc) : void{
|
||||||
$this->checkFolders();
|
if($argc > 1){
|
||||||
$this->compileFiles();
|
switch($argv[1]){
|
||||||
|
case "compile":
|
||||||
echo "Done";
|
if($argv[2] != null)
|
||||||
|
switch($argv[2]) {
|
||||||
|
case "dev":
|
||||||
|
echo "
|
||||||
|
==========================
|
||||||
|
= KOMPILOWANIE DO 'dev'
|
||||||
|
==========================
|
||||||
|
";
|
||||||
|
$this->versionUp("dev");
|
||||||
|
$this->addCustoms("dev");
|
||||||
|
$this->checkFolders("dev");
|
||||||
|
$this->compileFiles("dev");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
echo "
|
||||||
|
==========================
|
||||||
|
= KOMPILOWANIE DO 'pub'
|
||||||
|
==========================
|
||||||
|
";
|
||||||
|
$this->versionUp("pub");
|
||||||
|
$this->addCustoms("pub");
|
||||||
|
$this->checkFolders("public");
|
||||||
|
$this->compileFiles("public");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
echo "
|
||||||
|
==========================
|
||||||
|
= KOMPILOWANIE DO 'pub'
|
||||||
|
==========================
|
||||||
|
";
|
||||||
|
$this->versionUp("pub");
|
||||||
|
$this->addCustoms("pub");
|
||||||
|
$this->checkFolders("public");
|
||||||
|
$this->compileFiles("public");
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "start-server":
|
||||||
|
if($argv[2] != null)
|
||||||
|
$this->runServer($argv[2]);
|
||||||
|
else
|
||||||
|
$this->runServer("pub");
|
||||||
|
break;
|
||||||
|
case "help":
|
||||||
|
$this->help();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
echo "Brak parametru rozruchowego. Wpisz help, aby zobaczyć listę dostępnych komend. \n";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* SPRAWDZANIE CZY SĄ FOLDERY css I js
|
* SPRAWDZANIE CZY SĄ FOLDERY css I js
|
||||||
*/
|
*/
|
||||||
function checkFolders() : void{
|
function checkFolders($folder) : void{
|
||||||
if(!file_exists("public/css"))
|
if(!file_exists("$folder/css"))
|
||||||
mkdir("public/css");
|
mkdir("$folder/css");
|
||||||
|
|
||||||
if(!file_exists("public/js"))
|
if(!file_exists("$folder/js"))
|
||||||
mkdir("public/js");
|
mkdir("$folder/js");
|
||||||
}
|
}
|
||||||
|
|
||||||
function compileFiles() : void{
|
function compileFiles($folder) : void{
|
||||||
// KOPIOWANIE PLIKÓW HTML DO PUBLICZNEGO FOLDERU
|
// KOPIOWANIE PLIKÓW HTML DO PUBLICZNEGO FOLDERU
|
||||||
foreach ($this->htmls as $html) {
|
foreach ($this->htmls as $html) {
|
||||||
$file = $this->src . "views/" . $html;
|
$file = $this->src . "views/" . $html;
|
||||||
@@ -40,25 +92,26 @@
|
|||||||
$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->page_tags) as $page_tag) {
|
||||||
echo $page_tag;
|
|
||||||
if ($page_tag == "{CSS}") {
|
if ($page_tag == "{CSS}") {
|
||||||
$this->dictionary->page_tags[$page_tag] .= "<link rel='stylesheet' href='vendor/blog-engine/blog.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='public/css/{$this->csss[$j]}' />";
|
$this->dictionary->page_tags[$page_tag] .= "\n <link rel='stylesheet' href='$folder/css/{$this->csss[$j]}?v{$this->version}' />";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($page_tag == "{JS}") {
|
if ($page_tag == "{JS}") {
|
||||||
$this->dictionary->page_tags[$page_tag] .= "<script src='vendor/blog-engine/blog.js'></script>";
|
|
||||||
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='public/js/{$this->jss[$j]}'></script>";
|
$this->dictionary->page_tags[$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->page_tags[$page_tag], $site);
|
||||||
}
|
}
|
||||||
|
|
||||||
$site_file = fopen("public/" . $name, "w");
|
$site = str_replace("<body>", "<body>\n<?php include \$topbar; ?>", $site);
|
||||||
|
|
||||||
|
$site_file = fopen("$folder/" . $name, "w");
|
||||||
fwrite($site_file, $site);
|
fwrite($site_file, $site);
|
||||||
fclose($site_file);
|
fclose($site_file);
|
||||||
|
|
||||||
|
echo "* Plik '$html' przetworzono do folderu '$folder'!\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,9 +122,11 @@
|
|||||||
$name = basename($file);;
|
$name = basename($file);;
|
||||||
$style = file_get_contents($file);
|
$style = file_get_contents($file);
|
||||||
|
|
||||||
$style_file = fopen("public/css/" . $name, "w");
|
$style_file = fopen("$folder/css/" . $name, "w");
|
||||||
fwrite($style_file, $style);
|
fwrite($style_file, $style);
|
||||||
fclose($style_file);
|
fclose($style_file);
|
||||||
|
|
||||||
|
echo "* Plik '$css' przetworzono do folderu '$folder'!\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -82,13 +137,91 @@
|
|||||||
$name = basename($file);
|
$name = basename($file);
|
||||||
$script = file_get_contents($file);
|
$script = file_get_contents($file);
|
||||||
|
|
||||||
$script_file = fopen("public/js/" . $name, "w");
|
$script_file = fopen("$folder/js/" . $name, "w");
|
||||||
fwrite($script_file, $script);
|
fwrite($script_file, $script);
|
||||||
fclose($script_file);
|
fclose($script_file);
|
||||||
|
|
||||||
|
echo "* Plik '$js' przetworzono do folderu '$folder'!\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function versionUp($type) : void{
|
||||||
|
switch($type){
|
||||||
|
case "pub":
|
||||||
|
$this->version++;
|
||||||
|
break;
|
||||||
|
case "dev":
|
||||||
|
$this->version += 0.1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$verfile = fopen("version", "w+");
|
||||||
|
fwrite($verfile, $this->version);
|
||||||
|
fclose($verfile);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function addCustoms($type) : void {
|
||||||
|
$json = json_decode(file_get_contents("custom.json"), true);
|
||||||
|
switch($type){
|
||||||
|
case "dev":
|
||||||
|
foreach ($json["dev"]["css"] as $css){
|
||||||
|
$this->dictionary->page_tags["{CSS}"] .= "\n <link rel='stylesheet' href='$css' />";
|
||||||
|
echo "* Dodano '$css' do styli w '$type'!\n";
|
||||||
|
}
|
||||||
|
foreach ($json["dev"]["js"] as $js){
|
||||||
|
$this->dictionary->page_tags["{JS}"] .= "\n <script src='$js'></script>";
|
||||||
|
echo "* Dodano '$js' do skryptów w '$type'!\n";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case "pub":
|
||||||
|
foreach ($json["pub"]["css"] as $css){
|
||||||
|
$this->dictionary->page_tags["{CSS}"] .= "\n <link rel='stylesheet' href='$css' />";
|
||||||
|
echo "* Dodano '$css' do styli w '$type'!\n";
|
||||||
|
}
|
||||||
|
foreach ($json["pub"]["js"] as $js){
|
||||||
|
$this->dictionary->page_tags["{JS}"] .= "\n <script src='$js'></script>";
|
||||||
|
echo "* Dodano '$js' do skryptów w '$type'!\n";
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function runServer($type) : void{
|
||||||
|
if(file_exists("_config.php")){
|
||||||
|
|
||||||
|
$port = match ($type) {
|
||||||
|
"dev" => DEV_PORT,
|
||||||
|
default => PUB_PORT,
|
||||||
|
};
|
||||||
|
} else
|
||||||
|
$port = 14071;
|
||||||
|
|
||||||
|
echo "
|
||||||
|
=========================================
|
||||||
|
Uruchamianie serwera na adresie:
|
||||||
|
* http://127.0.0.1:$port *
|
||||||
|
Aby zatrzymać serwer, naciśnij Ctrl+C
|
||||||
|
=========================================
|
||||||
|
|
||||||
|
";
|
||||||
|
exec("php -S 127.0.0.1:$port -t " . __DIR__);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function help() : void {
|
||||||
|
echo "
|
||||||
|
===============================
|
||||||
|
= BLOG ENGINE v0.1
|
||||||
|
= Krzysztof KrzysiekSiemv Smaga 2023
|
||||||
|
===============================
|
||||||
|
Dostępne komendy dla narzędzia:
|
||||||
|
|
||||||
|
* start-server [pub/dev] - uruchom serwer dla projektu. Opcja 'dev' specjalna dla programisty, opcja 'pub' dla każdego użytkownika. Domyślnie 'pub'
|
||||||
|
* help - wyświetl listę komend
|
||||||
|
* compile [pub/dev] - skompiluj projekt strony z folderu 'src'. Opcja 'dev' specjalna dla programisty, opcja 'pub' dla każdego użytkownika. Domyślnie 'pub'
|
||||||
|
";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$exec = new CompileIt();
|
$exec = new CompileIt();
|
||||||
$exec->main();
|
$exec->main($argv, $argc);
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"_comment": "Tutaj możesz dodawać linki do swoich styli zewnętrznych, bądź skryptów, które chcesz użyć na swoim blogu.",
|
||||||
|
"dev": {
|
||||||
|
"css": [
|
||||||
|
"vendor/blog-engine/blog.css",
|
||||||
|
"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css"
|
||||||
|
],
|
||||||
|
"js": [
|
||||||
|
"vendor/blog-engine/blog.js",
|
||||||
|
"https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"pub": {
|
||||||
|
"css": [
|
||||||
|
"vendor/blog-engine/blog.css"
|
||||||
|
],
|
||||||
|
"js": [
|
||||||
|
"vendor/blog-engine/blog.js"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="pl">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Witaj świecie! - Kwiatowy Blog</title>
|
||||||
|
|
||||||
|
<link rel='stylesheet' href='vendor/blog-engine/blog.css' />
|
||||||
|
<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/css/bootstrap.min.css' />
|
||||||
|
<link rel='stylesheet' href='dev/css/style.css?v2' />
|
||||||
|
|
||||||
|
<meta name="author" content="Krzysiek Smaga">
|
||||||
|
<meta name="keywords" content="kwiaty, rośliny">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<?php include $topbar; ?>
|
||||||
|
<h1>Kwiatowy Blog</h1>
|
||||||
|
<p>ef</p>
|
||||||
|
<a href="be_login.php">Zaloguj się do panelu</a>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
<script src='vendor/blog-engine/blog.js'></script>
|
||||||
|
<script src='https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha3/dist/js/bootstrap.bundle.min.js'></script>
|
||||||
|
<script src='dev/js/script.js?v2'></script>
|
||||||
|
</html>
|
||||||
@@ -25,10 +25,22 @@
|
|||||||
else
|
else
|
||||||
$ssl = 0;
|
$ssl = 0;
|
||||||
|
|
||||||
|
if(isset($_FILES['BLOG_ICON'])){
|
||||||
|
if(strtolower(pathinfo(basename($_FILES['BLOG_ICON']['name']),PATHINFO_EXTENSION)) == "png") {
|
||||||
|
if (move_uploaded_file($_FILES['BLOG_ICON']['tmp_name'], "resources/favicon.png")) {
|
||||||
|
$file = "resources/favicon.png";
|
||||||
|
}
|
||||||
|
$file = "";
|
||||||
|
}
|
||||||
|
$file = "";
|
||||||
|
} else
|
||||||
|
$file = "";
|
||||||
|
|
||||||
// Wczytywanie danych do tablicy
|
// Wczytywanie danych do tablicy
|
||||||
$data = [
|
$data = [
|
||||||
"BLOG_TITLE" => $_POST['BLOG_TITLE'], "BLOG_DESC" => $_POST['BLOG_DESC'], "BLOG_AUTHOR" => $_POST['BLOG_AUTHOR'], "BLOG_TAGS" => $_POST['BLOG_TAGS'], "BLOG_DOMAIN" => $_POST['BLOG_DOMAIN'],
|
"BLOG_TITLE" => $_POST['BLOG_TITLE'], "BLOG_DESC" => $_POST['BLOG_DESC'], "BLOG_AUTHOR" => $_POST['BLOG_AUTHOR'], "BLOG_TAGS" => $_POST['BLOG_TAGS'], "BLOG_DOMAIN" => $_POST['BLOG_DOMAIN'], "BLOG_ICON" => $file,
|
||||||
"DB_HOST" => $_POST['DB_HOST'], "DB_USER" => $_POST['DB_USER'], "DB_PASS" => $_POST['DB_PASS'], "DB_NAME" => $_POST['DB_NAME'],
|
"DB_HOST" => $_POST['DB_HOST'], "DB_USER" => $_POST['DB_USER'], "DB_PASS" => $_POST['DB_PASS'], "DB_NAME" => $_POST['DB_NAME'],
|
||||||
|
"PUB_PORT" => $_POST['PUB_PORT'], "DEV_PORT" => $_POST['DEV_PORT'],
|
||||||
"ADMIN_USER" => $_POST['ADMIN_USER'], "ADMIN_EMAIL" => $_POST['ADMIN_EMAIL'], "ADMIN_PASS" => $_POST['ADMIN_PASS'],
|
"ADMIN_USER" => $_POST['ADMIN_USER'], "ADMIN_EMAIL" => $_POST['ADMIN_EMAIL'], "ADMIN_PASS" => $_POST['ADMIN_PASS'],
|
||||||
"MAIL_NAME" => $_POST['MAIL_NAME'], "MAIL_PASS" => $_POST['MAIL_PASS'], "MAIL_SRV" => $_POST['MAIL_SRV'], "MAIL_PORT" => $_POST['MAIL_PORT'], "MAIL_SSL" => $ssl
|
"MAIL_NAME" => $_POST['MAIL_NAME'], "MAIL_PASS" => $_POST['MAIL_PASS'], "MAIL_SRV" => $_POST['MAIL_SRV'], "MAIL_PORT" => $_POST['MAIL_PORT'], "MAIL_SSL" => $ssl
|
||||||
];
|
];
|
||||||
@@ -58,10 +70,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(file_exists("_config.php")){
|
if(file_exists("_config.php")){
|
||||||
if(isset($_SESSION['uToken_BE'])){
|
$topbar = "";
|
||||||
if($auth->CheckRole($_SESSION['uToken_BE']) == "administrator")
|
if($_SERVER['SERVER_PORT'] == DEV_PORT) {
|
||||||
include "vendor/blog-engine/php/Sites/Views/be-topbar.php";
|
if(isset($_SESSION['uToken_BE'])){
|
||||||
}
|
if($auth->CheckRole($_SESSION['uToken_BE']) == "administrator")
|
||||||
require "public/index.html";
|
$topbar = "vendor/blog-engine/php/Sites/Views/be-topbar.php";
|
||||||
|
}
|
||||||
|
require "dev/index.html";
|
||||||
|
} else if($_SERVER['SERVER_PORT'] == PUB_PORT) {
|
||||||
|
if(isset($_SESSION['uToken_BE'])){
|
||||||
|
if($auth->CheckRole($_SESSION['uToken_BE']) == "administrator")
|
||||||
|
$topbar = "vendor/blog-engine/php/Sites/Views/be-topbar.php";
|
||||||
|
}
|
||||||
|
require "public/index.html";
|
||||||
|
} else
|
||||||
|
echo "<h1>Uruchom ponownie serwer</h1>";
|
||||||
} else
|
} else
|
||||||
require "be_firstrun.php";
|
require "be_firstrun.php";
|
||||||
+7
-4
@@ -3,16 +3,19 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Witaj świecie! - Kwiatowy Blog</title>
|
<title>Witaj świecie! - Kwiatowy 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' />
|
<link rel='stylesheet' href='public/css/style.css?v1' />
|
||||||
|
|
||||||
<meta name="author" content="Krzysiek Smaga">
|
<meta name="author" content="Krzysiek Smaga">
|
||||||
<meta name="keywords" content="nowy, pierwszy, super">
|
<meta name="keywords" content="kwiaty, rośliny">
|
||||||
<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>
|
||||||
<h1>Kwiatowy Blog</h1>
|
<h1>Kwiatowy Blog</h1>
|
||||||
<p>sdf</p>
|
<p>ef</p>
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
<script src='vendor/blog-engine/blog.js'></script>
|
<script src='vendor/blog-engine/blog.js'></script>
|
||||||
<script src='public/js/script.js'></script>
|
<script src='public/js/script.js?v1'></script>
|
||||||
</html>
|
</html>
|
||||||
Binary file not shown.
|
After Width: | Height: | Size: 83 KiB |
@@ -4,6 +4,7 @@
|
|||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<title>Witaj świecie! - {TITLE}</title>
|
<title>Witaj świecie! - {TITLE}</title>
|
||||||
{CSS}
|
{CSS}
|
||||||
|
{FAVICON}
|
||||||
<meta name="author" content="{AUTHOR}">
|
<meta name="author" content="{AUTHOR}">
|
||||||
<meta name="keywords" content="{KEYWORDS}">
|
<meta name="keywords" content="{KEYWORDS}">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
@@ -11,6 +12,7 @@
|
|||||||
<body>
|
<body>
|
||||||
<h1>{TITLE}</h1>
|
<h1>{TITLE}</h1>
|
||||||
<p>{DESCRIPTION}</p>
|
<p>{DESCRIPTION}</p>
|
||||||
|
<a href="be_login.php">Zaloguj się do panelu</a>
|
||||||
</body>
|
</body>
|
||||||
{JS}
|
{JS}
|
||||||
</html>
|
</html>
|
||||||
Vendored
+22
-1
@@ -1,4 +1,7 @@
|
|||||||
import * as bootstrap from "../twbs/bootstrap/dist/js/bootstrap.min.js";
|
(async() => {
|
||||||
|
const bootstrap = await import("../twbs/bootstrap/dist/js/bootstrap.min.js");
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
if(document.getElementById("testConn"))
|
if(document.getElementById("testConn"))
|
||||||
document.getElementById("testConn").addEventListener("click", () => testConnection());
|
document.getElementById("testConn").addEventListener("click", () => testConnection());
|
||||||
@@ -17,3 +20,21 @@ function testConnection(){
|
|||||||
xmlhttp.open("GET", "_checkdbconn.php?s=" + server + "&u=" + user + "&p=" + pass + "&d=" + name, true);
|
xmlhttp.open("GET", "_checkdbconn.php?s=" + server + "&u=" + user + "&p=" + pass + "&d=" + name, true);
|
||||||
xmlhttp.send();
|
xmlhttp.send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function insertAtCursor(field, text, mark) {
|
||||||
|
let sel = window.getSelection().getRangeAt(0);
|
||||||
|
if(sel != null){
|
||||||
|
let startPos = sel.startOffset;
|
||||||
|
let endPos = sel.endOffset;
|
||||||
|
|
||||||
|
if(mark === true){
|
||||||
|
let start_tag = text.substring(0, (text.length % 2 === 0 ? Math.ceil(text.length / 2) : Math.ceil(text.length / 2) - 1));
|
||||||
|
let end_tag = text.substring((text.length % 2 === 0 ? Math.ceil(text.length / 2) : Math.ceil(text.length / 2) - 1), text.length);
|
||||||
|
|
||||||
|
field.innerHTML = field.innerHTML.substring(0, startPos) + start_tag + field.innerHTML.substring(startPos, endPos) + end_tag + field.innerHTML.substring(endPos, field.innerHTML.length);
|
||||||
|
} else {
|
||||||
|
field.innerHTML = field.innerHTML.substring(0, startPos) + text + field.innerHTML.substring(startPos, endPos) + "<br>" + field.innerHTML.substring(endPos, field.innerHTML.length);
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
field.innerHTML += text;
|
||||||
|
}
|
||||||
@@ -1,6 +1,11 @@
|
|||||||
<?php
|
<?php
|
||||||
namespace BlogEngine\Authentication {
|
namespace BlogEngine\Authentication {
|
||||||
require "vendor/blog-engine/php/Database/DatabaseController.php";
|
$file = "vendor/blog-engine/php/Database/DatabaseController.php";
|
||||||
|
if(file_exists($file))
|
||||||
|
require $file;
|
||||||
|
else
|
||||||
|
require "../$file";
|
||||||
|
|
||||||
use BlogEngine\Database\DatabaseController;
|
use BlogEngine\Database\DatabaseController;
|
||||||
|
|
||||||
class AuthController extends DatabaseController{
|
class AuthController extends DatabaseController{
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
<!-- Podsumowanie -->
|
||||||
|
<?php
|
||||||
|
|
||||||
|
?>
|
||||||
|
<div class="row">
|
||||||
|
<div class="col card me-2">
|
||||||
|
<div class="card-body">
|
||||||
|
<h3>Ostatnie komentarze</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="col card ms-2">
|
||||||
|
<div class="card-body">
|
||||||
|
<h3>Statystyki z 24 godzin</h3>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
+64
@@ -0,0 +1,64 @@
|
|||||||
|
<!-- Posty -->
|
||||||
|
<?php
|
||||||
|
$posts = array();
|
||||||
|
|
||||||
|
// Pobierz posty
|
||||||
|
$get_posts_query = "SELECT * FROM posts";
|
||||||
|
$get_posts_res = mysqli_query($conn, $get_posts_query);
|
||||||
|
|
||||||
|
while($row = mysqli_fetch_assoc($get_posts_res)){
|
||||||
|
array_push($posts, [
|
||||||
|
"ID" => $row['id_post'],
|
||||||
|
"Nazwa" => $row['name'],
|
||||||
|
"Tytuł" => $row['title'],
|
||||||
|
"Treść" => $row['content'],
|
||||||
|
"Wyswietlenia" => $row['views'],
|
||||||
|
"Dodano" => $row['added_at']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<button type="button" name="add_post" class="btn btn-success" onclick="location.href='blog_panel/be_post.php';">Dodaj nowy post</button>
|
||||||
|
<table class="table table-stripped">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>ID</th>
|
||||||
|
<th>Tytuł</th>
|
||||||
|
<th>Zawartość</th>
|
||||||
|
<th>Wyświetlenia</th>
|
||||||
|
<th>Dodano</th>
|
||||||
|
<th>Akcja</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
foreach ($posts as $post){
|
||||||
|
if(strlen($post['Treść']) > 256){
|
||||||
|
$post['Treść'] = substr($post['Treść'], 0, 253) . "...";
|
||||||
|
}
|
||||||
|
echo "
|
||||||
|
<tr>
|
||||||
|
<th>{$post['Nazwa']}</th>
|
||||||
|
<td>{$post['Tytuł']}</td>
|
||||||
|
<td>{$post['Treść']}</td>
|
||||||
|
<td>{$post['Wyswietlenia']}</td>
|
||||||
|
<td>{$post['Dodano']}</td>
|
||||||
|
<td>
|
||||||
|
<div class='d-flex'>
|
||||||
|
<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>
|
||||||
|
</form>
|
||||||
|
<form method='POST' action='be_panel.php'>
|
||||||
|
<div class='d-flex'>
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
+1
@@ -5,6 +5,7 @@ namespace BlogEngine {
|
|||||||
public $page_tags = [
|
public $page_tags = [
|
||||||
"{POSTS}" => "",
|
"{POSTS}" => "",
|
||||||
"{LINKS}" => "",
|
"{LINKS}" => "",
|
||||||
|
"{FAVICON}" => (BLOG_ICON != ""?"<link rel='icon' type='image/png' href='" . BLOG_ICON . "' sizes='any'>":""),
|
||||||
"{KEYWORDS}" => BLOG_TAGS,
|
"{KEYWORDS}" => BLOG_TAGS,
|
||||||
"{TITLE}" => BLOG_TITLE,
|
"{TITLE}" => BLOG_TITLE,
|
||||||
"{AUTHOR}" => BLOG_AUTHOR,
|
"{AUTHOR}" => BLOG_AUTHOR,
|
||||||
|
|||||||
+1
-1
@@ -15,7 +15,7 @@
|
|||||||
</button>
|
</button>
|
||||||
<div class="collapse navbar-collapse" id="navbarNav">
|
<div class="collapse navbar-collapse" id="navbarNav">
|
||||||
<ul class="navbar-nav">
|
<ul class="navbar-nav">
|
||||||
<li class="nav-item"><a class="nav-link" href="#">Wejdź do panelu</a></li>
|
<li class="nav-item"><a class="nav-link" href="be_panel.php">Wejdź do panelu</a></li>
|
||||||
<li class="nav-item"><a class="nav-link" href="#">Dodaj nowy wpis</a></li>
|
<li class="nav-item"><a class="nav-link" href="#">Dodaj nowy wpis</a></li>
|
||||||
<li class="nav-item"><a class="nav-link" href="#">Moderuj komentarze</a></li>
|
<li class="nav-item"><a class="nav-link" href="#">Moderuj komentarze</a></li>
|
||||||
<li class="nav-item"><a class="nav-link" href="#">Zobacz statystyki</a></li>
|
<li class="nav-item"><a class="nav-link" href="#">Zobacz statystyki</a></li>
|
||||||
|
|||||||
Vendored
+10
-3
@@ -24,9 +24,6 @@
|
|||||||
// Ikona bloga (format .PNG)
|
// Ikona bloga (format .PNG)
|
||||||
const BLOG_ICON = "{BLOG_ICON}";
|
const BLOG_ICON = "{BLOG_ICON}";
|
||||||
|
|
||||||
// Nazwa pliku strony głównej
|
|
||||||
const BLOG_INDEX = "{BLOG_INDEX}";
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* KONFIGURACJA BAZY DANYCH
|
* KONFIGURACJA BAZY DANYCH
|
||||||
*/
|
*/
|
||||||
@@ -43,6 +40,16 @@
|
|||||||
// Baza danych dla bloga
|
// Baza danych dla bloga
|
||||||
const DB_NAME = "{DB_NAME}";
|
const DB_NAME = "{DB_NAME}";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* KONFIGURACJA NARZĘDZIA SERWEROWEGO
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Port, który ma używać PHP dla serwera publicznego
|
||||||
|
const PUB_PORT = "{PUB_PORT}";
|
||||||
|
|
||||||
|
// Port, który ma używać PHP dla serwera deweloperskiego
|
||||||
|
const DEV_PORT = "{DEV_PORT}";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* KONFIGURACJA KONTA ADMINISTRATORA
|
* KONFIGURACJA KONTA ADMINISTRATORA
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user