settings.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php require "misc/header.php"; ?>
  2. <title>LibreX - Settings</title>
  3. </head>
  4. <body>
  5. <div class="settings-container">
  6. <h1>Settings</h1>
  7. <form method="post" enctype="multipart/form-data" autocomplete="off">
  8. <label for="theme">Theme:</label>
  9. <select name="theme">
  10. <?php
  11. $themes = "<option value=\"auto\">Auto</option>
  12. <option value=\"dark\">Dark</option>
  13. <option value=\"light\">Light</option>
  14. <option value=\"nord\">Nord</option>
  15. <option value=\"night_owl\">Night Owl</option>
  16. <option value=\"discord\">Discord</option>";
  17. if (isset($_COOKIE["theme"]))
  18. {
  19. $cookie_theme = $_COOKIE["theme"];
  20. $themes = str_replace($cookie_theme . "\"", $cookie_theme . "\" selected", $themes);
  21. }
  22. echo $themes;
  23. ?>
  24. </select>
  25. <br><br>
  26. <h2>Privacy friendly frontends</h2>
  27. <p>Replace popular sites with privacy friendly frontends</p>
  28. <div class="instances-container">
  29. <a for="invidious" href="https://docs.invidious.io/Invidious-Instances/" target="_blank">Invidious</a>
  30. <input type="text" name="invidious" placeholder="e.g.: https://yewtu.be" value=
  31. <?php echo isset($_COOKIE["invidious"]) ? $_COOKIE["invidious"] : "\"\""; ?>
  32. >
  33. <br><br>
  34. <a for="bibliogram" href="https://git.sr.ht/~cadence/bibliogram-docs/tree/master/docs/Instances.md" target="_blank">Bibliogram</a>
  35. <input type="text" name="bibliogram" value=
  36. <?php echo isset($_COOKIE["bibliogram"]) ? $_COOKIE["bibliogram"] : "\"\""; ?>
  37. >
  38. <br><br>
  39. <a for="nitter" href="https://github.com/zedeus/nitter/wiki/Instances" target="_blank">Nitter</a>
  40. <input type="text" name="nitter" value=
  41. <?php echo isset($_COOKIE["nitter"]) ? $_COOKIE["nitter"] : "\"\""; ?>
  42. >
  43. <br><br>
  44. <a for="libreddit" href=" https://github.com/spikecodes/libreddit" target="_blank">Libreddit</a>
  45. <input type="text" name="libreddit" value=
  46. <?php echo isset($_COOKIE["libreddit"]) ? $_COOKIE["libreddit"] : "\"\""; ?>
  47. >
  48. </div>
  49. <br>
  50. <button type="submit" name="save" value="1">Save</button>
  51. <button type="submit" name="reset" value="1">Reset</button>
  52. </form>
  53. <?php
  54. if (isset($_REQUEST["save"]))
  55. {
  56. if (!empty($_REQUEST["invidious"]))
  57. setcookie("invidious", $_REQUEST["invidious"]);
  58. if (!empty($_REQUEST["bibliogram"]))
  59. setcookie("bibliogram", $_REQUEST["bibliogram"]);
  60. if (!empty($_REQUEST["nitter"]))
  61. setcookie("nitter", $_REQUEST["nitter"]);
  62. if (!empty($_REQUEST["libreddit"]))
  63. setcookie("libreddit", $_REQUEST["libreddit"]);
  64. setcookie("theme", $_REQUEST["theme"]);
  65. header("Location: /settings.php");
  66. die();
  67. }
  68. else if (isset($_REQUEST["reset"]))
  69. {
  70. if (isset($_SERVER['HTTP_COOKIE'])) {
  71. $cookies = explode(';', $_SERVER['HTTP_COOKIE']);
  72. foreach($cookies as $cookie) {
  73. $parts = explode('=', $cookie);
  74. $name = trim($parts[0]);
  75. setcookie($name, '', time()-1000);
  76. setcookie($name, '', time()-1000, '/');
  77. }
  78. header("Location: /settings.php");
  79. die();
  80. }
  81. }
  82. ?>
  83. </div>
  84. <?php require "misc/footer.php"; ?>