Reader UI

This commit is contained in:
saintly2k 2023-05-29 22:19:21 +02:00
parent e61291558f
commit 99603a724a
27 changed files with 587 additions and 60 deletions

0
.installed Normal file
View File

View File

@ -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)

View File

@ -1,6 +1,6 @@
<?php
function clean($data, $title = true)
function clean($data, $title = false)
{
// This function is used, to completely sanitize user-input and make any form of scripts harmless and displayable
$data = htmlspecialchars($data);
@ -15,7 +15,7 @@ function clean($data, $title = true)
function cat($title)
{
// This function is used, to make all titles readable for the URL and links
// This function is used, to make all titles readable for the URL, Cookies and links
return preg_replace('/[^A-Za-z0-9\-_,.]/', '', str_replace("&", "et", str_replace(' ', '-', strtolower($title))));
}

View File

@ -0,0 +1,17 @@
<?php
/* ************************************************************ *
* Name: Daisy Theme *
* Author: Saintly *
* Website: https://h33t.moe *
* Last Updated: 28.01.2023 *
* ------------------------------------------------------------ *
* This plugin gets the cookie "{prefix}_daisytheme" and pushes *
* it to Smarty as a variable. *
* ************************************************************ */
$daisytheme = cat($_COOKIE[cat($config["title"]) . "_daisytheme"] ?? "light");
if (isset($smarty)) {
$smarty->assign("daisytheme", $daisytheme);
unset($daisytheme);
}

View File

@ -0,0 +1,14 @@
<?php
/* ************************************************************ *
* Name: Get Rel *
* Author: Saintly *
* Website: https://h33t.moe *
* Last Updated: 13.02.2023 *
* ------------------------------------------------------------ *
* This plugin is used to get if rel isset per get request and *
* if it is "rel", it assigns it to smarty. *
* ************************************************************ */
if (isset($_GET["rel"]) && !empty($_GET["rel"]))
$smarty->assign("rel", clean($_GET["rel"]));

1
library/plugins/keep.txt Normal file
View File

@ -0,0 +1 @@
Keep this, GitHub!

View File

@ -0,0 +1,20 @@
<?php
/* ************************************************************ *
* Name: Logo Image *
* Author: Saintly *
* Website: https://h33t.moe *
* Last Updated: 28.01.2023 *
* ------------------------------------------------------------ *
* This plugin checks if the logo in the theme folder exists *
* and pushes it to Smarty. If it doesn't exist, it will assign *
* and empty value to "logoImage". *
* ************************************************************ */
$usertheme = getUserTheme($logged, $user["theme"] ?? "");
$logoImage = file_exists(ps(__DIR__ . "/../../../public/assets/{$usertheme}/logo.png")) ? "assets/{$usertheme}/logo.png" : "";
if (isset($smarty)) {
$smarty->assign("logoImage", $logoImage);
unset($logoImage);
unset($usertheme);
}

View File

@ -0,0 +1,46 @@
<?php
/* ************************************************************ *
* Name: Read Chapters *
* Author: Saintly *
* Website: https://h33t.moe *
* Last Updated: 29.05.2023 *
* ------------------------------------------------------------ *
* Gets all read chapters from Database and puts the into an *
* array which gets pushed to Smarty. *
* ************************************************************ */
if ($logged) {
$readChapters = $db["readChapters"]->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);
}

View File

@ -0,0 +1,28 @@
<?php
/* ************************************************************ *
* Name: Reading mode *
* Author: Saintly *
* Website: https://h33t.moe *
* Last Updated: 26.05.2023 *
* ------------------------------------------------------------ *
* Gets the current reading mode and assigns it to smarty. *
* ************************************************************ */
$readingmode = "strip";
if (isset($_COOKIE[cat($config["title"]) . "_readingmode"])) {
$readingmode = cat($_COOKIE[cat($config["title"]) . "_readingmode"]);
}
switch ($readingmode) {
case "strip":
$readingmode = "strip";
break;
case "single":
$readingmode = "single";
break;
default:
$readingmode = "strip";
}
$smarty->assign("readingMode", $readingmode);

View File

