|
@@ -1,4 +1,44 @@
|
|
|
-<?php require "misc/header.php"; ?>
|
|
|
+
|
|
|
+ <?php
|
|
|
+ require "misc/header.php";
|
|
|
+
|
|
|
+ function better_setcookie($name)
|
|
|
+ {
|
|
|
+ if (!empty($_REQUEST[$name]))
|
|
|
+ setcookie($name, $_REQUEST[$name], time() + (86400 * 90));
|
|
|
+ else if (isset($_COOKIE[$name]))
|
|
|
+ setcookie($name, "", time() - 1000);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isset($_REQUEST["save"]))
|
|
|
+ {
|
|
|
+ better_setcookie("theme");
|
|
|
+
|
|
|
+ better_setcookie("disable_special");
|
|
|
+
|
|
|
+ better_setcookie("invidious");
|
|
|
+ better_setcookie("bibliogram");
|
|
|
+ better_setcookie("nitter");
|
|
|
+ better_setcookie("libreddit");
|
|
|
+
|
|
|
+ header("Location: /settings.php");
|
|
|
+ die();
|
|
|
+ }
|
|
|
+ else if (isset($_REQUEST["reset"]))
|
|
|
+ {
|
|
|
+ if (isset($_SERVER["HTTP_COOKIE"])) {
|
|
|
+ $cookies = explode(";", $_SERVER["HTTP_COOKIE"]);
|
|
|
+ foreach($cookies as $cookie) {
|
|
|
+ $parts = explode("=", $cookie);
|
|
|
+ $name = trim($parts[0]);
|
|
|
+ setcookie($name, "", time() - 1000);
|
|
|
+ }
|
|
|
+
|
|
|
+ header("Location: /settings.php");
|
|
|
+ die();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ?>
|
|
|
|
|
|
<title>LibreX - Settings</title>
|
|
|
</head>
|
|
@@ -10,7 +50,6 @@
|
|
|
<label for="theme">Theme:</label>
|
|
|
<select name="theme">
|
|
|
<?php
|
|
|
-
|
|
|
$themes = "<option value=\"dark\">Dark</option>
|
|
|
<option value=\"light\">Light</option>
|
|
|
<option value=\"auto\">Auto</option>
|
|
@@ -27,35 +66,41 @@
|
|
|
echo $themes;
|
|
|
?>
|
|
|
</select>
|
|
|
- </div>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <label for="special">Disable special queries (e.g.: currency conversion)</label>
|
|
|
+ <input type="checkbox" name="disable_special"
|
|
|
+ <?php echo isset($_COOKIE["disable_special"]) ? "checked" : "\"\""; ?>
|
|
|
+ >
|
|
|
+ </div>
|
|
|
<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:
|
|
|
+ <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:
|
|
|
<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=
|
|
|
+ <input pattern="https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)" 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=
|
|
|
+ <input pattern="https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)" 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=
|
|
|
+ <input pattern="https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)" 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=
|
|
|
+ <input pattern="https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*)" type="text" name="libreddit" placeholder="Replace Reddit" value=
|
|
|
<?php echo isset($_COOKIE["libreddit"]) ? $_COOKIE["libreddit"] : "\"\""; ?>
|
|
|
>
|
|
|
</div>
|
|
@@ -64,46 +109,24 @@
|
|
|
<button type="submit" name="save" value="1">Save</button>
|
|
|
<button type="submit" name="reset" value="1">Reset</button>
|
|
|
</div>
|
|
|
- </form>
|
|
|
-
|
|
|
-
|
|
|
- <?php
|
|
|
- if (isset($_REQUEST["save"]))
|
|
|
- {
|
|
|
- if (!empty($_REQUEST["invidious"]))
|
|
|
- setcookie("invidious", $_REQUEST["invidious"], time() + (86400 * 90));
|
|
|
-
|
|
|
- if (!empty($_REQUEST["bibliogram"]))
|
|
|
- setcookie("bibliogram", $_REQUEST["bibliogram"], time() + (86400 * 90));
|
|
|
-
|
|
|
- if (!empty($_REQUEST["nitter"]))
|
|
|
- setcookie("nitter", $_REQUEST["nitter"], time() + (86400 * 90));
|
|
|
-
|
|
|
- if (!empty($_REQUEST["libreddit"]))
|
|
|
- setcookie("libreddit", $_REQUEST["libreddit"], time() + (86400 * 90));
|
|
|
+ <div>
|
|
|
+ <?php
|
|
|
+ if (!empty($_COOKIE))
|
|
|
+ {
|
|
|
+ echo "<p>If you use the Tor browser or just regularly delete cookies you can also set the settings as a query param:</p>";
|
|
|
|
|
|
+ $url = "?";
|
|
|
|
|
|
- setcookie("theme", $_REQUEST["theme"], time() + (86400 * 90));
|
|
|
+ foreach ($_COOKIE as $key => $value)
|
|
|
+ $url .= "&$key=$value";
|
|
|
+
|
|
|
+ $url = substr_replace($url, "", 1, 1);
|
|
|
|
|
|
- header("Location: /settings.php");
|
|
|
- die();
|
|
|
- }
|
|
|
- else if (isset($_REQUEST["reset"]))
|
|
|
- {
|
|
|
- if (isset($_SERVER["HTTP_COOKIE"])) {
|
|
|
- $cookies = explode(";", $_SERVER["HTTP_COOKIE"]);
|
|
|
- foreach($cookies as $cookie) {
|
|
|
- $parts = explode("=", $cookie);
|
|
|
- $name = trim($parts[0]);
|
|
|
- setcookie($name, "", time()-1000);
|
|
|
- setcookie($name, "", time()-1000, "/");
|
|
|
+ echo $url;
|
|
|
}
|
|
|
-
|
|
|
- header("Location: /settings.php");
|
|
|
- die();
|
|
|
- }
|
|
|
- }
|
|
|
- ?>
|
|
|
+ ?>
|
|
|
+ </div>
|
|
|
+ </form>
|
|
|
</div>
|
|
|
|
|
|
<?php require "misc/footer.php"; ?>
|