FoOlSlideX/public/install.php
2023-05-30 15:51:43 +02:00

328 lines
16 KiB
PHP

<?php
require "../funky.php";
if (file_exists(ps(__DIR__ . "/../.installed")))
die("System already installed!");
require_once "../config.php";
if ($config["email"] == "saintly@h33t.moe")
die("You haven't edited the config.php file yet.");
require_once "../library/plugins/userLangs.php";
$userlang = cat($_COOKIE[cat("fsx_lang")] ?? $config["default"]["lang"]);
if (file_exists("../library/langs/" . $userlang . ".php"))
require "../library/langs/" . $userlang . ".php";
else
require "../library/langs/" . $config["default"]["lang"] . ".php";
$key = null;
if (isset($_POST["install"])) {
$time = time();
$key = genUuid();
$file = fopen("../library/secrets/started.txt", "w");
fwrite($file, $time);
fclose($file);
$file = fopen("../library/secrets/key.txt", "w");
fwrite($file, $key);
fclose($file);
header("Location: ?step=4");
}
if (isset($_GET["cleanup"])) {
$file = fopen("../.installed", "w");
fclose($file);
if (!file_exists(ps(__DIR__ . "/../library/secrets/key.txt")))
die("Failed to create file. Make sure you have chmod set on 777 on this whole software. Try again.");
if (!file_exists(ps(__DIR__ . "/../library/secrets/started.txt")))
die("Failed to create file. Make sure you have chmod set on 777 on this whole software. Try again.");
$key = file_get_contents(ps(__DIR__ . "/../library/secrets/key.txt"));
$actualLink = (empty($_SERVER['HTTPS']) ? 'http' : 'https') . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]";
// Generated by Postman :)
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "http://api.h33t.moe/api.php?action=fsx_installation&key={$key}&domain={$actualLink}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
));
$response = curl_exec($curl);
// print_r($response);
unlink("install.php");
header("Refresh: 2; url=index.php");
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>FoOlSlideX Installation</title>
<link href="https://cdn.jsdelivr.net/npm/daisyui@2.51.5/dist/full.css" rel="stylesheet" type="text/css" />
<script src="https://cdn.tailwindcss.com"></script>
<script src="assets/js.cookie.js"></script>
<link rel="apple-touch-icon" sizes="180x180" href="assets/favicon/apple-touch-icon.png">
<link rel="icon" type="image/png" sizes="32x32" href="assets/favicon/favicon-32x32.png">
<link rel="icon" type="image/png" sizes="16x16" href="assets/favicon/favicon-16x16.png">
<link rel="manifest" href="assets/favicon/site.webmanifest">
<style>
.auto a {
text-decoration-line: underline;
text-decoration-style: dotted;
}
.auto a:hover {
text-decoration-style: solid;
}
</style>
</head>
<body onload="assignTheme('fsx_');" class="min-h-screen">
<div class="container mx-auto">
<a href="install.php" title="Click to reset installation">
<img src="assets/nucleus/logo.png" alt="FoOlSlideX Logo" class="h-20 mx-auto">
</a>
<p class="text-center">
Developed by
<a href="https://github.com/saintly2k" class="link" target="_blank">Saintly2k</a> and
<a href="https://github.com/saintly2k/FoOlSlideX/graphs/contributors" class="link" target="_blank">The
Gang</a>.
</p>
<hr class="my-3 border-black">
<div class="text-center mb-3">
<ul class="steps lg:steps-vertical steps-horizontal">
<li class="step <?= isset($_GET["step"]) && !empty($_GET["step"]) && $_GET["step"] >= 1 ? "step-primary" : "step-info" ?>">Requirements</li>
<li class="step <?= isset($_GET["step"]) && !empty($_GET["step"]) && $_GET["step"] >= 1 ? ($_GET["step"] == 1 ? "step-primary step-info" : "step-primary") : "" ?>">Credits</li>
<!-- <li class="step <?= isset($_GET["step"]) && !empty($_GET["step"]) && $_GET["step"] >= 2 ? ($_GET["step"] == 2 ? "step-primary step-info" : "step-primary") : "" ?>">Configuration</li> -->
<li class="step <?= isset($_GET["step"]) && !empty($_GET["step"]) && $_GET["step"] >= 3 ? ($_GET["step"] == 3 ? "step-primary step-info" : "step-primary") : "" ?>">Installation</li>
<li class="step <?= isset($_GET["step"]) && !empty($_GET["step"]) && $_GET["step"] >= 4 ? ($_GET["step"] == 4 ? "step-primary step-success" : "step-primary") : "" ?>">Finish</li>
</ul>
</div>
<?php if (!isset($_GET["step"]) || (isset($_GET["step"]) && !empty($_GET["step"]) && $_GET["step"] == 0)) { ?>
<h1 class="text-3xl text-center font-bold">Requirements</h1>
<div class="md:w-[400px] mx-auto px-2 md:px-0">
<div class="auto">
<p>
Before you start, please make sure that you edited the <code>config.php</code> file in the root directory properly. If you did not, you can use this installer just fine but it will fail to initiate some things, so please do it.
</p>
<p class="mt-2">
If you have some questions, <a href="https://discord.gg/uahG2fKVvg" target="_blank">join the Discord</a> and ask in <code>#foolslidex</code> for help. We'll try to answer as soon as possible.
</p>
</div>
<a href="?step=1" class="btn btn-primary mt-2 w-full">
Continue
</a>
</div>
<?php } ?>
<?php if (isset($_GET["step"]) && !empty($_GET["step"]) && $_GET["step"] == 1) { ?>
<h1 class="text-3xl text-center font-bold">Credits</h1>
<div class="md:w-[400px] mx-auto px-2 md:px-0">
<div class="auto">
<p>
<a href="https://github.com/saintly2k/FoOlSlideX" target="_blank">FoOlSlideX</a> is an open-source software for sharing and reading comics of all kinds.
</p>
<p class="mt-2">
It has been developed by the following people:
</p>
<ul class="list-disc list-inside">
<li><a href="https://github.com/saintly2k" target="_blank">Saintly2k</a></li>
<li><a href="https://github.com/s-vhs" target="_blank">S-VHS</a></li>
<li><a href="https://github.com/kaligula-eu" target="_blank">Kaligula</a></li>
</ul>
<p class="mt-2">
It makes use of the following technologies and softwares:
</p>
<ul class="list-disc list-inside">
<li><a href="https://www.php.net" target="_blank">PHP</a> as framework of my choice</li>
<li><a href="http://htmlpurifier.org" target="_blank">HTMLPurifier</a> to sanitize user-input</li>
<li><a href="https://github.com/PHPMailer/PHPMailer" target="_blank">PHPMailer/PHPMailer</a> for sending Emails</li>
<li><a href="https://github.com/rakibtg/SleekDB" target="_blank">rakibtg/SleekDB</a> as Database-software</li>
<li><a href="https://github.com/smarty-php/smarty" target="_blank">smarty-php/smarty</a> as template-engine</li>
<li><a href="https://github.com/erusev/parsedown" target="_blank">erusev/parsedown</a> for perfect parsedown</li>
</ul>
</div>
<a href="?step=3" class="btn btn-primary mt-2 w-full">
Continue
</a>
</div>
<div class="md:w-[400px] mx-auto auto px-2 md:px-0">
<p class="mt-2">
To support the lead developers, <a href="https://github.com/saintly2k" target="_blank">Saintly2k</a>, <a href="https://github.com/kaligula-eu" target="_blank">Kaligula</a> and <a href="https://github.com/s-vhs" target="_blank">S-VHS</a>, please consider donating:
</p>
<div class="grid grid-cols-2 gap-2 mt-1 mx-auto">
<div>
<a href="https://ko-fi.com/saintly" target="_target">
<img src="assets/other/kofi_s_tag_white.png" alt="Donate through Ko-fi" class="w-full">
</a>
</div>
<div>
<a href="https://paypal.me/WOLFRAMEdev" target="_target">
<img src="assets/other/paypal-donate-button.png" alt="Donate through PayPal" class="w-full">
</a>
</div>
</div>
</div>
<?php } ?>
<!-- <?php if (isset($_GET["step"]) && !empty($_GET["step"]) && $_GET["step"] == 2) { ?>
<h1 class="text-3xl text-center font-bold">Configuration</h1>
<div class="md:w-[400px] mx-auto px-2 md:px-0">
<a href="?step=3" class="btn btn-primary mt-2 w-full">
Continue
</a>
</div>
<?php } ?> -->
<?php if (isset($_GET["step"]) && !empty($_GET["step"]) && $_GET["step"] == 3) { ?>
<h1 class="text-3xl text-center font-bold">Installation</h1>
<div class="md:w-[400px] mx-auto px-2 md:px-0">
<form method="POST" name="install">
<p>There's nothing here to customize <i>yet</i>. Maybe we'll implement something here later on in newer versions.</p>
<input type="submit" name="install" class="btn btn-primary mt-2 w-full bg-primary" value="Continue">
</form>
</div>
<?php } ?>
<?php if (isset($_GET["step"]) && !empty($_GET["step"]) && $_GET["step"] == 4) { ?>
<h1 class="text-3xl text-center font-bold">Installation</h1>
<div class="md:w-[400px] mx-auto px-2 md:px-0">
<p>You're almost done! To finalize your installation, hit the button below.</p>
<a href="?step=5&cleanup" class="btn btn-primary mt-2 w-full">
Finalize
</a>
</div>
<?php } ?>
<?php if (isset($_GET["step"]) && !empty($_GET["step"]) && $_GET["step"] == 5) { ?>
<h1 class="text-3xl text-center font-bold">Finishing</h1>
<div class="md:w-[400px] mx-auto px-2 md:px-0">
<p>
If everything worked, you should be redirected in two seconds...
</p>
</div>
<?php } ?>
<hr class="my-3 border-black">
<p class="auto">
Installing <a href="https://github.com/saintly2k/FoOlSlideX" class="link" target="_blank">FoOlSlideX</a>
<span class="badge badge-info"><?= file_get_contents(ps(__DIR__ . "/../version.txt")) ?></span>
<br class="md:hidden">
by <a href="https://github.com/saintly2k" class="link" target="_blank">Saintly2k</a> and
<a href="https://github.com/saintly2k/FoOlSlideX/graphs/contributors" class="link" target="_blank">The
Gang</a>.
<span class="hidden md:inline">|</span>
<br class="md:hidden">
<label for="themeModal" class="link">Change Design</label> or
<label for="langModal" class="link">Change Language</label>
</p>
</div>
<!-- Theme Modal -->
<input type="checkbox" id="themeModal" class="modal-toggle">
<div class="modal">
<div class="modal-box w-11/12 max-w-5xl">
<h3 class="font-bold text-lg mb-4">Change Design</h3>
<?php $daisyThemes = array("light", "dark", "cupcake", "bumblebee", "emerald", "corporate", "synthwave", "retro", "cyberpunk", "valentine", "halloween", "garden", "forest", "aqua", "lofi", "pastel", "fantasy", "wireframe", "black", "luxury", "dracula", "cmyk", "autumn", "business", "acid", "lemonade", "night", "coffee", "winter"); ?>
<div class="grid grid-cols-2 md:grid-cols-5 gap-1 sm:gap-2 md:gap-4">
<?php foreach ($daisyThemes as $item) { ?>
<div class="col-span-1 border rounded-xl p-1 md:p-2 cursor-pointer bg-base-100" data-theme="<?= $item ?>" onclick="setCookie('daisytheme','<?= $item ?>');assignTheme('fsx_');">
<div class="grid grid-cols-5 grid-rows-2">
<div class="bg-base-200 col-start-1 row-span-1 row-start-1 rounded-tl-md"></div>
<div class="bg-base-300 col-start-1 row-start-2 rounded-bl-md"></div>
<div class="col-span-4 col-start-2 row-span-2 row-start-1 ml-2">
<span class="font-bold"><?= $item ?></span>
<div class="w-full grid grid-cols-4 gap-1 md:gap-2 mt-1 md:mt-2 text-sm">
<button class="btn btn-sm btn-primary">A</button>
<button class="btn btn-sm btn-secondary">A</button>
<button class="btn btn-sm btn-accent">A</button>
<button class="btn btn-sm btn-neutral">A</button>
</div>
</div>
</div>
</div>
<?php } ?>
<label for="themeModal" class="mt-4 md:mt-0 btn col-span-2 md:col-span-5">Close</label>
</div>
</div>
</div>
<!-- /Theme Modal -->
<!-- Language Modal -->
<input type="checkbox" id="langModal" class="modal-toggle">
<div class="modal">
<div class="modal-box w-11/12 max-w-5xl">
<h3 class="font-bold text-lg mb-4">Change Language</h3>
<div class="grid grid-cols-2 md:grid-cols-4 gap-1 sm:gap-2 md:gap-4">
<?php foreach ($_userlangs as $item) { ?>
<div class="col-span-1 border rounded-xl text-center p-1 md:p-2 cursor-pointer bg-base-100" onclick="setCookie('userlang','<?= $item["code"] ?>');updateUserLang('<?= $item["code"] ?>');">
<p class="font-bold text-xl"><?= $item["name"] ?></p>
<p>
by
<?php if (!empty($item["website"])) { ?>
<a href="<?= $item["website"] ?>" target="_blank" class="link">
<?php } ?>
<?= $item["author"] ?>
<?php if (!empty($item["website"])) { ?>
</a>
<?php } ?>
</p>
<p class="italic text-sm">Updated: <?= $item["updated"] ?></p>
</div>
<?php } ?>
<label for="langModal" class="mt-4 md:mt-0 btn col-span-2 md:col-span-4">Close</label>
</div>
</div>
</div>
<!-- /Language Modal -->
<script>
function setCookie(name, value) {
Cookies.set("fsx_" + name, value, {
expires: 999
})
}
function assignTheme(prefix) {
let theme = Cookies.get(prefix + "daisytheme");
document.body.setAttribute("data-theme", theme);
}
function updateUserLang(lang) {
location.reload();
}
</script>
</body>
</html>