@ -0,0 +1,32 @@
<?php
/* ************************************************************ *
* Name: Simple Alert *
* Author: Saintly *
* Website: https://h33t.moe *
* Last Updated: 29.05.2023 *
* ------------------------------------------------------------ *
* This plugin gets the latest Alert and assigns it to Smarty. *
* If the user is logged, he has an option to mark it as read, *
* thus it will no longer be displayed to him. *
* ************************************************************ */
/*
// Alert structure:
$data = array(
"type" => "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);

View File

@ -0,0 +1,4 @@
<?php
if (!file_exists(ps(__DIR__ . "/../secrets/started.txt"))) die("started.txt is missing. did you install the software properly?");
$started = file_get_contents(ps(__DIR__ . "/../secrets/started.txt"));

View File

@ -0,0 +1,26 @@
<?php
/* ************************************************************ *
* Name: User Langs *
* Author: Saintly *
* Website: https://h33t.moe *
* Last Updated: 28.01.2023 *
* ------------------------------------------------------------ *
* This Plugin is used to get all the languages and put *
* them into an array and push that to Smarty. *
* ************************************************************ */
$userlangs = glob(ps(__DIR__ . "/../langs/*.php"));
$_userlangs = array();
foreach ($userlangs as $userlang) {
unset($lang);
require_once $userlang;
$lang["info"]["code"] = substr(basename($userlang), 0, -4);
array_push($_userlangs, $lang["info"]);
}
if (isset($smarty)) {
$smarty->assign("userlangs", $_userlangs);
unset($lang);
// unset($userlangs);
unset($_userlangs);
}

1
library/secrets/key.txt Normal file
View File

@ -0,0 +1 @@
8dcf81c5-7cc9-4830-8466-0bbbabd25b1e

View File

@ -0,0 +1 @@
1685111125

View File

@ -10,7 +10,8 @@ $theme = [
"readChapters",
"simpleAlert",
"started",
"userLangs"
"userLangs",
"readingMode"
],
"version" => "2023-03-30"
];

View File

