diff --git a/.installed b/.installed
new file mode 100644
index 0000000..e69de29
diff --git a/autoload.php b/autoload.php
index aeb5fcf..19451e6 100644
--- a/autoload.php
+++ b/autoload.php
@@ -66,9 +66,9 @@ $smarty->setCacheDir(ps(__DIR__ . $config["smarty"]["cache"]));
// Getting all plugins for the Theme
require ps(__DIR__ . $config["smarty"]["template"] . "/{$usertheme}/info.php");
foreach ($theme["plugins"] as $reqPlugin) {
- if (!file_exists(ps(__DIR__ . $config["path"]["plugins"] . "/enabled/" . $reqPlugin . ".php")))
- die("This theme requires following plugin to be enabled: " . $reqPlugin);
- require_once ps(__DIR__ . $config["path"]["plugins"] . "/enabled/" . $reqPlugin . ".php");
+ if (!file_exists(ps(__DIR__ . $config["path"]["plugins"] . "/" . $reqPlugin . ".php")))
+ die("This theme requires following plugin: " . $reqPlugin);
+ require_once ps(__DIR__ . $config["path"]["plugins"] . "/" . $reqPlugin . ".php");
}
// Plugins (Legacy)
diff --git a/funky.php b/funky.php
index 514e4ee..040ba20 100644
--- a/funky.php
+++ b/funky.php
@@ -1,6 +1,6 @@
assign("daisytheme", $daisytheme);
+ unset($daisytheme);
+}
diff --git a/library/plugins/getRel.php b/library/plugins/getRel.php
new file mode 100644
index 0000000..3c75bec
--- /dev/null
+++ b/library/plugins/getRel.php
@@ -0,0 +1,14 @@
+assign("rel", clean($_GET["rel"]));
diff --git a/library/plugins/keep.txt b/library/plugins/keep.txt
new file mode 100644
index 0000000..ec3e524
--- /dev/null
+++ b/library/plugins/keep.txt
@@ -0,0 +1 @@
+Keep this, GitHub!
\ No newline at end of file
diff --git a/library/plugins/logoImage.php b/library/plugins/logoImage.php
new file mode 100644
index 0000000..ab0b085
--- /dev/null
+++ b/library/plugins/logoImage.php
@@ -0,0 +1,20 @@
+assign("logoImage", $logoImage);
+ unset($logoImage);
+ unset($usertheme);
+}
diff --git a/library/plugins/readChapters.php b/library/plugins/readChapters.php
new file mode 100644
index 0000000..128a561
--- /dev/null
+++ b/library/plugins/readChapters.php
@@ -0,0 +1,46 @@
+findBy(["user", "==", $user["id"]]);
+ $_readChapters = array();
+ foreach ($readChapters as $key => $ch) {
+ array_push($_readChapters, $ch["chapter"]);
+ }
+ if (isset($_GET["id"]) && is_numeric($_GET["id"]) && strpos($_SERVER["REQUEST_URI"], "chapter.php") !== false) {
+ $id = $_GET["id"];
+ $chapter = $db["chapters"]->findById($id);
+ if (!empty($chapter)) {
+ if (!in_array($id, $_readChapters)) {
+ $_data = array(
+ "user" => $user["id"],
+ "chapter" => $id,
+ "timestamp" => now()
+ );
+ $request = $db["readChapters"]->insert($_data);
+ if ($request)
+ array_push($_readChapters, $id);
+ unset($request);
+ unset($_data);
+ }
+ }
+ unset($id);
+ unset($chapter);
+ }
+
+ $smarty->assign("readChapters", $_readChapters);
+
+ unset($ch);
+ unset($_readChapters);
+ unset($readChapters);
+}
diff --git a/library/plugins/readingMode.php b/library/plugins/readingMode.php
new file mode 100644
index 0000000..c822403
--- /dev/null
+++ b/library/plugins/readingMode.php
@@ -0,0 +1,28 @@
+assign("readingMode", $readingmode);
diff --git a/library/plugins/simpleAlert.php b/library/plugins/simpleAlert.php
new file mode 100644
index 0000000..5fcb036
--- /dev/null
+++ b/library/plugins/simpleAlert.php
@@ -0,0 +1,32 @@
+ "info", // "", "info", "success", "warning", "error"
+ "content" => "Welcome to {$config["title"]}! To use all the functions such as commenting or Bookmarking, please create a free acount!",
+ "timestamp" => now()
+);
+// Database Insert
+$db["alerts"]->insert($data);
+*/
+$topAlert = $db["alerts"]->findAll(["id" => "DESC"], 1);
+if (!empty($topAlert)) $topAlert = $topAlert[0];
+$readAlert = !empty($topAlert) ? ($logged ? (!empty($db["alertReads"]->findOneBy([["user", "=", $user["id"]], "AND", ["alert", "=", $topAlert["id"]]])) ? true : false) : false) : false;
+
+$smarty->assign("topAlert", $topAlert);
+$smarty->assign("readAlert", $readAlert);
+
+unset($topAlert);
+unset($readAlert);
diff --git a/library/plugins/started.php b/library/plugins/started.php
new file mode 100644
index 0000000..f80a005
--- /dev/null
+++ b/library/plugins/started.php
@@ -0,0 +1,4 @@
+assign("userlangs", $_userlangs);
+ unset($lang);
+ // unset($userlangs);
+ unset($_userlangs);
+}
diff --git a/library/secrets/key.txt b/library/secrets/key.txt
new file mode 100644
index 0000000..c997c3b
--- /dev/null
+++ b/library/secrets/key.txt
@@ -0,0 +1 @@
+8dcf81c5-7cc9-4830-8466-0bbbabd25b1e
\ No newline at end of file
diff --git a/library/secrets/started.txt b/library/secrets/started.txt
new file mode 100644
index 0000000..600c3c8
--- /dev/null
+++ b/library/secrets/started.txt
@@ -0,0 +1 @@
+1685111125
\ No newline at end of file
diff --git a/library/themes/nucleus/info.php b/library/themes/nucleus/info.php
index d347c7e..0c007fb 100644
--- a/library/themes/nucleus/info.php
+++ b/library/themes/nucleus/info.php
@@ -10,7 +10,8 @@ $theme = [
"readChapters",
"simpleAlert",
"started",
- "userLangs"
+ "userLangs",
+ "readingMode"
],
"version" => "2023-03-30"
];
diff --git a/library/themes/nucleus/pages/chapter.tpl b/library/themes/nucleus/pages/chapter.tpl
index f34a25f..9beb016 100644
--- a/library/themes/nucleus/pages/chapter.tpl
+++ b/library/themes/nucleus/pages/chapter.tpl
@@ -1,3 +1,269 @@
-{foreach from=$images item=item key=key name=name}
-
-{/foreach}
\ No newline at end of file
+
+
+
+
+
+
+ {$fullChapterTitle}
+
+
+
+
+
+
+
+
+
+ {if $readingMode == "strip"}
+
+ {else}
+
+
+ {/if}
+
+
+ {if $readingMode == "strip"}
+ {foreach from=$images item=item key=key name=name}
+
})
+ {/foreach}
+ {else}
+

