pub / serci

Search the web with !keywords
git clone https://https://src.jayvii.de/pub/serci.git
Home | Log | Files | Exports | Refs | README | RSS

commit c11ef8fd6539487afd95c6ff767f3e2bdf663cc5
parent 8634b8ee623f1b7abfc1815ea8aab53a643683af
Author: JayVii <jayvii[AT]posteo[DOT]de>
Date:   Mon, 16 Sep 2024 11:58:42 +0200

feat: let user choose default engine via GET request

Diffstat:
Mindex.php | 16++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/index.php b/index.php @@ -20,10 +20,18 @@ $query = null; } - /* Handle Default Search Engine cookie (if set) */ - if (!is_null($_COOKIE["default_search"])) { - /* Use search engine stored in cookie; refresh cookie */ - $default_search = $_COOKIE["default_search"]; + /* Handle Default Search Engine cookie or GET parameter */ + if ( + !is_null($_COOKIE["default_search"]) || + !is_null($_GET["default_search"]) + ) { + /* Use search engine stored in cookie or GET argument */ + if (!is_null($_GET["default_search"])) { + $default_search = $_GET["default_search"]; + } else { + $default_search = $_COOKIE["default_search"]; + } + /* refresh cookie */ setcookie( "default_search", $default_search,