Compare commits

...

12 Commits

Author SHA1 Message Date
Ahwx be59098abd
fix: docker shit, wikipedia vuln pointed out via email by Yufan You (merge pull request #9 from codedipper/main) 2023-08-17 23:59:48 +02:00
Ahwx 91ecdf64c2
feat: add "Did you mean?" to LibreY (merge pull request #8 from davidovski/did_you_mean
Live saving shit right here!
2023-08-17 23:51:53 +02:00
Ahwx 3ef3b31973
feat: add instances page (merge pull request #7 from davidovski/instances_list)
Instances list
2023-08-17 23:48:07 +02:00
Revvy d0b9411ad3 update docker-compose.yml for new docker changes 2023-08-17 16:14:03 -04:00
Revvy d3cea672a5 CONFIG_INSTANCE_FALLBACK 2023-08-17 16:12:04 -04:00
Revvy ee377e514e choosing engine support docker 2023-08-17 15:48:12 -04:00
Revvy 0ac3cd2e06 CURLOPT_PROXYTYPE docker 2023-08-17 15:15:11 -04:00
Revvy 3b5e95ff60 CONFIG_GOOGLE_NUMBER_OF_RESULTS docker 2023-08-17 15:07:17 -04:00
Revvy edbc23f124 Thank you random Chinese student! 2023-08-17 14:27:25 -04:00
davidovski 78c774bc3b Style did you mean text 2023-08-17 14:33:26 +01:00
davidovski b7e0ed8742 Add instances.php to footer 2023-08-16 22:27:48 +01:00
davidovski b20a57572b Add instances list 2023-08-16 22:26:31 +01:00
13 changed files with 278 additions and 9 deletions

View File

@ -14,6 +14,8 @@ services:
- CONFIG_GOOGLE_DOMAIN=com
- CONFIG_GOOGLE_LANGUAGE_SITE=en
- CONFIG_GOOGLE_LANGUAGE_RESULTS=en
- CONFIG_TEXT_SEARCH_ENGINE=google
- CONFIG_INSTANCE_FALLBACK=true
- CONFIG_WIKIPEDIA_LANGUAGE=en
volumes:
- ./nginx_logs:/var/log/nginx

View File

@ -10,6 +10,7 @@
- [Search Config](#search-config)
- [Wikipedia](#wikipedia)
- [Applications](#applications)
- [Engines](#engines)
- [Curl](#curl)
- [Docker version issues](#docker-version-issues)
- [Building a docker image](#building-a-docker-image)
@ -87,6 +88,8 @@ This docker image was developed with high configurability in mind, so here is th
|:----------|:-------------|:---------|:------|
| 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_NUMBER_OF_RESULTS | "10" | "10", "20", "30" | Number of results for Google to return each page. |
| CONFIG_INSTANCE_FALLBACK | true | boolean | Choose whether or not to use the API on the backend to request to another LibreX/Y instance in case of rate limiting. |
| 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 |
@ -102,6 +105,13 @@ This docker image was developed with high configurability in mind, so here is th
<br>
### Engines
| Variables | Default | Examples | Description |
|:----------|:-------------|:---------|:------|
| CONFIG_TEXT_SEARCH_ENGINE | "google" | "google", "duckduckgo" | Change your text search engine. |
<br>
### Applications
| Variables | Default | Examples | Description |
@ -129,6 +139,7 @@ This docker image was developed with high configurability in mind, so here is th
|:----------|:-------------|:---------|:------|
| CURLOPT_PROXY_ENABLED | false | boolean | If you want to use a proxy, you need to set this variable to true. |
| CURLOPT_PROXY | "" | "127.0.0.1:8080" | Set the proxy using the ip and port to be used |
| CURLOPT_PROXYTYPE | "CURLPROXY_HTTP" | "CURLPROXY_SOCKS4A" "CURLPROXY_SOCKS5" "CURLPROXY_SOCKS5_HOSTNAME" | Set the type of proxy connection (if you enabled it). |
| CURLOPT_RETURNTRANSFER | true | boolean | **TODO** |
| CURLOPT_ENCODING | "" | string | Defines the encode that curl should use to display the texts correctly |
| CURLOPT_USERAGENT | "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36" | string | This variable defines the 'User-Agent' that curl will use to attempt to avoid being blocked |

View File

@ -22,6 +22,8 @@ export OPEN_SEARCH_HOST=${OPEN_SEARCH_HOST:-"127.0.0.1"}
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:-"en"}"
export CONFIG_GOOGLE_NUMBER_OF_RESULTS="${CONFIG_GOOGLE_NUMBER_OF_RESULTS:-"10"}"
export CONFIG_INSTANCE_FALLBACK="${CONFIG_INSTANCE_FALLBACK}:-true}
export CONFIG_INVIDIOUS_INSTANCE="${CONFIG_INVIDIOUS_INSTANCE:-"invidious.snopyta.org"}"
export CONFIG_HIDDEN_SERVICE_SEARCH=${CONFIG_HIDDEN_SERVICE_SEARCH:-false}
export CONFIG_DISABLE_BITTORRENT_SEARCH=${CONFIG_DISABLE_BITTORRENT_SEARCH:-false}
@ -48,10 +50,13 @@ export APP_ANONYMOUS_OVERFLOW=${APP_ANONYMOUS_OVERFLOW:-""}
export APP_SUDS=${APP_SUDS:-""}
export APP_BIBLIOREADS=${APP_BIBLIOREADS:-""}
export CONFIG_TEXT_SEARCH_ENGINE=${CONFIG_TEXT_SEARCH_ENGINE:-"google"}
# GNU/Curl configurations. Leave 'CURLOPT_PROXY' blank whether you don't need to use a proxy for requests
# Generally, a proxy is needed when your IP address is blocked by search engines in response to multiple requests within a short time frame. In these cases, it is recommended to use rotating proxies
export CURLOPT_PROXY_ENABLED=${CURLOPT_PROXY_ENABLED:-false}
export CURLOPT_PROXY=${CURLOPT_PROXY:-""}
export CURLOPT_PROXYTYPE=${CURLOPT_PROXYTYPE:-"CURLPROXY_HTTP"}
export CURLOPT_RETURNTRANSFER=${CURLOPT_RETURNTRANSFER:-true}
export CURLOPT_ENCODING=${CURLOPT_ENCODING:-""}
export CURLOPT_USERAGENT="${CURLOPT_USERAGENT:-"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"}"

View File

@ -3,6 +3,7 @@
"google_domain" => "${CONFIG_GOOGLE_DOMAIN}",
"google_language_site" => "${CONFIG_GOOGLE_LANGUAGE_SITE}",
"google_language_results" => "${CONFIG_GOOGLE_LANGUAGE_RESULTS}",
"google_number_of_results" => "${CONFIG_GOOGLE_NUMBER_OF_RESULTS}",
"wikipedia_language" => "${CONFIG_WIKIPEDIA_LANGUAGE}",
"invidious_instance_for_video_results" => "${CONFIG_INVIDIOUS_INSTANCE}",
@ -10,6 +11,7 @@
"disable_bittorent_search" => ${CONFIG_DISABLE_BITTORRENT_SEARCH},
"bittorent_trackers" => "${CONFIG_BITTORRENT_TRACKERS}",
"disable_hidden_service_search" => ${CONFIG_HIDDEN_SERVICE_SEARCH},
"instance_fallback" => ${CONFIG_INSTANCE_FALLBACK},
"frontends" => array(
"invidious" => array(
@ -99,9 +101,13 @@
)
),
"preferred_engines" => array(
"text" => "${CONFIG_TEXT_SEARCH_ENGINE}"
),
"curl_settings" => array(
CURLOPT_PROXY => "${CURLOPT_PROXY}",
CURLOPT_PROXYTYPE => CURLPROXY_HTTP,
CURLOPT_PROXYTYPE => "${CURLOPT_PROXYTYPE}",
CURLOPT_RETURNTRANSFER => ${CURLOPT_RETURNTRANSFER},
CURLOPT_ENCODING => "${CURLOPT_ENCODING}",
CURLOPT_USERAGENT => "${CURLOPT_USERAGENT}",

View File

@ -14,6 +14,8 @@ ENV OPEN_SEARCH_HOST="http://127.0.0.1:${NGINX_PORT}"
ENV CONFIG_GOOGLE_DOMAIN="com"
ENV CONFIG_GOOGLE_LANGUAGE_SITE="en"
ENV CONFIG_GOOGLE_LANGUAGE_RESULTS="en"
ENV CONFIG_GOOGLE_NUMBER_OF_RESULTS="10"
ENV CONFIG_INSTANCE_FALLBACK=true
ENV CONFIG_INVIDIOUS_INSTANCE="https://invidious.snopyta.org"
ENV CONFIG_HIDDEN_SERVICE_SEARCH=false
ENV CONFIG_DISABLE_BITTORRENT_SEARCH=false
@ -36,11 +38,14 @@ ENV APP_ANONYMOUS_OVERFLOW=""
ENV APP_SUDS=""
ENV APP_BIBLIOREADS=""
# Preferred search engines.
ENV CONFIG_TEXT_SEARCH_ENGINE="google"
# GNU/Curl configurations. Leave 'CURLOPT_PROXY' blank whether you don't need to use a proxy for requests
# Generally, a proxy is needed when your IP address is blocked by search engines in response to multiple requests within a short time frame. In these cases, it is recommended to use rotating proxies
ENV CURLOPT_PROXY_ENABLED=false
ENV CURLOPT_PROXY=""
ENV CURLOPT_PROXYTYPE="CURLPROXY_HTTP"
ENV CURLOPT_RETURNTRANSFER=true
ENV CURLOPT_ENCODING=""
ENV CURLOPT_USERAGENT="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36"

View File

@ -54,7 +54,8 @@
break;
case 7:
$wikipedia_language = isset($_COOKIE["wikipedia_language"]) ? trim(htmlspecialchars($_COOKIE["wikipedia_language"])) : $config->wikipedia_language;
$url = "https://$wikipedia_language.wikipedia.org/w/api.php?format=json&action=query&prop=extracts%7Cpageimages&exintro&explaintext&redirects=1&pithumbsize=500&titles=$query_encoded";
if (in_array($wikipedia_language, json_decode(file_get_contents("static/misc/wikipedia_langs.json"), true)))
$url = "https://$wikipedia_language.wikipedia.org/w/api.php?format=json&action=query&prop=extracts%7Cpageimages&exintro&explaintext&redirects=1&pithumbsize=500&titles=$query_encoded";
break;
}

View File

@ -54,7 +54,8 @@
break;
case 7:
$wikipedia_language = isset($_COOKIE["wikipedia_language"]) ? trim(htmlspecialchars($_COOKIE["wikipedia_language"])) : $config->wikipedia_language;
$url = "https://$wikipedia_language.wikipedia.org/w/api.php?format=json&action=query&prop=extracts%7Cpageimages&exintro&explaintext&redirects=1&pithumbsize=500&titles=$query_encoded";
if (in_array($wikipedia_language, json_decode(file_get_contents("static/misc/wikipedia_langs.json"), true)))
$url = "https://$wikipedia_language.wikipedia.org/w/api.php?format=json&action=query&prop=extracts%7Cpageimages&exintro&explaintext&redirects=1&pithumbsize=500&titles=$query_encoded";
break;
}
@ -173,7 +174,7 @@
{
$didyoumean = $special["did_you_mean"];
$new_url = "/search.php?q=" . urlencode($didyoumean);
echo "<p class\"did-you-mean\">Did you mean ";
echo "<p class=\"did-you-mean\">Did you mean ";
echo "<a href=\"$new_url\">$didyoumean</a>";
echo "?</p>";
}

View File

@ -4,19 +4,176 @@
"clearnet": "https://search.ahwx.org",
"tor": "http://hyy7rcvknwb22v4nnoar635wntiwr4uwzhiuyimemyl4fz6k7tahj5id.onion",
"i2p": null,
"country": "FR"
"country": "FR",
"librey": true
},
{
"clearnet": "https://librex.me",
"tor": "librex.revvybrr6pvbx4n3j4475h4ghw4elqr4t5xo2vtd3gfpu2nrsnhh57id.onion",
"i2p": "revekebotog64xrrammtsmjwtwlg3vqyzwdurzt2pu6botg4bejq.b32.i2p",
"country": "CA"
"country": "CA",
"librey": true
},
{
"clearnet": "https://librex.revvy.de",
"tor": "librex.revvybrr6pvbx4n3j4475h4ghw4elqr4t5xo2vtd3gfpu2nrsnhh57id.onion",
"i2p": "revekebotog64xrrammtsmjwtwlg3vqyzwdurzt2pu6botg4bejq.b32.i2p",
"country": "CA"
"country": "CA",
"librey": true
},
{
"clearnet": "https://search.davidovski.xyz/",
"tor": null,
"i2p": null,
"country": "GB",
"librey": true
},
{
"clearnet": "https://librex.zzls.xyz/",
"tor": "http://librex.zzlsghu6mvvwyy75mvga6gaf4znbp3erk5xwfzedb4gg6qqh2j6rlvid.onion/",
"i2p": "http://zzlsaymhcfla7vibo3a223bybeecu3bd5z6rmw2u4y76maqeu76q.b32.i2p/",
"country": "CL",
"librey": false
},
{
"clearnet": "https://librex.me/",
"tor": "http://librex.revvybrr6pvbx4n3j4475h4ghw4elqr4t5xo2vtd3gfpu2nrsnhh57id.onion/",
"i2p": "http://revekebotog64xrrammtsmjwtwlg3vqyzwdurzt2pu6botg4bejq.b32.i2p/",
"country": "CA",
"librey": false
},
{
"clearnet": "https://s.dyox.in/",
"tor": "http://ddhigxwjz7elcl2erm7qzzukda4qmovoy4cepcueahggpwrpu24mi6qd.onion/",
"i2p": "http://s.dyoxin.i2p/",
"country": "IS",
"librey": false
},
{
"clearnet": "https://lx.vern.cc/",
"tor": "http://lx.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion/",
"i2p": "http://vernziqfqvweijfaacmwazohgpdo2bt2ib2jlupt2pwwu27bhgxq.b32.i2p/",
"country": "US",
"librey": false
},
{
"clearnet": "https://search.ahwx.org/",
"tor": "http://cosrpybbddzdfjquer3zfmb2h5avtacnctnbu4gucwocdb42s63gcqqd.onion/",
"i2p": null,
"country": "NL",
"librey": false
},
{
"clearnet": "https://search.spaceint.fr/",
"tor": "http://6d4nqt2rndvmhogpwrbqfvj2ur6e6nm2r6dzi7ny4wj6ai3j5hnvbhyd.onion/",
"i2p": null,
"country": "FR",
"librey": false
},
{
"clearnet": "https://search.madreyk.xyz/",
"tor": null,
"i2p": null,
"country": "DE",
"librey": false
},
{
"clearnet": "https://search.pabloferreiro.es/",
"tor": null,
"i2p": null,
"country": "DE",
"librey": false
},
{
"clearnet": "https://librex.pufe.org/",
"tor": null,
"i2p": null,
"country": "NZ",
"librey": false
},
{
"clearnet": "https://librex.ratakor.com/",
"tor": null,
"i2p": null,
"country": "FR",
"librey": false
},
{
"clearnet": "https://search.tildevarsh.in/",
"tor": null,
"i2p": null,
"country": "IN",
"librey": false
},
{
"clearnet": "https://librex.myroware.eu/",
"tor": null,
"i2p": null,
"country": "DE",
"librey": false
},
{
"clearnet": "https://librex.bloatcat.tk/",
"tor": null,
"i2p": null,
"country": "IS",
"librey": false
},
{
"clearnet": "https://librex.retro-hax.net/",
"tor": null,
"i2p": null,
"country": "DE",
"librey": false
},
{
"clearnet": "https://search.funami.tech/",
"tor": null,
"i2p": null,
"country": "KR",
"librey": false
},
{
"clearnet": "https://search.zeroish.xyz/",
"tor": null,
"i2p": null,
"country": "US",
"librey": false
},
{
"clearnet": "https://librex.baczek.me/",
"tor": null,
"i2p": null,
"country": "PL",
"librey": false
},
{
"clearnet": "https://librex.yogeshlamichhane.com.np/",
"tor": null,
"i2p": null,
"country": "US",
"librey": false
},
{
"clearnet": "https://lx.benike.monster/",
"tor": null,
"i2p": null,
"country": "DE",
"librey": false
},
{
"clearnet": "https://librex.nohost.network/",
"tor": null,
"i2p": null,
"country": "MX",
"librey": false
},
{
"clearnet": "https://search.decentrala.org/",
"tor": null,
"i2p": null,
"country": "US",
"librey": false
}
]
}

61
instances.php Normal file
View File

@ -0,0 +1,61 @@
<?php
require "misc/header.php";
require "misc/tools.php";
$instances_json = json_decode(file_get_contents("instances.json"), true);
$librey_instances = array_filter($instances_json['instances'], fn($n) => $n['librey']);
$librex_instances = array_filter($instances_json['instances'], fn($n) => !$n['librey']);
function list_instances($instances)
{
echo "<table><tr>";
echo "<th>Clearnet</th>";
echo "<th>Tor</th>";
echo "<th>I2P</th>";
echo "<th>Country</th>";
echo "</tr>";
foreach($instances as $instance) {
$hostname = parse_url($instance["clearnet"])["host"];
$country = get_country_emote($instance["country"]) . $instnace["country"];
$is_tor = !is_null($instance["tor"]);
$is_i2p = !is_null($instance["i2p"]);
echo "<tr>";
echo "<td><a href=\"" . $instance["clearnet"] . "\">" . $hostname . "</a></td>";
echo $is_tor
? "<td><a href=\"" . $instance["tor"] . "\">\u{2705}</a></td>"
: "<td>\u{274C}</td>";
echo $is_i2p
? "<td><a href=\"" . $instance["i2p"] . "\">\u{2705}</a></td>"
:"<td>\u{274C}</td>";
echo "<td>$country</td>";
echo "</tr>";
}
echo "</table>";
}
?>
<title>LibreY - instances</title>
</head>
<body>
<center>
<h2>Libre<span class="Y">Y</span> instances</h2>
<?php
list_instances($librey_instances);
?>
<p>The following instnaces are running the older <a href="https://github.com/hnhx/librex">LibreX</a>:</p>
<?php
list_instances($librex_instances);
?>
</center>
<?php require "misc/footer.php"; ?>

View File

@ -1,6 +1,7 @@
<div class="footer-container">
<a href="./">LibreY</a>
<a href="https://github.com/Ahwxorg/librey/" target="_blank">Source &amp; Instances</a>
<a href="https://github.com/Ahwxorg/librey/" target="_blank">Source</a>
<a href="./instances.php" target="_blank">Instances</a>
<a href="./settings.php">Settings</a>
<a href="./api.php" target="_blank">API</a>
<a href="./donate.php">Donate ❤️</a>

View File

@ -237,4 +237,20 @@
curl_setopt( $curl, CURLOPT_COOKIE, $_SERVER['HTTP_COOKIE'] );
}
function get_country_emote($code)
{
$emoji = [];
foreach(str_split($code) as $c) {
if(($o = ord($c)) > 64 && $o % 32 < 27) {
$emoji[] = hex2bin("f09f87" . dechex($o % 32 + 165));
continue;
}
$emoji[] = $c;
}
return join($emoji);
}
?>

View File

@ -30,6 +30,7 @@ a,
.text-result-wrapper a:visited h2,
.special-result-container a,
.did-you-mean a,
.sub-search-button-wrapper a,
.sub-search-button-wrapper a:visited{
color: #bd93f9;
@ -187,7 +188,8 @@ a:hover,
.text-result-container,
#time,
.next-page-button-wrapper {
.next-page-button-wrapper,
.did-you-mean {
margin-left: 170px;
}

View File

@ -0,0 +1 @@
["ab","ace","ady","af","ak","als","am","an","ang","ar","arc","ary","arz","as","ast","atj","av","avk","awa","ay","az","azb","ba","ban","bar","bat-smg","bcl","be","be-tarask","bg","bh","bi","bjn","bm","bn","bo","bpy","br","bs","bug","bxr","ca","cbk-zam","cdo","ce","ceb","ch","chr","chy","ckb","co","cr","crh","cs","csb","cu","cv","cy","da","de","din","diq","dsb","dty","dv","dz","ee","el","eml","en","eo","es","et","eu","ext","fa","ff","fi","fiu-vro","fj","fo","fr","frp","frr","fur","fy","ga","gag","gan","gcr","gd","gl","glk","gn","gom","gor","got","gu","gv","ha","hak","haw","he","hi","hif","hr","hsb","ht","hu","hy","hyw","ia","id","ie","ig","ik","ilo","inh","io","is","it","iu","ja","jam","jbo","jv","ka","kaa","kab","kbd","kbp","kg","ki","kk","kl","km","kn","ko","koi","krc","ks","ksh","ku","kv","kw","ky","la","lad","lb","lbe","lez","lfn","lg","li","lij","lld","lmo","ln","lo","lt","ltg","lv","mad","mai","map-bms","mdf","mg","mhr","mi","min","mk","ml","mn","mnw","mr","mrj","ms","mt","mwl","my","myv","mzn","na","nah","nap","nds","nds-nl","ne","new","nia","nl","nn","no","nostalgia","nov","nqo","nrm","nso","nv","ny","oc","olo","om","or","os","pa","pag","pam","pap","pcd","pdc","pfl","pi","pih","pl","pms","pnb","pnt","ps","pt","qu","rm","rmy","rn","ro","roa-rup","roa-tara","ru","rue","rw","sa","sah","sat","sc","scn","sco","sd","se","sg","sh","shn","si","simple","sk","skr","sl","sm","smn","sn","so","sq","sr","srn","ss","st","stq","su","sv","sw","szl","szy","ta","tcy","te","tet","tg","th","ti","tk","tl","tn","to","tpi","tr","ts","tt","tum","tw","ty","tyv","udm","ug","uk","ur","uz","ve","vec","vep","vi","vls","vo","wa","war","wo","wuu","xal","xh","xmf","yi","yo","za","zea","zh","zh-classical","zh-min-nan","zh-yue","zu","zh-hans","zh-hant","zh-cn","zh-hk","zh-mo","zh-my","zh-sg","zh-tw"]