LibreY

- privacy respecting meta search engine
git clone git://git.acid.vegas/LibreY.git
Log | Files | Refs | Archive | README | LICENSE

settings.php (6218B)

      1 <?php
      2         require "misc/search_engine.php";
      3 
      4         // Reset all cookies when resetting, or before saving new cookies
      5         if (isset($_REQUEST["reset"]) || isset($_REQUEST["save"])) {
      6             if (isset($_SERVER["HTTP_COOKIE"])) {
      7                 $cookies = explode(";", $_SERVER["HTTP_COOKIE"]);
      8                 foreach($cookies as $cookie) {
      9                     $parts = explode("=", $cookie);
     10                     $name = trim($parts[0]);
     11                     setcookie($name, "", time() - 1000);
     12                 }
     13             }
     14         }
     15 
     16         if (isset($_REQUEST["save"])) {
     17             foreach($_POST as $key=>$value) {
     18                 if (!empty($value)) {
     19                     setcookie($key, $value, time() + (86400 * 90), '/');
     20                 } else {
     21                     setcookie($key, "", time() - 1000);
     22                 }
     23             }
     24         }
     25 
     26         if (isset($_REQUEST["save"]) || isset($_REQUEST["reset"])) {
     27             header("Location: ./");
     28             die();
     29         }
     30 
     31         $opts = load_opts();
     32 
     33         require "misc/header.php";
     34 ?>
     35 
     36     <title>LibreY - <?php printtext("settings_title");?></title>
     37     </head>
     38     <body>
     39         <div class="misc-container">
     40             <h1>Settings</h1>
     41             <form method="post" enctype="multipart/form-data" autocomplete="off">
     42               <div>
     43                 <label for="theme"><?php printtext("settings_theme");?>:</label>
     44                 <select name="theme">
     45                 <?php
     46                     $themes = "<option value=\"dark\">Dark</option>
     47                     <option value=\"darker\">Darker</option>
     48                     <option value=\"amoled\">AMOLED</option>
     49                     <option value=\"light\">Light</option>
     50                     <option value=\"auto\">Auto</option>
     51 					<option value=\"dracula\">Dracula</option>
     52                     <option value=\"nord\">Nord</option>
     53                     <option value=\"night_owl\">Night Owl</option>
     54                     <option value=\"discord\">Discord</option>
     55                     <option value=\"google\">Google Dark</option>
     56                     <option value=\"startpage\">Startpage Dark</option>
     57                     <option value=\"gruvbox\">Gruvbox</option>
     58                     <option value=\"github_night\">GitHub Night</option>
     59                     <option value=\"catppuccin\">Catppucin</option>
     60                     <option value=\"ubuntu\">Ubuntu</option>
     61                     <option value=\"tokyo_night\">Tokyo night</option>";
     62 
     63                     if (isset($opts->theme)) {
     64                         $theme = $opts->theme;
     65                         $themes = str_replace($theme . "\"", $theme . "\" selected", $themes);
     66                     }
     67 
     68                     echo $themes;
     69                 ?>
     70                 </select>
     71                 </div>
     72                 <div>
     73                     <label><?php printtext("settings_special_disabled");?></label>
     74                     <input type="checkbox" name="disable_special" <?php echo $opts->disable_special ? "checked"  : ""; ?> >
     75                 </div>
     76 
     77                 <h2><?php printtext("settings_frontends");?></h2>
     78                 <p><?php printtext("settings_frontends_description");?></p>
     79                 <div class="settings-textbox-container">
     80                       <?php
     81                            foreach($opts->frontends as $frontend => $data)
     82                            {
     83                                 echo "<div>";
     84                                 echo "<a for=\"$frontend\" href=\"" . $data["project_url"] . "\" target=\"_blank\">" . ucfirst($frontend) . "</a>";
     85                                 echo "<input type=\"text\" name=\"$frontend\" placeholder=\"Replace " .  $data["original_name"] . "\" value=";
     86                                 echo htmlspecialchars($opts->frontends["$frontend"]["instance_url"] ?? "");
     87                                 echo ">";
     88                                 echo "</div>";
     89                            }
     90                       ?>
     91                 </div>
     92                 <div>
     93                     <label><?php printtext("settings_frontends_disable");?></label>
     94                     <input type="checkbox" name="disable_frontends" <?php echo $opts->disable_frontends ? "checked"  : ""; ?> >
     95                 </div>
     96 
     97                 <h2><?php printtext("settings_search_settings");?></h2>
     98                 <div class="settings-textbox-container">
     99                     <div>
    100                         <span><?php printtext("settings_language");?></span>
    101                         <select name="language">
    102                         <?php
    103 
    104                            $languages = json_decode(file_get_contents("static/misc/languages.json"), true);
    105                            $options = "";
    106 
    107                            $options .= "<option value=\"\" " . (!isset($opts->language) ? "selected" : "") . ">Any</option>";
    108 
    109                            foreach ($languages as $lang_code => $language) {
    110                                $name = $language["name"];
    111                                $selected = $opts->language == $lang_code ? "selected" : "";
    112                                $options .= "<option value=\"$lang_code\" $selected>$name</option>";
    113                            }
    114                            echo $options;
    115                         ?>
    116                         </select>
    117                     </div>
    118                     <div>
    119                         <label><?php printtext("settings_number_of_results");?></label>
    120                         <input type="number" name="number_of_results" value="<?php echo htmlspecialchars($opts->number_of_results ?? "10") ?>" >
    121                     </div>
    122                 </div>
    123                 <div>
    124                     <label><?php printtext("settings_safe_search");?></label>
    125                     <input type="checkbox" name="safe_search" <?php echo $opts->safe_search ? "checked"  : ""; ?> >
    126                 </div>
    127 
    128                 <div>
    129                   <button type="submit" name="save" value="1"><?php printtext("settings_save");?></button>
    130                   <button type="submit" name="reset" value="1"><?php printtext("settings_reset");?></button>
    131                 </div>
    132             </form>
    133         </div>
    134 
    135 <?php require "misc/footer.php"; ?>