/
new.php
38 lines (25 loc) · 1.13 KB
/
new.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
define("PHPUNIT_TESTING", true);
include_once("../../index.php");
$Wcms = new Wcms();
$Wcms->init();
$SimpleBlog = new SimpleBlog(false);
$SimpleBlog->init();
$requestToken = $_POST['token'] ?? $_GET['token'] ?? null;
if(!$Wcms->loggedIn
|| $_SESSION['token'] !== $requestToken
|| !$Wcms->hashVerify($requestToken))
die("Please login first.");
if(!isset($_POST["page"])) die("Please specify key and value");
$slug = $Wcms->slugify($_POST["page"]);
if(empty($slug)) die("Please specify all the fields");
$posts = (array)$SimpleBlog->get("posts");
$posts[$slug] = [
"title" => htmlspecialchars($_POST['page'], ENT_QUOTES),
"description" => "This blog post and the first paragraph is the short snippet.",
"date" => time(),
"body" => "This is the full blog post content. Here's some more example text. Lorem ipsum dolor sit amet, consectetur adipisicing elit. Quidem nesciunt voluptas tempore vero, porro reprehenderit cum provident eum sapiente voluptate veritatis, iure libero, fugiat iste soluta repellendus aliquid impedit alias."
];
$SimpleBlog->set("posts", $posts);
echo $SimpleBlog->slug . "/" . $slug;
?>