Deletion of $page->title
"; + echo "Are you sure you want to delete this page?
"; + echo "Cancel"; + echo "Confirm"; + } + + ?> + + diff --git a/public/admin/edit.php b/public/admin/edit.php new file mode 100644 index 0000000..6838aac --- /dev/null +++ b/public/admin/edit.php @@ -0,0 +1,80 @@ + + + + +
+
+
+
+
+
+
+ title = $_POST['title'];
+ $page->slug = $newSlug;
+ $page->author = $_SESSION['loginUsername'];
+ $page->cDate = time();
+ $page->mDate = time();
+ $page->content = $_POST['content'];
+
+ } else {
+ // This is modification of an existing page
+ $page = new Page($originalSlug);
+ $page->title = $_POST['title'];
+ $page->mDate = time();
+ $page->content = $_POST['content'];
+ if ($originalSlug !== $newSlug) {
+ // The page needs to be moved
+ $page->slug = $originalSlug;
+ $page->rename($newSlug);
+ }
+ }
+
+ $page->write();
+
+ header('Location: /admin');
+ exit();
+
+ } else if (isset($_GET['page'])) {
+
+ $page = new Page($_GET['page']);
+
+ if ($page->slug) {
+ echo "Accord's CMS
+
+
+
+
+
+
+
+
+
+
+
+ parse();
+ }
+
+ ?>
+
+
+
diff --git a/public/login/index.php b/public/login/index.php
new file mode 100644
index 0000000..67991d2
--- /dev/null
+++ b/public/login/index.php
@@ -0,0 +1,61 @@
+
+
+
+
+
+ Accord's Library - Login
+
+
+
+
+
Editing $page->title
"; + } else { + echo "Editing a new page
"; + } + + echo " + + "; + } + + ?> + + + diff --git a/public/admin/index.php b/public/admin/index.php new file mode 100644 index 0000000..5d5c3d4 --- /dev/null +++ b/public/admin/index.php @@ -0,0 +1,55 @@ + + + + +
+
+
+
+
+
+
+
+
diff --git a/public/admin/logout.php b/public/admin/logout.php
new file mode 100644
index 0000000..6256642
--- /dev/null
+++ b/public/admin/logout.php
@@ -0,0 +1,5 @@
+
diff --git a/public/admin/tools.php b/public/admin/tools.php
new file mode 100644
index 0000000..30098f1
--- /dev/null
+++ b/public/admin/tools.php
@@ -0,0 +1,112 @@
+ $value) {
+ $this->$key = $value;
+ }
+ $this->slug = $pageSlug;
+ }
+ }
+
+ function write() {
+ $filePath = getPageJSONPath($this->slug);
+
+ // Remove attributes that should be serialized
+ $slug = $this->slug;
+ unset($this->slug);
+
+ $file = fopen($filePath, 'w');
+ fwrite($file, json_encode($this));
+ fclose($file);
+
+ // Add them back
+ $this->slug = $slug;
+ }
+
+ function delete() {
+ $filePath = getPageJSONPath($this->slug);
+ if (file_exists($filePath)) {
+ unlink($filePath);
+ }
+ }
+
+ function rename($newSlug) {
+ rename(getPageJSONPath($this->slug), getPageJSONPath($newSlug));
+ $this->slug = $newSlug;
+ }
+
+ function parse() {
+ require_once($_SERVER["DOCUMENT_ROOT"] . "/../Parsedown.php");
+ $parsedown = new Parsedown();
+ $parsedown->setSafeMode(true);
+ return $parsedown->text($this->content);
+ }
+ }
+
+ function getListSlugPages() {
+ global $pagesFolder;
+ $pages = scandir($pagesFolder);
+ $pages = array_slice($pages, 2);
+ $result = array();
+ foreach ($pages as $page) {
+ if (substr($page, -5, 5) == '.json') {
+ array_push($result, substr($page, 0, -5));
+ }
+ }
+ return $result;
+ }
+
+ function existPage($pageSlug) {
+ return file_exists(getPageJSONPath($pageSlug));
+ }
+
+ function getPageJSONPath($pageSlug) {
+ global $pagesFolder;
+ return $pagesFolder . $pageSlug . '.json';
+ }
+
+ function unixToDate($unixTime) {
+ return date('Y-m-d', $unixTime);
+ }
+
+ function sluggify($string) {
+ $string = strtolower($string);
+ $string = str_replace(' ', '-', $string);
+
+ $string = str_split($string);
+ $result = "";
+ $slugAcceptable = "abcdefghijklmnopqrstuvwxyz0123456789-";
+ foreach ($string as $c) {
+ if (stripos($slugAcceptable, $c) !== false) $result .= $c;
+ }
+ $result = trim($result, "-");
+ return $result;
+ }
+
+
+
+ }
+
+
+
+
+ ?>
diff --git a/public/css/admin.css b/public/css/admin.css
new file mode 100644
index 0000000..029d19f
--- /dev/null
+++ b/public/css/admin.css
@@ -0,0 +1,88 @@
+@font-face {
+ font-family: customFont;
+ src: url("/font/Quicksand-VariableFont_wght.ttf");
+}
+
+:root {
+ --break-point: 60em;
+}
+
+body {
+ width: 100%;
+ display: grid;
+ grid-template-columns: 1fr var(--break-point) 1fr;
+ place-content: center;
+ overflow-x: hidden;
+}
+
+body > .container {
+ margin-top: 2rem;
+ margin-bottom: 2rem;
+ border: var(--default-border);
+ box-shadow: var(--default-box-shadow);
+ grid-column: 2;
+ transition: 1s margin-top;
+}
+
+body > .container > .content {
+ padding: 2rem;
+}
+
+#admin-bar {
+ max-width: var(--break-point);
+ display: grid;
+ grid-template-columns: 1fr;
+ grid-auto-flow: column;
+ align-items: center;
+ padding-left: 2rem;
+ padding-right: 2rem;
+ box-sizing: border-box;
+ background-color: var(--color-main-dark);
+ color: var(--color-main-light);
+}
+
+#admin-bar > #logout > .button {
+ margin-left: 1rem;
+}
+
+.content > .title {
+ display: grid;
+ grid-gap: 1rem;
+ grid-auto-flow: column;
+ place-content: start;
+ place-items: center start;
+}
+
+.page-list {
+ display: grid;
+ grid-template-columns: 2fr 1fr 1fr auto auto auto;
+ grid-row-gap: 0.5rem;
+}
+
+.page-list > * {
+ width: auto;
+}
+
+.page-list > .button {
+ place-self: center;
+}
+
+.page-list p {
+ margin-top: .5em;
+ margin-bottom: .5em;
+ font-weight: bold;
+}
+
+
+@media only screen and (max-width: 60em) {
+ body {
+ grid-template-columns: 1fr;
+ }
+
+ body > .container {
+ grid-column: 1;
+ margin-top: 0;
+ border: unset;
+ box-shadow: unset;
+ }
+}
diff --git a/public/css/edit.css b/public/css/edit.css
new file mode 100644
index 0000000..14d615a
--- /dev/null
+++ b/public/css/edit.css
@@ -0,0 +1,31 @@
+body {
+ display: grid;
+ place-content: center;
+}
+
+textarea {
+ padding: 1em;
+ margin-top: 1em;
+ min-width: 100%;
+ max-width: 100%;
+ height: 30em;
+ box-sizing: border-box;
+ background-color: inherit;
+ border: var(--default-border);
+ border-radius: 1em;
+}
+
+input[type = text] {
+ background-color: inherit;
+ border: var(--default-border);
+ padding: 0.3em 1em;
+ border-radius: 9999px;
+}
+
+input[type = submit] {
+ margin-top: 1em;
+}
+
+textarea:focus-visible, input:focus-visible {
+ outline: unset;
+}
diff --git a/public/css/login.css b/public/css/login.css
new file mode 100644
index 0000000..bc38309
--- /dev/null
+++ b/public/css/login.css
@@ -0,0 +1,76 @@
+body {
+ display: grid;
+ place-content: center;
+ height: 100vh;
+ overflow: hidden;
+ font-size: 120%;
+ text-align: center;
+}
+
+#container {
+ background: var(--color-main-light);
+ border: var(--default-border);
+ margin-bottom: 15vh;
+ width: 20em;
+ box-shadow: var(--default-box-shadow);
+ padding: 2em;
+}
+
+#container img {
+ width: 50%;
+ justify-self: center;
+}
+
+#myForm {
+ display: inline-grid;
+ grid-auto-flow: row;
+ padding: 1em;
+ width: 100%;
+ box-sizing: border-box;
+}
+
+#myForm > input, #myForm > button {
+ text-align: center;
+ padding: 0.5em;
+ border: solid 1px var(--color-main-dark);
+ border-radius: 9999px;
+ margin-top: 0.75em;
+ font-size: 100%;
+ font-family: customFont;
+ color: var(--color_background);
+ cursor: pointer;
+}
+
+#myForm > input:first-of-type {
+ margin-top: 0em;
+}
+
+#myForm > button {
+ color: white;
+ background: var(--color-main-dark);
+ font-weight: 600;
+ font-size: 125%;
+}
+
+#answer {
+ margin: 0;
+ padding: 1em;
+ border-radius: 0 0 var(--default_border_radius) var(--default_border_radius);
+ background: var(--color_accent);
+ font-size: 120%;
+ font-weight: 900;
+}
+
+@keyframes shake {
+ 0% { transform: translate(0px, 0);}
+ 10% { transform: translate(1px, 0);}
+ 20% { transform: translate(3px, 0);}
+ 30% { transform: translate(5px, 0);}
+ 40% { transform: translate(3px, 0);}
+ 50% { transform: translate(1px, 0);}
+ 60% { transform: translate(-1px, 0);}
+ 70% { transform: translate(-3px, 0));}
+ 80% { transform: translate(-5px, 0);}
+ 90% { transform: translate(-3px, 0);}
+ 100% { transform: translate(-1px, 0));}
+}
diff --git a/public/css/master.css b/public/css/master.css
new file mode 100644
index 0000000..451b290
--- /dev/null
+++ b/public/css/master.css
@@ -0,0 +1,39 @@
+@font-face {
+ font-family: customFont;
+ src: url("/font/Quicksand-VariableFont_wght.ttf");
+}
+
+:root {
+ --color-main-light: #FFF8E7;
+ --color-main-base: #ffEBCD;
+ --color-main-dark: #954535;
+ --color-main-black: #1B1811;
+ --default-border: solid 1px var(--color-main-dark);
+ --default-box-shadow: #95453529 0 0 2em;
+}
+
+body {
+ background: var(--color-main-light);
+ color: var(--color-main-black);
+ font-family: customFont;
+ margin: 0;
+ padding: 0;
+}
+
+.button {
+ background: var(--color-main-light);
+ padding: 0.3em 1.1em;
+ color: var(--color-main-dark);
+ transition: .1s background-color, .1s color, .1s border;
+ border: solid 2px var(--color-main-dark);
+ border-radius: 9999px;
+ text-decoration-line: none;
+ margin-left: 0.3em;
+ margin-right: 0.3em;
+}
+
+.button:hover {
+ background: var(--color-main-dark);
+ color: var(--color-main-light);
+ border: solid 2px var(--color-main-dark);
+}
diff --git a/public/font/.gitkeep b/public/font/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/public/img/.gitkeep b/public/img/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/public/index.php b/public/index.php
new file mode 100644
index 0000000..951b92a
--- /dev/null
+++ b/public/index.php
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+ ';
+
+ ?>
+
+ Pages
+ Create a new page +
+
+
+ The account name or password that you have entered is incorrect.';
+ echo '';
+ }
+
+ //echo '
+
+
' . $username . ';' . password_hash($password, PASSWORD_DEFAULT) . '
'; + + } + + ?> + +