librex/settings.php

110 lines
4.8 KiB
PHP
Raw Normal View History

<?php require "misc/header.php"; ?>
2022-03-09 09:18:24 -03:00
<title>LibreX - Settings</title>
</head>
2022-03-10 07:18:07 -03:00
<body>
<div class="misc-container">
2022-03-10 07:18:07 -03:00
<h1>Settings</h1>
<form method="post" enctype="multipart/form-data" autocomplete="off">
<div>
2022-03-10 07:18:07 -03:00
<label for="theme">Theme:</label>
<select name="theme">
<?php
$themes = "<option value=\"dark\">Dark</option>
2022-03-10 07:18:07 -03:00
<option value=\"light\">Light</option>
<option value=\"auto\">Auto</option>
2022-03-10 07:18:07 -03:00
<option value=\"nord\">Nord</option>
<option value=\"night_owl\">Night Owl</option>
<option value=\"discord\">Discord</option>";
2022-03-09 09:18:24 -03:00
2022-03-10 07:18:07 -03:00
if (isset($_COOKIE["theme"]))
{
2022-03-10 07:18:07 -03:00
$cookie_theme = $_COOKIE["theme"];
$themes = str_replace($cookie_theme . "\"", $cookie_theme . "\" selected", $themes);
}
2022-03-09 09:18:24 -03:00
2022-03-10 07:18:07 -03:00
echo $themes;
?>
</select>
</div>
2022-03-10 07:18:07 -03:00
<h2>Privacy friendly frontends</h2>
<p>For an example if you want to view YouTube without getting spied on, click on "Invidious", find the instance that is most suitable for you then paste it in (correct format: https://url.domain)</p>
2022-03-10 07:18:07 -03:00
<div class="instances-container">
<div>
<a for="invidious" href="https://docs.invidious.io/Invidious-Instances/" target="_blank">Invidious</a>
<input type="text" name="invidious" placeholder="Replace YouTube" value=
<?php echo isset($_COOKIE["invidious"]) ? $_COOKIE["invidious"] : "\"\""; ?>
>
</div>
<div>
<a for="bibliogram" href="https://git.sr.ht/~cadence/bibliogram-docs/tree/master/docs/Instances.md" target="_blank">Bibliogram</a>
<input type="text" name="bibliogram" placeholder="Replace Instagram" value=
<?php echo isset($_COOKIE["bibliogram"]) ? $_COOKIE["bibliogram"] : "\"\""; ?>
>
</div>
<div>
<a for="nitter" href="https://github.com/zedeus/nitter/wiki/Instances" target="_blank">Nitter</a>
<input type="text" name="nitter" placeholder="Replace Twitter" value=
<?php echo isset($_COOKIE["nitter"]) ? $_COOKIE["nitter"] : "\"\""; ?>
>
</div>
<div>
<a for="libreddit" href="https://github.com/spikecodes/libreddit" target="_blank">Libreddit</a>
<input type="text" name="libreddit" placeholder="Replace Reddit" value=
<?php echo isset($_COOKIE["libreddit"]) ? $_COOKIE["libreddit"] : "\"\""; ?>
>
</div>
</div>
<div>
<button type="submit" name="save" value="1">Save</button>
<button type="submit" name="reset" value="1">Reset</button>
2022-03-10 07:18:07 -03:00
</div>
</form>
2022-03-09 09:18:24 -03:00
2022-03-10 07:18:07 -03:00
<?php
if (isset($_REQUEST["save"]))
{
if (!empty($_REQUEST["invidious"]))
2022-03-17 15:39:33 -03:00
setcookie("invidious", $_REQUEST["invidious"], time() + (86400 * 90));
2022-03-09 09:18:24 -03:00
2022-03-10 07:18:07 -03:00
if (!empty($_REQUEST["bibliogram"]))
2022-03-17 15:39:33 -03:00
setcookie("bibliogram", $_REQUEST["bibliogram"], time() + (86400 * 90));
2022-03-09 09:18:24 -03:00
2022-03-10 07:18:07 -03:00
if (!empty($_REQUEST["nitter"]))
2022-03-17 15:39:33 -03:00
setcookie("nitter", $_REQUEST["nitter"], time() + (86400 * 90));
2022-03-09 09:18:24 -03:00
2022-03-10 07:18:07 -03:00
if (!empty($_REQUEST["libreddit"]))
2022-03-17 15:39:33 -03:00
setcookie("libreddit", $_REQUEST["libreddit"], time() + (86400 * 90));
2022-03-09 09:18:24 -03:00
2022-03-17 15:39:33 -03:00
setcookie("theme", $_REQUEST["theme"], time() + (86400 * 90));
2022-03-09 09:18:24 -03:00
2022-03-10 07:18:07 -03:00
header("Location: /settings.php");
die();
}
else if (isset($_REQUEST["reset"]))
{
if (isset($_SERVER["HTTP_COOKIE"])) {
$cookies = explode(";", $_SERVER["HTTP_COOKIE"]);
2022-03-10 07:18:07 -03:00
foreach($cookies as $cookie) {
$parts = explode("=", $cookie);
2022-03-10 07:18:07 -03:00
$name = trim($parts[0]);
setcookie($name, "", time()-1000);
setcookie($name, "", time()-1000, "/");
2022-03-10 07:18:07 -03:00
}
2022-03-09 09:18:24 -03:00
2022-03-10 07:18:07 -03:00
header("Location: /settings.php");
die();
}
}
?>
</div>
2022-03-09 09:18:24 -03:00
<?php require "misc/footer.php"; ?>