+ {/if}
+
+
+ {if $readingMode == "strip"}
+
+ {else}
+
+
+ {/if}
+
+
+
+
+
+
+
+
+
+ {$fullChapterTitle}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {$fullChapterTitle}
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/library/themes/nucleus/pages/title.tpl b/library/themes/nucleus/pages/title.tpl
index 94fb5f3..bae12f8 100644
--- a/library/themes/nucleus/pages/title.tpl
+++ b/library/themes/nucleus/pages/title.tpl
@@ -480,7 +480,7 @@
-
+
0) {
- fd.append("cover", files[0]);
- $.ajax({
- type: "POST",
- url: "ajax\\images\\tmp.php",
- data: fd,
- contentType: false,
- processData: false,
- success: function(msg) {
- let result = JSON.parse(msg);
- if (result.s == true) {
- let preview = document.getElementById("imgpreview");
- //preview.classList.remove("hidden");
- preview.src = "data/tmp/" + result.msg;
- document.querySelector("input[name='cover']").value =
- result.msg;
- } else {
- alert(result.msg);
+ var allowedTypes = ["image/jpeg", "image/jpg", "image/png", "image/webp"];
+ var file = this.files[0];
+ var fileType = file.type;
+ if (!allowedTypes.includes(fileType)) {
+ alert("Upload only supports JPG, JPEG, PNG and WEBP!");
+ $("#cover").val("");
+ return false;
+ } else {
+ var fd = new FormData();
+ var files = $("#cover")[0].files;
+ if (files.length > 0) {
+ fd.append("cover", files[0]);
+ $.ajax({
+ type: "POST",
+ url: "ajax\\images\\tmp.php",
+ data: fd,
+ contentType: false,
+ processData: false,
+ success: function(msg) {
+ let result = JSON.parse(msg);
+ if (result.s == true) {
+ let preview = document.getElementById("imgpreview");
+ preview.src = "data/tmp/" + result.msg;
+ document.querySelector("input[name='cover']").value =
+ result.msg;
+ } else {
+ alert(result.msg);
+ }
}
- }
- });
+ });
+ }
}
});
});
- $("#cover").change(function(e) {
- var allowedTypes = ["image/jpeg", "image/jpg", "image/png", "image/webp"];
- var file = this.files[0];
- var fileType = file.type;
- if (!allowedTypes.includes(fileType)) {
- alert("Upload only supports JPG, JPEG, PNG and WEBP!");
- $("#cover").val("");
- return false;
- }
- });
+ $("#cover").change(function(e) {});
$("#editTitleForm").submit(function(e) {
e.preventDefault();
diff --git a/public/ajax/chapters/add.php b/public/ajax/chapters/add.php
index 8185a04..86282c3 100644
--- a/public/ajax/chapters/add.php
+++ b/public/ajax/chapters/add.php
@@ -42,8 +42,8 @@ $data = array(
"volume" => namba($volume),
"name" => $name,
"language" => $language,
- "title" => $title,
- "user" => $user,
+ "title" => $title["id"],
+ "user" => $user["id"],
"lastEdited" => now(),
"timestamp" => now()
);
diff --git a/public/ajax/chapters/edit.php b/public/ajax/chapters/edit.php
index 1cd136a..63aa090 100644
--- a/public/ajax/chapters/edit.php
+++ b/public/ajax/chapters/edit.php
@@ -46,8 +46,8 @@ $data = array(
"volume" => namba($volume),
"name" => $name,
"language" => $language,
- "title" => $title,
- "user" => $user,
+ "title" => $title["id"],
+ "user" => $user["id"],
"lastEdited" => now(),
"timestamp" => now()
);
diff --git a/public/ajax/images/tmp.php b/public/ajax/images/tmp.php
index 762c648..6a94cd9 100644
--- a/public/ajax/images/tmp.php
+++ b/public/ajax/images/tmp.php
@@ -25,4 +25,4 @@ if ($_FILES["cover"]["size"] > $config["mfs"]["cover"]) die(je(["s" => false, "m
if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "webp") die(je(["s" => false, "msg" => "Invalid Image! Please use JPEG, PNG or WEBP."]));
if (!move_uploaded_file($_FILES["cover"]["tmp_name"], $target_file)) die(je(["s" => false, "msg" => "Something went wrong..."]));
-die(je(["s" => true, "msg" => $output_file]));
+die(je(["s" => true, "msg" => $output_file]));
\ No newline at end of file
diff --git a/public/ajax/titles/add.php b/public/ajax/titles/add.php
index 17cf5ff..0d826a3 100644
--- a/public/ajax/titles/add.php
+++ b/public/ajax/titles/add.php
@@ -99,7 +99,8 @@ if (!empty($db["titles"]->findOneBy(["title", "=", $title]))) die(je(["s" => fal
//die(je(["s" => false, "msg" => $cover]));
if (!file_exists("../../data/covers")) mkdir("../../data/covers", 0777, true);
-if (file_exists("../../data/tmp/" . $cover)) rename("../../data/tmp/" . $cover, "../../data/covers/" . ($db["titles"]->getLastInsertedId() + 1) . ".png");
+if (file_exists(ps(__DIR__ . "/../../data/tmp/" . $cover))) rename(ps(__DIR__ . "/../../data/tmp/" . $cover), ps(__DIR__ . "/../../data/covers/" . ($db["titles"]->getLastInsertedId() + 1) . ".png"));
+if (file_exists(ps(__DIR__ . "/../../data/tmp/" . $cover))) unlink(ps(__DIR__ . "/../../data/tmp/" . $cover));
$data = array(
"title" => $title,
@@ -118,7 +119,7 @@ $data = array(
"themes" => $themes,
"genres" => $genres
),
- "creator" => $user,
+ "creator" => $user["id"],
"lastEdited" => now(),
"timestamp" => now()
);
diff --git a/public/ajax/titles/edit.php b/public/ajax/titles/edit.php
index 8c0b6cd..b25a613 100644
--- a/public/ajax/titles/edit.php
+++ b/public/ajax/titles/edit.php
@@ -105,8 +105,8 @@ if (!empty($genres)) {
if ($title != $title["title"])
if (!empty($db["titles"]->findOneBy(["title", "=", $title]))) die(je(["s" => false, "msg" => "Title already exists!"]));
-if (!file_exists("../../data/covers")) mkdir("../../data/covers", 0777, true);
-if (file_exists("../../data/tmp/" . $cover)) rename("../../data/tmp/" . $cover, "../../data/covers/" . $title["id"] . ".png");
+if (!file_exists(ps(__DIR__ . "/../../data/covers"))) mkdir(ps(__DIR__ . "/../../data/covers"), 0777, true);
+if (file_exists(ps(__DIR__ . "/../../data/tmp/" . $cover))) rename(ps(__DIR__ . "/../../data/tmp/" . $cover), ps(__DIR__ . "/../../data/covers/" . $title["id"] . ".png"));
$data = array(
"title" => $name,
diff --git a/public/chapter.php b/public/chapter.php
index 4a0b59a..6c0bd79 100644
--- a/public/chapter.php
+++ b/public/chapter.php
@@ -6,22 +6,75 @@ if (!isset($_GET["id"]) || empty($_GET["id"])) header("Location: index.php") &&
if (!is_numeric($_GET["id"])) header("Location: index.php") && die("Invalid ID.");
$id = cat($_GET["id"]);
$chapter = $db["chapters"]->findById($id);
-$title = $db["titles"]->findById($chapter["title"]["id"]);
+$title = $db["titles"]->findById($chapter["title"]);
if (empty($title)) header("Location: titles.php") && die("Title not found.");
if (empty($chapter)) header("Location: title.php?id={$title["id"]}") && die("Chapter not found.");
+$fct = formatChapterTitle($chapter["volume"], $chapter["number"], "full");
+$smarty->assign("fullChapterTitle", $fct);
+
+$chapters = $db["chapters"]->findBy(["title", "==", $title["id"]]);
+$smarty->assign("chapters", $chapters);
+
+$isNextChapter = false;
+$isPrevChapter = false;
+
+foreach ($chapters as $key => $ch) {
+ if ($ch["id"] == $id) {
+ if (!empty($chapters[($key + 1)])) $isNextChapter = $chapters[($key + 1)]["id"];
+ if (!empty($chapters[($key - 1)])) $isPrevChapter = $chapters[($key - 1)]["id"];
+ }
+}
+
+$smarty->assign("nextChapter", $isNextChapter);
+$smarty->assign("prevChapter", $isPrevChapter);
+
$images = glob(ps(__DIR__ . "/data/chapters/{$id}/*.{jpg,png,jpeg,webp,gif}"), GLOB_BRACE);
natsort($images);
-$comments = $db["chapterComments"]->findBy(["chapter.id", "=", $title["id"]], ["id" => "DESC"]);
+$comments = $db["chapterComments"]->findBy(["chapter.id", "==", $title["id"]], ["id" => "DESC"]);
chapterVisit($chapter);
+$imgind = [];
+$ic = 1;
+foreach ($images as $ii) {
+ $ii = pathinfo($ii);
+ $imgind[$ic]["order"] = $ic;
+ $imgind[$ic]["name"] = $ii["filename"];
+ $imgind[$ic]["ext"] = $ii["extension"];
+ $ic++;
+}
+$smarty->assign("imgind", $imgind);
+
+if ($readingmode == "single") {
+ if (!isset($_GET["page"]) || empty($_GET["page"]) || $_GET["page"] == "0") {
+ header("Location: chapter.php?id=" . $id . "&page=1");
+ }
+
+ $page = cat($_GET["page"]);
+
+ $isNextPage = true;
+ $isPrevPage = true;
+
+ $nextPage = $page + 1;
+ $prevPage = $page - 1;
+
+ $imgCount = count($images);
+
+ if ($nextPage >= $imgCount) $isNextPage = false;
+ if ($prevPage <= 0) $isPrevPage = false;
+
+ $smarty->assign("isNextPage", $isNextPage);
+ $smarty->assign("isPrevPage", $isPrevPage);
+ $smarty->assign("currentPage", $page);
+}
+
$smarty->assign("commentsCount", count($comments));
$smarty->assign("title", $title);
$smarty->assign("chapter", $chapter);
$smarty->assign("images", $images);
-$smarty->assign("pagetitle", "Read " . $title["title"] . " " . formatChapterTitle($chapter["volume"], $chapter["number"]) . " (Chapter) " . $config["divider"] . " " . $config["title"]);
+$smarty->assign("pagetitle", "Read " . $title["title"] . " " . formatChapterTitle($chapter["volume"], $chapter["number"]) . " " . $config["divider"] . " " . $config["title"]);
$smarty->display("parts/header.tpl");
$smarty->display("pages/chapter.tpl");
diff --git a/public/index.php b/public/index.php
index 195eab9..f8b1525 100644
--- a/public/index.php
+++ b/public/index.php
@@ -46,7 +46,8 @@ $recentlyUpdated = $db["chapters"]->createQueryBuilder()
->fetch();
foreach ($recentlyUpdated as $key => $rec) {
- $title = $db["titles"]->findById($rec["title"]["id"]);
+ $title = $db["titles"]->findById($rec["title"]);
+ $recentlyUpdated[$key]["title"] = $title;
$recentlyUpdated[$key]["title"]["summary1"] = shorten($parsedown->text($purifier->purify($title["summary"])), 400);
$recentlyUpdated[$key]["title"]["summary2"] = shorten($parsedown->text($purifier->purify($title["summary"])), 100);
}
@@ -57,6 +58,13 @@ $chapters = $db["chapters"]->createQueryBuilder()
->getQuery()
->fetch();
+foreach ($chapters as $key => $ch) {
+ $title = $db["titles"]->findById($ch["title"]);
+ $uploader = $db["users"]->findById($ch["user"]);
+ $chapters[$key]["title"] = $title;
+ $chapters[$key]["user"] = $uploader;
+}
+
$smarty->assign("chapters", $chapters);
$smarty->assign("recentlyUpdated", $recentlyUpdated);
$smarty->assign("pagetitle", $config["title"] . " " . $config["divider"] . " " . $config["slogan"]);
diff --git a/public/releases.php b/public/releases.php
index fd5dc96..9b4be1c 100644
--- a/public/releases.php
+++ b/public/releases.php
@@ -14,6 +14,13 @@ $chapters = $db["chapters"]->createQueryBuilder()
->getQuery()
->fetch();
+foreach ($chapters as $key => $ch) {
+ $title = $db["titles"]->findById($ch["title"]);
+ $uploader = $db["users"]->findById($ch["user"]);
+ $chapters[$key]["title"] = $title;
+ $chapters[$key]["user"] = $uploader;
+}
+
$pagis = array();
$totalPages = $db["chapters"]->count() / $config["perpage"]["chapters"];
for ($i = 0; $i < $totalPages; $i++) {
diff --git a/public/title.php b/public/title.php
index fc527e8..c4084e1 100644
--- a/public/title.php
+++ b/public/title.php
@@ -91,11 +91,11 @@ if (!empty($title["summary"])) {
$chapters = array();
$chapterLangs = array();
$chapterCount = 0;
-if (!empty($db["chapters"]->findOneBy(["title.id", "=", $title["id"]]))) {
+if (!empty($db["chapters"]->findOneBy(["title", "==", $title["id"]]))) {
// Chapter Languages
$chapterLangs = $db["chapters"]->createQueryBuilder()
->select(["language"])
- ->where(["title.id", "=", $title["id"]])
+ ->where(["title", "==", $title["id"]])
->distinct("language.0")
->getQuery()
->fetch();
@@ -105,7 +105,7 @@ if (!empty($db["chapters"]->findOneBy(["title.id", "=", $title["id"]]))) {
// Actual Chapters
foreach ($chapterLangs as $key => $chLang) {
$_chapters = $db["chapters"]->createQueryBuilder()
- ->where([["title.id", "=", $title["id"]], "AND", ["language.1", "=", $chLang["language"][1]]])
+ ->where([["title", "==", $title["id"]], "AND", ["language.1", "==", $chLang["language"][1]]])
->orderBy(["volume" => "DESC"])
->orderBy(["number" => "DESC"])
->getQuery()
@@ -114,6 +114,8 @@ if (!empty($db["chapters"]->findOneBy(["title.id", "=", $title["id"]]))) {
$chapterLangs[$key]["language"]["chapters"] = array();
$chapterLangs[$key]["language"]["count"] = count($_chapters);
foreach ($_chapters as $_chapter) {
+ $uploader = $db["users"]->findById($_chapter["user"]);
+ $_chapter["user"] = $uploader;
// array_push($chapterLangs[$chLang[]], $_chapter);
array_push($chapterLangs[$key]["language"]["chapters"], $_chapter);
$chapterCount++;
@@ -122,7 +124,7 @@ if (!empty($db["chapters"]->findOneBy(["title.id", "=", $title["id"]]))) {
}
}
-$comments = $db["titleComments"]->findBy(["title.id", "=", $title["id"]], ["id" => "DESC"]);
+$comments = $db["titleComments"]->findBy(["title", "==", $title["id"]], ["id" => "DESC"]);
titleVisit($title);
diff --git a/version.txt b/version.txt
index 00be3b3..d7ee97b 100644
--- a/version.txt
+++ b/version.txt
@@ -1 +1 @@
-v0.3.0-alpha
\ No newline at end of file
+v0.3.1-alpha
\ No newline at end of file