Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added user selectable search domain and updated docker files #166

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config.php.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<?php
return (object) array(

# user selectable google domains, form https://www.google.com/supported_domains
"google_allowed_domains" => explode(" ", "com ad ae com.af com.ag com.ai al am co.ao com.ar as at com.au az ba com.bd be bf bg com.bh bi bj com.bn com.bo com.br bs bt co.bw by com.bz ca cd cf cg ch ci co.ck cl cm cn com.co co.cr com.cu cv com.cy cz de dj dk dm com.do dz com.ec ee com.eg es com.et fi com.fj fm fr ga ge gg com.gh com.gi gl gm gr com.gt gy com.hk hn hr ht hu co.id ie co.il im co.in iq is it je com.jm jo co.jp co.ke com.kh ki kg co.kr com.kw kz la com.lb li lk co.ls lt lu lv com.ly co.ma md me mg mk ml com.mm mn ms com.mt mu mv mw com.mx com.my co.mz com.na com.ng com.ni ne nl no com.np nr nu co.nz com.om com.pa com.pe com.pg com.ph com.pk pl pn com.pr ps pt com.py com.qa ro ru rw com.sa com.sb sc se com.sg sh si sk com.sl sn so sm sr st com.sv td tg co.th com.tj tl tm tn to com.tr tt com.tw co.tz com.ua co.ug co.uk com.uy co.uz com.vc co.ve vg co.vi com.vn vu ws rs co.za co.zm co.zw cat"),
// e.g.: fr -> https://google.fr/
"google_domain" => "com",

Expand Down
14 changes: 8 additions & 6 deletions docker/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ To run librex in a docker container, you can simply use the command:
docker run -d --name librex \
-e TZ="America/New_York" \
-e CONFIG_GOOGLE_DOMAIN="com" \
-e CONFIG_GOOGLE_LANGUAGE="en" \
-e CONFIG_GOOGLE_LANGUAGE_SITE="en" \
-p 8080:8080 \
librex/librex:latest
```
Expand All @@ -48,9 +48,9 @@ services:
- PUID=1000
- PGID=1000
- VERSION=docker
- TZ="America/New_York"
- CONFIG_GOOGLE_DOMAIN="com"
- CONFIG_GOOGLE_LANGUAGE="en"
- TZ=America/New_York
- CONFIG_GOOGLE_DOMAIN=com
- CONFIG_GOOGLE_LANGUAGE_SITE=en
volumes:
- ./nginx_logs:/var/log/nginx
- ./php_logs:/var/log/php7
Expand Down Expand Up @@ -82,7 +82,9 @@ This docker image was developed with high configurability in mind, so here is th
| Variables | Default | Examples | Description |
|:----------|:-------------|:---------|:------|
| CONFIG_GOOGLE_DOMAIN | "com" | "com", "com.br", "com.es" | Defines which Google domain the search will be done, change according to your country |
| CONFIG_GOOGLE_LANGUAGE | "en" | "pt", "es", "ru" | Defines the language in which searches will be done, see the list of supported languages [here](https://developers.google.com/custom-search/docs/ref_languages). |
| CONFIG_GOOGLE_ALLOWED_DOMAINS | see Description | "com co.uk ca it fr de" | Defines a list of allowed Google domains selectable by user in settings; defaults to a list of supported domains got from [here](https://www.google.com/supported_domains).|
| CONFIG_GOOGLE_LANGUAGE_SITE | "en" | "pt", "es", "ru" | Defines the language in which searches will be done, see the list of supported languages [here](https://developers.google.com/custom-search/docs/ref_languages). |
| CONFIG_GOOGLE_LANGUAGE_RESULTS | "" | "en", "pt", "es", "ru" | Defines the language of searche results|
| CONFIG_INVIDIOUS_INSTANCE | "https://invidious.namazso.eu" | string | Defines the host that will be used to do video searches using invidious |
| CONFIG_HIDDEN_SERVICE_SEARCH | false | boolean | Defines whether safesearch will be enabled or disabled |
| CONFIG_DISABLE_BITTORRENT_SEARCH | false | boolean | Defines whether bittorrent support will be enabled or disabled |
Expand Down Expand Up @@ -148,7 +150,7 @@ docker build https://github.com/hnhx/librex.git -t librex:latest
```sh
docker run -d --name librex \
-e CONFIG_GOOGLE_DOMAIN="com" \
-e CONFIG_GOOGLE_LANGUAGE="en" \
-e CONFIG_GOOGLE_LANGUAGE_SITE="en" \
-p 8080:8080 \
librex:latest
```
Expand Down
7 changes: 5 additions & 2 deletions docker/attributes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ export OPEN_SEARCH_HOST=${OPEN_SEARCH_HOST:-"127.0.0.1"}

# Replace the 'config.php' script, which contains the most common search engine configurations, with these environment setups
# These environment setups can be found in 'config.php', and the default configurations can be useful for most use cases
export CONFIG_GOOGLE_DOMAIN=${CONFIG_GOOGLE_DOMAIN:-".com"}
export CONFIG_GOOGLE_LANGUAGE=${CONFIG_GOOGLE_LANGUAGE:-"en"}
# allowed domains from https://www.google.com/supported_domains
export CONFIG_GOOGLE_ALLOWED_DOMAINS=${CONFIG_GOOGLE_ALLOWED_DOMAINS:-"com ad ae com.af com.ag com.ai al am co.ao com.ar as at com.au az ba com.bd be bf bg com.bh bi bj com.bn com.bo com.br bs bt co.bw by com.bz ca cd cf cg ch ci co.ck cl cm cn com.co co.cr com.cu cv com.cy cz de dj dk dm com.do dz com.ec ee com.eg es com.et fi com.fj fm fr ga ge gg com.gh com.gi gl gm gr com.gt gy com.hk hn hr ht hu co.id ie co.il im co.in iq is it je com.jm jo co.jp co.ke com.kh ki kg co.kr com.kw kz la com.lb li lk co.ls lt lu lv com.ly co.ma md me mg mk ml com.mm mn ms com.mt mu mv mw com.mx com.my co.mz com.na com.ng com.ni ne nl no com.np nr nu co.nz com.om com.pa com.pe com.pg com.ph com.pk pl pn com.pr ps pt com.py com.qa ro ru rw com.sa com.sb sc se com.sg sh si sk com.sl sn so sm sr st com.sv td tg co.th com.tj tl tm tn to com.tr tt com.tw co.tz com.ua co.ug co.uk com.uy co.uz com.vc co.ve vg co.vi com.vn vu ws rs co.za co.zm co.zw cat"}
export CONFIG_GOOGLE_DOMAIN=${CONFIG_GOOGLE_DOMAIN:-"com"}
export CONFIG_GOOGLE_LANGUAGE_SITE=${CONFIG_GOOGLE_LANGUAGE_SITE:-"en"}
export CONFIG_GOOGLE_LANGUAGE_RESULTS=${CONFIG_GOOGLE_LANGUAGE_RESULTS:-""}
export CONFIG_INVIDIOUS_INSTANCE=${CONFIG_INVIDIOUS_INSTANCE:-"invidious.namazso.eu"}
export CONFIG_HIDDEN_SERVICE_SEARCH=${CONFIG_HIDDEN_SERVICE_SEARCH:-false}
export CONFIG_DISABLE_BITTORRENT_SEARCH=${CONFIG_DISABLE_BITTORRENT_SEARCH:-false}
Expand Down
107 changes: 92 additions & 15 deletions docker/php/config.php
Original file line number Diff line number Diff line change
@@ -1,28 +1,105 @@
<?php
return (object) array(

"google_allowed_domains" => explode(" ", "${CONFIG_GOOGLE_ALLOWED_DOMAINS}"),

"google_domain" => "${CONFIG_GOOGLE_DOMAIN}",
"google_language" => "${CONFIG_GOOGLE_LANGUAGE}",
"google_language_site" => "${CONFIG_GOOGLE_LANGUAGE_SITE}",
"google_language_results" => "${CONFIG_GOOGLE_LANGUAGE_RESULTS}",
"invidious_instance_for_video_results" => "${CONFIG_INVIDIOUS_INSTANCE}",

"disable_bittorent_search" => ${CONFIG_DISABLE_BITTORRENT_SEARCH},
"bittorent_trackers" => "${CONFIG_BITTORRENT_TRACKERS}",
"disable_hidden_service_search" => ${CONFIG_HIDDEN_SERVICE_SEARCH},

"invidious" => "${APP_INVIDIOUS}", // youtube
"bibliogram" => "${APP_BIBLIOGRAM}", // instagram
"rimgo" => "${APP_RIMGO}", // imgur
"scribe" => "${APP_SCRIBE}", // medium
"librarian" => "${APP_LIBRARIAN}", // odysee
"gothub" => "${APP_GOTHUB}", // github
"nitter" => "${APP_NITTER}", // twitter
"libreddit" => "${APP_LIBREREDDIT}", // reddit
"proxitok" => "${APP_PROXITOK}", // tiktok
"wikiless" => "${APP_WIKILESS}", // wikipedia
"quetre" => "${APP_QUETRE}", // quora
"libremdb" => "${APP_LIBREMDB}", // imdb,
"breezewiki" => "${APP_BREEZEWIKI}", // fandom,
"anonymousoverflow" => "${APP_ANONYMOUS_OVERFLOW}", // stackoverflow
"frontends" => array(
"invidious" => array(
"instance_url" => "${APP_INVIDIOUS}",
"project_url" => "https://docs.invidious.io/instances/",
"original_name" => "YouTube",
"original_url" => "youtube.com"
),
"bibliogram" => array(
"instance_url" => "${APP_BIBLIOGRAM}",
"project_url" => "https://git.sr.ht/~cadence/bibliogram-docs/tree/master/docs/Instances.md",
"original_name" => "Instagram",
"original_url" => "instagram.com"
),
"rimgo" => array(
"instance_url" => "${APP_RIMGO}",
"project_url" => "https://codeberg.org/video-prize-ranch/rimgo#instances",
"original_name" => "Imgur",
"original_url" => "imgur.com"
),
"scribe" => array(
"instance_url" => "${APP_SCRIBE}",
"project_url" => "https://git.sr.ht/~edwardloveall/scribe/tree/main/docs/instances.md",
"original_name" => "Medium",
"original_url" => "medium.com"
),
"gothub" => array(
"instance_url" => "${APP_GOTHUB}",
"project_url" => "https://codeberg.org/gothub/gothub/wiki/Instances",
"original_name" => "GitHub",
"original_url" => "github.com"
),
"librarian" => array(
"instance_url" => "${APP_LIBRARIAN}",
"project_url" => "https://codeberg.org/librarian/librarian#clearnet",
"original_name" => "Odysee",
"original_url" => "odysee.com"
),

"nitter" => array(
"instance_url" => "${APP_NITTER}",
"project_url" => "https://github.com/zedeus/nitter/wiki/Instances",
"original_name" => "Twitter",
"original_url" => "twitter.com"
),

"libreddit" => array(
"instance_url" => "${APP_LIBREREDDIT}",
"project_url" => "https://github.com/spikecodes/libreddit",
"original_name" => "Reddit",
"original_url" => "reddit.com"
),
"proxitok" => array(
"instance_url" => "${APP_PROXITOK}",
"project_url" => "https://github.com/pablouser1/ProxiTok/wiki/Public-instances",
"original_name" => "TikTok",
"original_url" => "tiktok.com"
),
"wikiless" => array(
"instance_url" => "${APP_WIKILESS}",
"project_url" => "https://github.com/Metastem/wikiless#instances",
"original_name" => "Wikipedia",
"original_url" => "wikipedia.com"
),
"quetre" => array(
"instance_url" => "${APP_QUETRE}",
"project_url" => "https://github.com/zyachel/quetre",
"original_name" => "Quora",
"original_url" => "quora.com"
),
"libremdb" => array(
"instance_url" => "${APP_LIBREMDB}",
"project_url" => "https://github.com/zyachel/libremdb",
"original_name" => "IMDb",
"original_url" => "imdb.com"
),
"breezewiki" => array(
"instance_url" => "${APP_BREEZEWIKI}",
"project_url" => "https://gitdab.com/cadence/breezewiki",
"original_name" => "Fandom",
"original_url" => "fandom.com"
),
"anonymousoverflow" => array(
"instance_url" => "${APP_ANONYMOUS_OVERFLOW}",
"project_url" => "https://github.com/httpjamesm/AnonymousOverflow#clearnet-instances",
"original_name" => "StackOverflow",
"original_url" => "stackoverflow.com"
)
),
"curl_settings" => array(
CURLOPT_PROXY => "",
CURLOPT_PROXYTYPE => CURLPROXY_HTTP,
Expand Down
4 changes: 3 additions & 1 deletion docker/php/php.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ ENV OPEN_SEARCH_HOST="http://127.0.0.1:${NGINX_PORT}"

# Replace the 'config.php' script, which contains the most common search engine configurations, with these environment setups
# These environment setups can be found in 'config.php', and the default configurations can be useful for most use cases
ENV CONFIG_GOOGLE_ALLOWED_DOMAINS=""
ENV CONFIG_GOOGLE_DOMAIN="com"
ENV CONFIG_GOOGLE_LANGUAGE="en"
ENV CONFIG_GOOGLE_LANGUAGE_SITE="en"
ENV CONFIG_GOOGLE_LANGUAGE_RESULTS=""
ENV CONFIG_INVIDIOUS_INSTANCE="https://invidious.namazso.eu"
ENV CONFIG_HIDDEN_SERVICE_SEARCH=false
ENV CONFIG_DISABLE_BITTORRENT_SEARCH=false
Expand Down
19 changes: 19 additions & 0 deletions settings.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?php
$config = require "config.php";

$ok = true;
if (isset($_REQUEST["reset"]))
{
if (isset($_SERVER["HTTP_COOKIE"]))
Expand All @@ -22,10 +23,21 @@
if (!empty($value))
{
setcookie($key, $value, time() + (86400 * 90), '/');
$_COOKIE[$key] = $value;
}
else
{
setcookie($key, "", time() - 1000);
unset($_COOKIE[$key]);
}
}
if (isset($_COOKIE["google_domain"]))
{
if (!in_array($_COOKIE["google_domain"], $config->google_allowed_domains))
{
unset($_COOKIE["google_domain"]);
setcookie("google_domain", null, -1, '/');
$ok = false;
}
}
}
Expand Down Expand Up @@ -99,6 +111,13 @@
<h2>Google settings</h2>
<div class="settings-textbox-container">
<div>
<div>
<span>Google Domain</span>
<?php
echo "<input type=\"text\" name=\"google_domain\" placeholder=\"E.g.: co.uk\" value=\"";
echo isset($_COOKIE["google_domain"]) ? htmlspecialchars($_COOKIE["google_domain"]) : $config->google_domain;
?>">
</div>
<span>Site language</span>
<?php
echo "<input type=\"text\" name=\"google_language_site\" placeholder=\"E.g.: en\" value=\"";
Expand Down