diff --git a/Dockerfile b/Dockerfile index 6512cdc..58a08ea 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,5 @@ # syntax = edrevo/dockerfile-plus -ARG VERSION="3.17" +ARG VERSION="3.18" FROM alpine:${VERSION} AS librex WORKDIR "/var/www/html" diff --git a/README.md b/README.md index c4ee080..e7136e5 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,9 @@ | [librex.zzls.xyz](https://librex.zzls.xyz/) | [✅](http://librex.zzlsghu6mvvwyy75mvga6gaf4znbp3erk5xwfzedb4gg6qqh2j6rlvid.onion/) | [✅](http://zzlsaymhcfla7vibo3a223bybeecu3bd5z6rmw2u4y76maqeu76q.b32.i2p) | 🇨🇱 CL | | [librex.me](https://librex.me/) | [✅](http://librex.revvybrr6pvbx4n3j4475h4ghw4elqr4t5xo2vtd3gfpu2nrsnhh57id.onion/) | [✅](http://revekebotog64xrrammtsmjwtwlg3vqyzwdurzt2pu6botg4bejq.b32.i2p/) | 🇨🇦 CA | | [s.dyox.in](https://s.dyox.in/) | [✅](http://ddhigxwjz7elcl2erm7qzzukda4qmovoy4cepcueahggpwrpu24mi6qd.onion/) | [✅](http://s.dyoxin.i2p/) | 🇮🇸 IS | +| [lx.vern.cc](https://lx.vern.cc/) | [✅](http://lx.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion/) | [✅](http://vernziqfqvweijfaacmwazohgpdo2bt2ib2jlupt2pwwu27bhgxq.b32.i2p/) | 🇺🇸 US | | [search.ahwx.org](https://search.ahwx.org/) | [✅](http://cosrpybbddzdfjquer3zfmb2h5avtacnctnbu4gucwocdb42s63gcqqd.onion/) | ❌ | 🇳🇱 NL | +| [search.spaceint.fr](https://search.spaceint.fr/) | [✅](http://6d4nqt2rndvmhogpwrbqfvj2ur6e6nm2r6dzi7ny4wj6ai3j5hnvbhyd.onion/) | ❌ | 🇫🇷 FR | | [search.davidovski.xyz](https://search.davidovski.xyz/) | ❌ | ❌ | 🇬🇧 UK | | [search.madreyk.xyz](https://search.madreyk.xyz/) | ❌ | ❌ | 🇩🇪 DE | | [search.pabloferreiro.es](https://search.pabloferreiro.es/) | ❌ | ❌ | 🇩🇪 DE | @@ -30,9 +32,9 @@ | [search.zeroish.xyz](https://search.zeroish.xyz/) | ❌| ❌ | 🇺🇸 US | | [librex.baczek.me](https://librex.baczek.me/) | ❌| ❌ | 🇵🇱 PL | | [librex.yogeshlamichhane.com.np](https://librex.yogeshlamichhane.com.np/) | ❌| ❌ | 🇺🇸 US | -| [search.spaceint.fr](https://search.spaceint.fr/) | ❌ | ❌ | 🇩🇪 DE | | [lx.benike.monster](https://lx.benike.monster/) | ❌ | ❌ | 🇩🇪 DE | | [librex.nohost.network](https://librex.nohost.network/) | ❌ | ❌ | 🇲🇽 MX | +| [search.decentrala.org](https://search.decentrala.org/) | ❌| ❌ | 🇺🇸 US |
### Thanks rms diff --git a/docker/entrypoint.sh b/docker/entrypoint.sh index 525dd18..b3eb4b1 100755 --- a/docker/entrypoint.sh +++ b/docker/entrypoint.sh @@ -5,6 +5,6 @@ sh "docker/php/prepare.sh" sh "docker/server/prepare.sh" -/bin/sh -c /usr/sbin/php-fpm7 +/bin/sh -c /usr/sbin/php-fpm8 exec nginx -g "daemon off;" diff --git a/docker/php/php.dockerfile b/docker/php/php.dockerfile index 3252e0e..7c984e4 100644 --- a/docker/php/php.dockerfile +++ b/docker/php/php.dockerfile @@ -1,5 +1,5 @@ # Set this argument during build time to indicate that the path is for php's www.conf -ARG WWW_CONFIG="/etc/php7/php-fpm.d/www.conf" +ARG WWW_CONFIG="/etc/php8/php-fpm.d/www.conf" # Configure 'opensearch.xml' with Librex configuration metadata, such as the encoding and the host that stores the site # These configurations will replace the 'opensearch.xml' inside '.dockers/templates' for the best setup for your instance @@ -52,8 +52,8 @@ ENV CURLOPT_VERBOSE=true # Install PHP-FPM using Alpine's package manager, apk # Configure PHP-FPM to listen on a Unix socket instead of a TCP port, which is more secure and efficient -RUN apk add php7 php7-fpm php7-dom php7-curl php7-json --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing &&\ - sed -i 's/^\s*listen = 127.0.0.1:9000/listen = \/run\/php7\/php-fpm7.sock/' ${WWW_CONFIG} &&\ +RUN apk add php8 php8-fpm php8-dom php8-curl php8-json --no-cache --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing &&\ + sed -i 's/^\s*listen = 127.0.0.1:9000/listen = \/run\/php8\/php-fpm8.sock/' ${WWW_CONFIG} &&\ sed -i 's/^\s*;\s*listen.owner = nobody/listen.owner = nginx/' ${WWW_CONFIG} &&\ sed -i 's/^\s*;\s*listen.group = nobody/listen.group = nginx/' ${WWW_CONFIG} &&\ sed -i 's/^\s*;\s*listen.mode = 0660/listen.mode = 0660/' ${WWW_CONFIG} diff --git a/docker/php/prepare.sh b/docker/php/prepare.sh index 7a15b32..1ea7864 100755 --- a/docker/php/prepare.sh +++ b/docker/php/prepare.sh @@ -5,13 +5,13 @@ echo "[PREPARE] docker/server/prepare.sh'" # Load all environment variables from 'attributes.sh' using the command 'source /path/attributes.sh' source "docker/attributes.sh" -# This condition creates the Unix socket if 'php-fpm7.sock' does not already exist. +# This condition creates the Unix socket if 'php-fpm8.sock' does not already exist. # This fixes an issue where Nginx starts but does not serve content -if [ ! -d "/run/php7" ] || [ ! -S "/run/php7/php-fpm7.sock" ]; then - mkdir "/run/php7" - touch "/run/php7/php-fpm7.sock" - chmod 660 "/run/php7/php-fpm7.sock" - chown nginx:nginx "/run/php7/php-fpm7.sock" +if [ ! -d "/run/php8" ] || [ ! -S "/run/php8/php-fpm8.sock" ]; then + mkdir "/run/php8" + touch "/run/php8/php-fpm8.sock" + chmod 660 "/run/php8/php-fpm8.sock" + chown nginx:nginx "/run/php8/php-fpm8.sock" fi # The lines below will replace the environment variables in the templates with the corresponding variables listed above. To accomplish this, the GNU 'envsubst' package will be used diff --git a/docker/server/nginx.conf b/docker/server/nginx.conf index 24cce30..197c575 100644 --- a/docker/server/nginx.conf +++ b/docker/server/nginx.conf @@ -10,7 +10,7 @@ server { } location ~ \.php$ { - fastcgi_pass unix:/run/php7/php-fpm7.sock; + fastcgi_pass unix:/run/php8/php-fpm8.sock; fastcgi_index index.php; include fastcgi.conf; } diff --git a/engines/bittorrent/rutor.php b/engines/bittorrent/rutor.php index c5db2d5..8369f3e 100644 --- a/engines/bittorrent/rutor.php +++ b/engines/bittorrent/rutor.php @@ -10,20 +10,20 @@ foreach($xpath->query("//table/tr[@class='gai' or @class='tum']") as $result) { - $name = $xpath->evaluate(".//td/a", $result)[2]->textContent; $magnet = $xpath->evaluate(".//td/a/@href", $result)[1]->textContent; $magnet_without_tracker = explode("&tr=", $magnet)[0]; $magnet = $magnet_without_tracker . $config->bittorent_trackers; - $size = $xpath->evaluate(".//td", $result)[3]->textContent; + $td = $xpath->evaluate(".//td", $result); + $size = $td[count($td) == 5 ? 3 : 2]->textContent; $seeders = $xpath->evaluate(".//span", $result)[0]->textContent; $leechers = $xpath->evaluate(".//span", $result)[1]->textContent; array_push($results, array ( "name" => htmlspecialchars($name), - "seeders" => (int) remove_special($seeders), - "leechers" => (int) remove_special($leechers), + "seeders" => (int) filter_var($seeders, FILTER_SANITIZE_NUMBER_INT), + "leechers" => (int) filter_var($leechers, FILTER_SANITIZE_NUMBER_INT), "magnet" => htmlspecialchars($magnet), "size" => htmlspecialchars($size), "source" => "rutor.info" diff --git a/engines/google/text.php b/engines/google/text.php index b18a504..c598cc1 100644 --- a/engines/google/text.php +++ b/engines/google/text.php @@ -57,7 +57,7 @@ $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; } - + if ($url != NULL) { $special_ch = curl_init($url); @@ -70,6 +70,12 @@ do { curl_multi_exec($mh, $running); } while ($running); + if (curl_getinfo($google_ch)['http_code'] == '302') { + $instances_json = json_decode(file_get_contents("instances.json"), true); + $instances = array_map(fn($n) => $n['clearnet'], array_filter($instances_json['instances'], fn($n) => !is_null($n['clearnet']))); + header("Location: " . $instances[array_rand($instances)] . "search.php?q=$query"); + die(); + } if ($special_search != 0) diff --git a/instances.json b/instances.json index db27739..fa6501b 100644 --- a/instances.json +++ b/instances.json @@ -18,12 +18,24 @@ "i2p": "http://s.dyoxin.i2p/", "country": "IS" }, + { + "clearnet": "https://lx.vern.cc/", + "tor": "http://lx.vernccvbvyi5qhfzyqengccj7lkove6bjot2xhh5kajhwvidqafczrad.onion/", + "i2p": "http://vernziqfqvweijfaacmwazohgpdo2bt2ib2jlupt2pwwu27bhgxq.b32.i2p/", + "country": "US" + }, { "clearnet": "https://search.ahwx.org/", "tor": "http://cosrpybbddzdfjquer3zfmb2h5avtacnctnbu4gucwocdb42s63gcqqd.onion/", "i2p": null, "country": "NL" }, + { + "clearnet": "https://search.spaceint.fr/", + "tor": "http://6d4nqt2rndvmhogpwrbqfvj2ur6e6nm2r6dzi7ny4wj6ai3j5hnvbhyd.onion/", + "i2p": null, + "country": "FR" + }, { "clearnet": "https://search.davidovski.xyz/", "tor": null, @@ -102,12 +114,6 @@ "i2p": null, "country": "US" }, - { - "clearnet": "https://search.spaceint.fr/", - "tor": null, - "i2p": null, - "country": "DE" - }, { "clearnet": "https://lx.benike.monster/", "tor": null, @@ -119,6 +125,12 @@ "tor": null, "i2p": null, "country": "MX" + }, + { + "clearnet": "https://search.decentrala.org/", + "tor": null, + "i2p": null, + "country": "US" } ] } diff --git a/misc/tools.php b/misc/tools.php index 19f36cb..6735220 100644 --- a/misc/tools.php +++ b/misc/tools.php @@ -56,6 +56,12 @@ $gist_path = explode("gist.github.com", $url)[1]; $url = $frontend . "/gist" . $gist_path; } + else if (strpos($url, "stackexchange.com") !== false) + { + $se_domain = explode(".", explode("://", $url)[1])[0]; + $se_path = explode("stackexchange.com", $url)[1]; + $url = $frontend . "/exchange" . "/" . $se_domain . $se_path; + } else { $url = $frontend . explode($original, $url)[1]; @@ -85,6 +91,11 @@ $url = try_replace_with_frontend($url, $frontend, $original); break; } + else if (strpos($url, "stackexchange.com")) + { + $url = try_replace_with_frontend($url, "anonymousoverflow", "stackexchange.com"); + break; + } } return $url;