settings.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. require "misc/header.php";
  3. function better_setcookie($name)
  4. {
  5. if (!empty($_REQUEST[$name]))
  6. setcookie($name, $_REQUEST[$name], time() + (86400 * 90));
  7. else if (isset($_COOKIE[$name]))
  8. setcookie($name, "", time() - 1000);
  9. }
  10. if (isset($_REQUEST["save"]))
  11. {
  12. better_setcookie("theme");
  13. better_setcookie("disable_special");
  14. better_setcookie("invidious");
  15. better_setcookie("bibliogram");
  16. better_setcookie("nitter");
  17. better_setcookie("libreddit");
  18. header("Location: /settings.php");
  19. die();
  20. }
  21. else if (isset($_REQUEST["reset"]))
  22. {
  23. if (isset($_SERVER["HTTP_COOKIE"])) {
  24. $cookies = explode(";", $_SERVER["HTTP_COOKIE"]);
  25. foreach($cookies as $cookie) {
  26. $parts = explode("=", $cookie);
  27. $name = trim($parts[0]);
  28. setcookie($name, "", time() - 1000);
  29. }
  30. header("Location: /settings.php");
  31. die();
  32. }
  33. }
  34. ?>
  35. <title>LibreX - Settings</title>
  36. </head>
  37. <body>
  38. <div class="misc-container">
  39. <h1>Settings</h1>
  40. <form method="post" enctype="multipart/form-data" autocomplete="off">
  41. <div>
  42. <label for="theme">Theme:</label>
  43. <select name="theme">
  44. <?php
  45. $themes = "<option value=\"dark\">Dark</option>
  46. <option value=\"light\">Light</option>
  47. <option value=\"auto\">Auto</option>
  48. <option value=\"nord\">Nord</option>
  49. <option value=\"night_owl\">Night Owl</option>
  50. <option value=\"discord\">Discord</option>";
  51. if (isset($_COOKIE["theme"]))
  52. {
  53. $cookie_theme = $_COOKIE["theme"];
  54. $themes = str_replace($cookie_theme . "\"", $cookie_theme . "\" selected", $themes);
  55. }
  56. echo $themes;
  57. ?>
  58. </select>
  59. </div>
  60. <div>
  61. <label for="special">Disable special queries (e.g.: currency conversion)</label>
  62. <input type="checkbox" name="disable_special"
  63. <?php echo isset($_COOKIE["disable_special"]) ? "checked" : "\"\""; ?>
  64. >
  65. </div>
  66. <h2>Privacy friendly frontends</h2>
  67. <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://example.com)</p>
  68. <div class="instances-container">
  69. <div>
  70. <a for="invidious" href="https://docs.invidious.io/Invidious-Instances/" target="_blank">Invidious</a>
  71. <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=
  72. <?php echo isset($_COOKIE["invidious"]) ? $_COOKIE["invidious"] : "\"\""; ?>
  73. >
  74. </div>
  75. <div>
  76. <a for="bibliogram" href="https://git.sr.ht/~cadence/bibliogram-docs/tree/master/docs/Instances.md" target="_blank">Bibliogram</a>
  77. <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=
  78. <?php echo isset($_COOKIE["bibliogram"]) ? $_COOKIE["bibliogram"] : "\"\""; ?>
  79. >
  80. </div>
  81. <div>
  82. <a for="nitter" href="https://github.com/zedeus/nitter/wiki/Instances" target="_blank">Nitter</a>
  83. <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=
  84. <?php echo isset($_COOKIE["nitter"]) ? $_COOKIE["nitter"] : "\"\""; ?>
  85. >
  86. </div>
  87. <div>
  88. <a for="libreddit" href="https://github.com/spikecodes/libreddit" target="_blank">Libreddit</a>
  89. <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=
  90. <?php echo isset($_COOKIE["libreddit"]) ? $_COOKIE["libreddit"] : "\"\""; ?>
  91. >
  92. </div>
  93. </div>
  94. <div>
  95. <button type="submit" name="save" value="1">Save</button>
  96. <button type="submit" name="reset" value="1">Reset</button>
  97. </div>
  98. <div>
  99. <?php
  100. if (!empty($_COOKIE))
  101. {
  102. echo "<p>If you use the Tor browser or just regularly delete cookies you can also set the settings as a query param:</p>";
  103. $url = "?";
  104. foreach ($_COOKIE as $key => $value)
  105. $url .= "&$key=$value";
  106. $url = substr_replace($url, "", 1, 1);
  107. echo $url;
  108. }
  109. ?>
  110. </div>
  111. </form>
  112. </div>
  113. <?php require "misc/footer.php"; ?>