Praca, praca

Took 5 hours 39 minutes
This commit is contained in:
Krzysztof 'KrzysiekSiemv' Smaga
2023-05-14 23:21:51 +02:00
parent 36302fbaf1
commit 1bb536cd12
22 changed files with 502 additions and 52 deletions
+22 -1
View File
@@ -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"))
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.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;
}
+6 -1
View File
@@ -1,6 +1,11 @@
<?php
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;
class AuthController extends DatabaseController{
+16
View File
@@ -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
View File
@@ -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
View File
@@ -5,6 +5,7 @@ namespace BlogEngine {
public $page_tags = [
"{POSTS}" => "",
"{LINKS}" => "",
"{FAVICON}" => (BLOG_ICON != ""?"<link rel='icon' type='image/png' href='" . BLOG_ICON . "' sizes='any'>":""),
"{KEYWORDS}" => BLOG_TAGS,
"{TITLE}" => BLOG_TITLE,
"{AUTHOR}" => BLOG_AUTHOR,
+1 -1
View File
@@ -15,7 +15,7 @@
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<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="#">Moderuj komentarze</a></li>
<li class="nav-item"><a class="nav-link" href="#">Zobacz statystyki</a></li>
+10 -3
View File
@@ -24,9 +24,6 @@
// Ikona bloga (format .PNG)
const BLOG_ICON = "{BLOG_ICON}";
// Nazwa pliku strony głównej
const BLOG_INDEX = "{BLOG_INDEX}";
/*
* KONFIGURACJA BAZY DANYCH
*/
@@ -43,6 +40,16 @@
// Baza danych dla bloga
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
*/