Praca nad kontrolerem postów; Zmianki w zakładce 'Posty'; Budowa kreatora postów; Zmianki w kontrolerze autoryzacji; Nowe, puste zakładki.

Took 3 hours 31 minutes
This commit is contained in:
Krzysztof 'KrzysiekSiemv' Smaga
2023-05-16 01:28:08 +02:00
parent 1bb536cd12
commit e7dd0b2fd6
175 changed files with 44439 additions and 46 deletions
+13
View File
@@ -0,0 +1,13 @@
<?php
require "../../../../_config.php";
require "../Authentication/AuthController.php";
use BlogEngine\Authentication\AuthController;
$auth = new AuthController();
$conn = $auth->Connection();
if(isset($_POST['title']) && isset($_POST['content']) && isset($_POST['name'])){
}
$conn->close();
+30
View File
@@ -0,0 +1,30 @@
<?php
namespace BlogEngine\Posts {
use BlogEngine\Authentication\AuthController;
class PostController {
public AuthController $auth;
public function __construct($auth)
{
$this->auth = $auth;
}
public function CreatePost($title, $content, $name, $tags, $commentStatus, $add_time, $status){
$srv = $this->auth->Connection();
$date = (is_bool($add_time)?"NOW()":Date("'y-m-d H:i:s'", strtotime($add_time)));
$status = ($status == "public"?"public":"draft");
$id_user = $this->auth->GetID($_SESSION['uToken_BE']);
$last_id_post = 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', '$status', '$commentStatus', 0, $date, null);";
mysqli_query($srv, $insert_post);
foreach ($tags as $tag){
mysqli_query($srv, "INSERT INTO tag_to_post VALUES($tag, $last_id_post)");
}
header("location: ../../../be_panel.php?s=posts");
}
}
}
+30
View File
@@ -0,0 +1,30 @@
<?php
require "../../../../../_config.php";
require "../../Authentication/AuthController.php";
use BlogEngine\Authentication\AuthController;
$auth = new AuthController();
$conn = $auth->Connection();
if(isset($_POST['show_name']) && isset($_POST['slug'])){
$check_if_exists = mysqli_query($conn, "SELECT id_tag FROM tags WHERE show_name = '{$_POST['show_name']}' AND slug = '{$_POST['slug']}'");
if(mysqli_num_rows($check_if_exists) == 0){
// Add a tag
mysqli_query($conn, "INSERT INTO tags VALUES(NULL, '{$_POST['show_name']}', '{$_POST['slug']}')");
// Podaj ID Taga
$get_tag = mysqli_query($conn, "SELECT * FROM tags WHERE show_name = '{$_POST['show_name']}' AND slug = '{$_POST['slug']}'");
if($row = mysqli_fetch_row($get_tag)){
$value = [
"id" => $row[0],
"show_name" => $row[1],
"slug" => $row[2]
];
echo json_encode($value);
}
} else {
echo mysqli_fetch_row($check_if_exists)[0];
}
}
$conn->close();