@ -1,3 +1,269 @@
{foreach from=$images item=item key=key name=name}
<img src="data/chapters/{$chapter.id}/{basename($item)}" alt="Page {$key + 1}">
<div class="grid grid-cols-12">
<div class="col-span-1"></div>
<div class="col-span-10">
<h1 class="text-3xl"><a href="title.php?id={$title.id}" class="text-blue-500 hover:underline">{$title.title}</a>
</h1>
<h2 class="text-2xl flex">
{$fullChapterTitle}
<label class="swap swap-flip">
<input type="checkbox" onchange="toggleRead({$chapter.id});toggleCheck('readBox{$chapter.id}0');toggleCheck('readBox{$chapter.id}Modal');"
id="readBox{$chapter.id}" {if $logged && in_array($chapter.id, $readChapters)}checked{/if}>
<div class="swap-on">&#9989;</div>
<div class="swap-off">&#10060;</div>
</label>
</h2>
<hr class="w-full mb-2">
<div class="w-full grid grid-cols-9 gap-2">
{if $readingMode == "strip"}
<select onchange="c = document.getElementById('chSelect'); location.href = 'chapter.php?id=' + c.value;"
class="col-span-3" id="chSelect">
{foreach from=$chapters item=item key=key name=name}
<option value="{$item.id}" {if $item.id == $chapter.id}selected{/if}>
{formatChapterTitle($item.volume, $item.number, "short")}</option>
{/foreach}
</select>
<select
onchange="s = document.getElementById('pageSelect'); Cookies.set('{cat($config.title)}_readingmode', s.value); location.href = 'chapter.php?id={$chapter.id}&page=1';"
class="col-span-2" id="pageSelect">
<option value="strip" selected>All Pages</option>
<option value="single">Single Page</option>
</select>
{if $prevChapter || $nextChapter}
<a href="{if $prevChapter}chapter.php?id={$prevChapter}{else}title.php?id={$title.id}{/if}"
class="col-span-2 p-2 border border-black text-center hover:bg-gray-200">{if $prevChapter}Previous{else}Title{/if}</a>
<a href="{if $nextChapter}chapter.php?id={$nextChapter}{else}title.php?id={$title.id}{/if}"
class="col-span-2 p-2 border border-black text-center hover:bg-gray-200">{if $nextChapter}Next{else}Title{/if}</a>
{else}
<a href="title.php?id={$title.id}"
class="col-span-4 p-2 border border-black text-center hover:bg-gray-200">Title</a>
{/if}
{else}
<select onchange="c = document.getElementById('chSelect'); location.href = 'chapter.php?id=' + c.value;"
class="col-span-2" id="chSelect">
{foreach from=$chapters item=item key=key name=name}
<option value="{$item.id}" {if $item.id == $chapter.id}selected{/if}>
{formatChapterTitle($item.volume, $item.number, "short")}</option>
{/foreach}
</select>
<select
onchange="s = document.getElementById('pageSelect'); Cookies.set('{cat($config.title)}_readingmode', s.value); location.href = 'chapter.php?id={$chapter.id}';"
class="col-span-2" id="pageSelect">
<option value="strip">All Pages</option>
<option value="single" selected>Single Page</option>
</select>
<select
onchange="this.options[this.selectedIndex].value&&window.open('chapter.php?id={$chapter.id}&page=' + this.options[this.selectedIndex].value,'_self')"
class="col-span-1">
{foreach from=$imgind item=item key=key name=name}
<option value="{$item.order}" {if $item.order == $currentPage}selected{/if}>
{$item.order}{if $item.order == $currentPage}/{count($images)}{/if}</option>
{/foreach}
</select>
{if $prevChapter || $nextChapter}
<a href="{if $prevChapter}chapter.php?id={$prevChapter}{else}title.php?id={$title.id}{/if}"
class="col-span-2 p-2 border border-black text-center hover:bg-gray-200">{if $prevChapter}Previous{else}Title{/if}</a>
<a href="{if $nextChapter}chapter.php?id={$nextChapter}{else}title.php?id={$title.id}{/if}"
class="col-span-2 p-2 border border-black text-center hover:bg-gray-200">{if $nextChapter}Next{else}Title{/if}</a>
{else}
<a href="title.php?id={$title.id}"
class="col-span-4 p-2 border border-black text-center hover:bg-gray-200">Title</a>
{/if}
{/if}
</div>
<hr class="w-full my-2">
</div>
<div class="col-span-1"></div>
{if $readingMode == "strip"}
<div class="col-span-2" onclick="scrollPx(-800)"></div>
{else}
<a href="chapter.php?id={$chapter.id}&page={$currentPage - 1}" class="col-span-2">
</a>
{/if}
<div class="col-span-8 cursor-pointer" onclick="toggleCheck('chapterModal');">
{if $readingMode == "strip"}
{foreach from=$images item=item key=key name=name}
<img src="data/chapters/{$chapter.id}/{basename($item)}" alt="Page {$key + 1}" class="w-full mx-auto">
{/foreach}
{else}
<img src="data/chapters/{$chapter.id}/{$imgind.$currentPage.order}.{$imgind.$currentPage.ext}"
alt="Page {$currentPage}" class="w-full mx-auto">
{/if}
</div>
{if $readingMode == "strip"}
<div class="col-span-2" onclick="scrollPx(800)"></div>
{else}
<a href="chapter.php?id={$chapter.id}&page={$currentPage + 1}" class="col-span-2">
</a>
{/if}
<div class="col-span-1"></div>
<div class="col-span-10">
<hr class="w-full my-2">
<div class="w-full grid grid-cols-9 gap-2">
{if $readingMode == "strip"}
<select onchange="c = document.getElementById('chSelect'); location.href = 'chapter.php?id=' + c.value;"
class="col-span-3" id="chSelect">
{foreach from=$chapters item=item key=key name=name}
<option value="{$item.id}" {if $item.id == $chapter.id}selected{/if}>
{formatChapterTitle($item.volume, $item.number, "short")}</option>
{/foreach}
</select>
<select
onchange="s = document.getElementById('pageSelect'); Cookies.set('{cat($config.title)}_readingmode', s.value); location.href = 'chapter.php?id={$chapter.id}&page=1';"
class="col-span-2" id="pageSelect">
<option value="strip" selected>All Pages</option>
<option value="single">Single Page</option>
</select>
{if $prevChapter || $nextChapter}
<a href="{if $prevChapter}chapter.php?id={$prevChapter}{else}title.php?id={$title.id}{/if}"
class="col-span-2 p-2 border border-black text-center hover:bg-gray-200">{if $prevChapter}Previous{else}Title{/if}</a>
<a href="{if $nextChapter}chapter.php?id={$nextChapter}{else}title.php?id={$title.id}{/if}"
class="col-span-2 p-2 border border-black text-center hover:bg-gray-200">{if $nextChapter}Next{else}Title{/if}</a>
{else}
<a href="title.php?id={$title.id}"
class="col-span-4 p-2 border border-black text-center hover:bg-gray-200">Title</a>
{/if}
{else}
<select onchange="c = document.getElementById('chSelect'); location.href = 'chapter.php?id=' + c.value;"
class="col-span-2" id="chSelect">
{foreach from=$chapters item=item key=key name=name}
<option value="{$item.id}" {if $item.id == $chapter.id}selected{/if}>
{formatChapterTitle($item.volume, $item.number, "short")}</option>
{/foreach}
</select>
<select
onchange="s = document.getElementById('pageSelect'); Cookies.set('{cat($config.title)}_readingmode', s.value); location.href = 'chapter.php?id={$chapter.id}';"
class="col-span-2" id="pageSelect">
<option value="strip">All Pages</option>
<option value="single" selected>Single Page</option>
</select>
<select
onchange="this.options[this.selectedIndex].value&&window.open('chapter.php?id={$chapter.id}&page=' + this.options[this.selectedIndex].value,'_self')"
class="col-span-1">
{foreach from=$imgind item=item key=key name=name}
<option value="{$item.order}" {if $item.order == $currentPage}selected{/if}>
{$item.order}{if $item.order == $currentPage}/{count($images)}{/if}</option>
{/foreach}
</select>
{if $prevChapter || $nextChapter}
<a href="{if $prevChapter}chapter.php?id={$prevChapter}{else}title.php?id={$title.id}{/if}"
class="col-span-2 p-2 border border-black text-center hover:bg-gray-200">{if $prevChapter}Previous{else}Title{/if}</a>
<a href="{if $nextChapter}chapter.php?id={$nextChapter}{else}title.php?id={$title.id}{/if}"
class="col-span-2 p-2 border border-black text-center hover:bg-gray-200">{if $nextChapter}Next{else}Title{/if}</a>
{else}
<a href="title.php?id={$title.id}"
class="col-span-4 p-2 border border-black text-center hover:bg-gray-200">Title</a>
{/if}
{/if}
</div>
<hr class="w-full my-2">
<h2 class="text-2xl flex">
{$fullChapterTitle}
<label class="swap swap-flip">
<input type="checkbox" onchange="toggleRead({$chapter.id});toggleCheck('readBox{$chapter.id}');toggleCheck('readBox{$chapter.id}Modal');"
id="readBox{$chapter.id}0" {if $logged && in_array($chapter.id, $readChapters)}checked{/if}>
<div class="swap-on">&#9989;</div>
<div class="swap-off">&#10060;</div>
</label>
</h2>
<h1 class="text-3xl"><a href="title.php?id={$title.id}" class="text-blue-500 hover:underline">{$title.title}</a>
</h1>
</div>
<div class="col-span-1"></div>
</div>
<input type="checkbox" id="chapterModal" class="modal-toggle" />
<div class="modal modal-bottom sm:modal-middle">
<div class="modal-box">
<h1 class="text-3xl"><a href="title.php?id={$title.id}" class="text-blue-500 hover:underline">{$title.title}</a>
</h1>
<h2 class="text-2xl flex">
{$fullChapterTitle}
<label class="swap swap-flip">
<input type="checkbox" onchange="toggleRead({$chapter.id});toggleCheck('readBox{$chapter.id}0');toggleCheck('readBox{$chapter.id}');"
id="readBox{$chapter.id}Modal" {if $logged && in_array($chapter.id, $readChapters)}checked{/if}>
<div class="swap-on">&#9989;</div>
<div class="swap-off">&#10060;</div>
</label>
</h2>
<hr class="w-full my-2">
<div class="w-full grid grid-cols-8 gap-2">
{if $readingMode == "strip"}
<select
onchange="c = document.getElementById('chSelectModal'); location.href = 'chapter.php?id=' + c.value;"
class="col-span-8 p-2 border border-black rounded-lg" id="chSelectModal">
{foreach from=$chapters item=item key=key name=name}
<option value="{$item.id}" {if $item.id == $chapter.id}selected{/if}>
{formatChapterTitle($item.volume, $item.number, "full")}</option>
{/foreach}
</select>
<select
onchange="s = document.getElementById('pageSelectModal'); Cookies.set('{cat($config.title)}_readingmode', s.value); location.href = 'chapter.php?id={$chapter.id}&page=1';"
class="col-span-8 p-2 rounded-lg border-1 border border-black" id="pageSelectModal">
<option value="strip" selected>All Pages</option>
<option value="single">Single Page</option>
</select>
{if $prevChapter || $nextChapter}
<a href="{if $prevChapter}chapter.php?id={$prevChapter}{else}title.php?id={$title.id}{/if}"
class="col-span-4 p-2 rounded-lg border border-black text-center hover:bg-gray-200">{if $prevChapter}Previous{else}Title{/if}</a>
<a href="{if $nextChapter}chapter.php?id={$nextChapter}{else}title.php?id={$title.id}{/if}"
class="col-span-4 p-2 rounded-lg border border-black text-center hover:bg-gray-200">{if $nextChapter}Next{else}Title{/if}</a>
{else}
<a href="title.php?id={$title.id}"
class="col-span-8 p-2 rounded-lg border border-black text-center hover:bg-gray-200">Title</a>
{/if}
<label for="chapterModal" class="btn col-span-8">Close</label>
{else}
<select
onchange="c = document.getElementById('chSelectModal'); location.href = 'chapter.php?id=' + c.value;"
class="col-span-8 p-2 border border-black rounded-lg" id="chSelectModal">
{foreach from=$chapters item=item key=key name=name}
<option value="{$item.id}" {if $item.id == $chapter.id}selected{/if}>
{formatChapterTitle($item.volume, $item.number, "full")}</option>
{/foreach}
</select>
<select
onchange="s = document.getElementById('pageSelectModal'); Cookies.set('{cat($config.title)}_readingmode', s.value); location.href = 'chapter.php?id={$chapter.id}';"
class="col-span-4 p-2 border border-black rounded-lg" id="pageSelectModal">
<option value="strip">All Pages</option>
<option value="single" selected>Single Page</option>
</select>
<select
onchange="this.options[this.selectedIndex].value&&window.open('chapter.php?id={$chapter.id}&page=' + this.options[this.selectedIndex].value,'_self')"
class="col-span-4 p-2 border border-black rounded-lg">
{foreach from=$imgind item=item key=key name=name}
<option value="{$item.order}" {if $item.order == $currentPage}selected{/if}>
{$item.order}{if $item.order == $currentPage}/{count($images)}{/if}</option>
{/foreach}
</select>
{if $prevChapter || $nextChapter}
<a href="{if $prevChapter}chapter.php?id={$prevChapter}{else}title.php?id={$title.id}{/if}"
class="col-span-4 rounded-lg p-2 border border-black text-center hover:bg-gray-200">{if $prevChapter}Previous{else}Title{/if}</a>
<a href="{if $nextChapter}chapter.php?id={$nextChapter}{else}title.php?id={$title.id}{/if}"
class="col-span-4 rounded-lg p-2 border border-black text-center hover:bg-gray-200">{if $nextChapter}Next{else}Title{/if}</a>
{else}
<a href="title.php?id={$title.id}"
class="col-span-8 rounded-lg p-2 border border-black text-center hover:bg-gray-200">Title</a>
{/if}
<label for="chapterModal" class="btn col-span-8">Close</label>
{/if}
</div>
</div>
</div>
<script>
function scrollPx(px) {
var y = $(window).scrollTop();
$("html, body").animate({
scrollTop: y + px
}, 600);
}
</script>

View File

@ -480,7 +480,7 @@
<!-- Title Data-->
<input name="id" value="{$title.id}" hidden>
<input name="cover" value="{$title.cover}" hidden>
<input id="formCoverInput" name="cover" value="" hidden>
<input type="text" value="{$title.title}" placeholder="Title" name="title"
class="input w-full border border-black" title="Title">
<input type="text" value="{$title.alts}" placeholder="Alternate Names" name="alts"
@ -622,6 +622,14 @@
$(function() {
$("#cover").change(function(e) {
e.preventDefault();
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) {
@ -636,7 +644,6 @@
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;
@ -646,19 +653,11 @@
}
});
}
}
});
});
$("#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();

View File

@ -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()
);

View File

@ -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()
);

View File

@ -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()
);

View File

@ -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,

View File

@ -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");

View File

@ -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"]);

View File

@ -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++) {

View File

@ -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);

View File

@ -1 +1 @@
v0.3.0-alpha
v0.3.1-alpha