settings.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <?php
  2. $config = require "config.php";
  3. if (isset($_REQUEST["reset"]))
  4. {
  5. if (isset($_SERVER["HTTP_COOKIE"]))
  6. {
  7. $cookies = explode(";", $_SERVER["HTTP_COOKIE"]);
  8. foreach($cookies as $cookie)
  9. {
  10. $parts = explode("=", $cookie);
  11. $name = trim($parts[0]);
  12. setcookie($name, "", time() - 1000);
  13. }
  14. }
  15. }
  16. if (isset($_REQUEST["save"]))
  17. {
  18. foreach($_POST as $key=>$value)
  19. {
  20. if (!empty($value))
  21. {
  22. setcookie($key, $value, time() + (86400 * 90), '/');
  23. }
  24. else
  25. {
  26. setcookie($key, "", time() - 1000);
  27. }
  28. }
  29. }
  30. if (isset($_REQUEST["save"]) || isset($_REQUEST["reset"]))
  31. {
  32. header("Location: ./");
  33. die();
  34. }
  35. require "misc/header.php";
  36. ?>
  37. <title>LibreX - Settings</title>
  38. </head>
  39. <body>
  40. <div class="misc-container">
  41. <h1>Settings</h1>
  42. <form method="post" enctype="multipart/form-data" autocomplete="off">
  43. <div>
  44. <label for="theme">Theme:</label>
  45. <select name="theme">
  46. <?php
  47. $themes = "<option value=\"dark\">Dark</option>
  48. <option value=\"darker\">Darker</option>
  49. <option value=\"amoled\">AMOLED</option>
  50. <option value=\"light\">Light</option>
  51. <option value=\"auto\">Auto</option>
  52. <option value=\"dracula\">Dracula</option>
  53. <option value=\"nord\">Nord</option>
  54. <option value=\"night_owl\">Night Owl</option>
  55. <option value=\"discord\">Discord</option>
  56. <option value=\"google\">Google Dark</option>
  57. <option value=\"startpage\">Startpage Dark</option>
  58. <option value=\"gruvbox\">Gruvbox</option>
  59. <option value=\"github_night\">GitHub Night</option>
  60. <option value=\"catppuccin\">Catppucin</option>
  61. <option value=\"ubuntu\">Ubuntu</option>
  62. <option value=\"tokyo_night\">Tokyo night</option>";
  63. if (isset($_COOKIE["theme"]))
  64. {
  65. $cookie_theme = $_COOKIE["theme"];
  66. $themes = str_replace($cookie_theme . "\"", $cookie_theme . "\" selected", $themes);
  67. }
  68. echo $themes;
  69. ?>
  70. </select>
  71. </div>
  72. <div>
  73. <label>Disable special queries (e.g.: currency conversion)</label>
  74. <input type="checkbox" name="disable_special" <?php echo isset($_COOKIE["disable_special"]) ? "checked" : ""; ?> >
  75. </div>
  76. <h2>Privacy friendly frontends</h2>
  77. <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>
  78. <div class="settings-textbox-container">
  79. <?php
  80. foreach($config->frontends as $frontend => $data)
  81. {
  82. echo "<div>";
  83. echo "<a for=\"$frontend\" href=\"" . $data["project_url"] . "\" target=\"_blank\">" . ucfirst($frontend) . "</a>";
  84. echo "<input type=\"text\" name=\"$frontend\" placeholder=\"Replace " . $data["original_name"] . "\" value=";
  85. echo isset($_COOKIE["$frontend"]) ? htmlspecialchars($_COOKIE["$frontend"]) : $data["instance_url"];
  86. echo ">";
  87. echo "</div>";
  88. }
  89. ?>
  90. </div>
  91. <div>
  92. <label>Disable frontends</label>
  93. <input type="checkbox" name="disable_frontends" <?php echo isset($_COOKIE["disable_frontends"]) ? "checked" : ""; ?> >
  94. </div>
  95. <h2>Google settings</h2>
  96. <div class="settings-textbox-container">
  97. <div>
  98. <span>Site language</span>
  99. <?php
  100. echo "<input type=\"text\" name=\"google_language_site\" placeholder=\"E.g.: en\" value=\"";
  101. echo isset($_COOKIE["google_language_site"]) ? htmlspecialchars($_COOKIE["google_language_site"]) : $config->google_language_site;
  102. ?>">
  103. </div>
  104. <div>
  105. <span>Results language</span>
  106. <?php
  107. echo "<input type=\"text\" name=\"google_language_results\" placeholder=\"E.g.: de\" value=\"";
  108. echo isset($_COOKIE["google_language_results"]) ? htmlspecialchars($_COOKIE["google_language_results"]) : $config->google_language_results;
  109. ?>">
  110. </div>
  111. <div>
  112. <label>Number of results per page</label>
  113. <input type="number" name="google_number_of_results" value="<?php echo isset($_COOKIE["google_number_of_results"]) ? $_COOKIE["google_number_of_results"] : $config->google_number_of_results; ?>" >
  114. </div>
  115. <div>
  116. <label>Safe search</label>
  117. <input type="checkbox" name="safe_search" <?php echo isset($_COOKIE["safe_search"]) ? "checked" : ""; ?> >
  118. </div>
  119. </div>
  120. <h2>Wikipedia settings</h2>
  121. <div class="settings-textbox-container">
  122. <div>
  123. <span>Results language</span>
  124. <?php
  125. echo "<input type=\"text\" name=\"wikipedia_language\" placeholder=\"E.g.: en\" value=\"";
  126. echo isset($_COOKIE["wikipedia_language"]) ? htmlspecialchars($_COOKIE["wikipedia_language"]) : $config->wikipedia_language;
  127. ?>">
  128. </div>
  129. </div>
  130. <div>
  131. <button type="submit" name="save" value="1">Save</button>
  132. <button type="submit" name="reset" value="1">Reset</button>
  133. </div>
  134. </form>
  135. </div>
  136. <?php require "misc/footer.php"; ?>