Compare commits

4 Commits

Author SHA1 Message Date
Victor Bodinaud
35ec8c6fed 🐛Fix composer install for docker 2025-03-19 13:53:59 +01:00
Victor Bodinaud
4c187e4059 🌐Add network to docker 2025-03-19 13:49:05 +01:00
Victor Bodinaud
ca0fa5b815 Change name to AlpineFind & some enhancements 2025-03-19 13:45:57 +01:00
Victor Bodinaud
dd78fcafd9 📱Add mobile support 2025-03-18 11:26:37 +01:00
11 changed files with 497 additions and 234 deletions

BIN
.DS_Store vendored

Binary file not shown.

30
Dockerfile Normal file
View File

@@ -0,0 +1,30 @@
FROM arm64v8/php:8.1-apache
# Installation des dépendances PHP nécessaires
RUN apt-get update && apt-get install -y \
libfreetype6-dev \
libjpeg62-turbo-dev \
libpng-dev \
git \
unzip \
&& docker-php-ext-configure gd --with-freetype --with-jpeg \
&& docker-php-ext-install -j$(nproc) gd
# Activer le module rewrite pour Apache
RUN a2enmod rewrite
# Installer Composer
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer
# Définir le répertoire de travail
WORKDIR /var/www/html
# Exposer le port 80
EXPOSE 80
# Script d'initialisation pour exécuter composer install et démarrer Apache
COPY docker-entrypoint.sh /usr/local/bin/
RUN chmod +x /usr/local/bin/docker-entrypoint.sh
ENTRYPOINT ["docker-entrypoint.sh"]
CMD ["apache2-foreground"]

View File

@@ -1,4 +1,4 @@
# FrogFind
Source for the FrogFind search engine for vintage computers
# AlpineFind
Source for the AlpineFind search engine for vintage computers
Love the frog. Be the frog.
Love the Alpine. Be the Alpine.

View File

@@ -4,30 +4,47 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 2.0//EN">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<html>
<head>
<title>FrogFind!</title>
<title>AlpineFind!</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<style type="text/css">
a {
padding: 4px 0;
display: inline-block;
}
h3 {
margin-top: 16px;
}
</style>
</head>
<body>
<body style="margin: 5px; padding: 0;">
<form action="/" method="get">
<a href="/"><font size=6 color="#008000">Frog</font><font size=6 color="#000000">Find!</font></a> Leap again: <input type="text" size="30" name="q" value="<?php echo urldecode($query) ?>">
<a href="/">
<font size=6 color="#008000">Alpine</font>
<font size=6 color="#000000">Find!</font>
</a>
<p>Leap again:</p>
<input type="text" size="30" name="q" value="<?php echo urldecode($query) ?>">
<input type="submit" value="Ribbbit!">
</form>
<hr>
<br>
<center>
<h1>What in the world is FrogFind?</h1>
<h1>What in the world is AlpineFind?</h1>
<small>A quick FAQ on an unconventional search engine</small>
</center>
<br>
<h3>Who made FrogFind?</h3>
<h3>Who made AlpineFind?</h3>
Hi, I'm Sean, A.K.A. <a href="https://youtube.com/ActionRetro">Action Retro</a> on YouTube. I work on a lot of 80's and 90's Macs (and other vintage machines), and I really like to try and get them online. However, the modern internet is not kind to old machines, which generally cannot handle the complicated javascript, CSS, and encryption that modern sites have. However, they can browse basic websites just fine. So I decided to see how much of the internet I could turn into basic websites, so that old machines can browse the modern internet once again!
<h3>How does FrogFind work?</h3>
The search functionality of FrogFind is basically a custom wrapper for DuckDuckGo search, converting the results to extremely basic HTML that old browsers can read. When clicking through to pages from search results, those pages are processed through a <a href="https://github.com/fivefilters/readability.php" target="_blank">PHP port of Mozilla's Readability</a>, which is what powers Firefox's reader mode. I then further strip down the results to be as basic HTML as possible.
<h3>What machines do you test FrogFind on?</h3>
I designed FrogFind with classic Macs in mind, so I've been testing on my SE/30 to make sure it looks good in 1 bit color with a 512x384 resolution. Most of my testing has been on Netscape 1.1N and 2.0.2, as well as a few 68k Mac versions of iCab. FrogFind should also work great on any text-based web browser!
<h3>How does AlpineFind work?</h3>
The search functionality of AlpineFind is basically a custom wrapper for DuckDuckGo search, converting the results to extremely basic HTML that old browsers can read. When clicking through to pages from search results, those pages are processed through a <a href="https://github.com/fivefilters/readability.php" target="_blank">PHP port of Mozilla's Readability</a>, which is what powers Firefox's reader mode. I then further strip down the results to be as basic HTML as possible.
<h3>What machines do you test AlpineFind on?</h3>
I designed AlpineFind with classic Macs in mind, so I've been testing on my SE/30 to make sure it looks good in 1 bit color with a 512x384 resolution. Most of my testing has been on Netscape 1.1N and 2.0.2, as well as a few 68k Mac versions of iCab. AlpineFind should also work great on any text-based web browser!
<h3>How can I get in touch with you?</h3>
Send me an email! <a href="mailto:actionretro@pm.me">actionretro@pm.me</a>
</body>
</html>

237
composer.lock generated
View File

@@ -8,30 +8,30 @@
"packages": [
{
"name": "fivefilters/readability.php",
"version": "v3.1.6",
"version": "v3.3.2",
"source": {
"type": "git",
"url": "https://github.com/fivefilters/readability.php.git",
"reference": "a00d35cb5eb14a236ba42326da9ac52c8c9f80a1"
"reference": "2cd2d3d7b24d3df9cc1dcb8919451876c693d69b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/fivefilters/readability.php/zipball/a00d35cb5eb14a236ba42326da9ac52c8c9f80a1",
"reference": "a00d35cb5eb14a236ba42326da9ac52c8c9f80a1",
"url": "https://api.github.com/repos/fivefilters/readability.php/zipball/2cd2d3d7b24d3df9cc1dcb8919451876c693d69b",
"reference": "2cd2d3d7b24d3df9cc1dcb8919451876c693d69b",
"shasum": ""
},
"require": {
"ext-dom": "*",
"ext-mbstring": "*",
"ext-xml": "*",
"league/uri": "~6.7.2",
"league/uri": "^7.0",
"masterminds/html5": "^2.0",
"php": ">=7.4.0",
"php": ">=8.1",
"psr/log": "^1.0 || ^2.0 || ^3.0"
},
"require-dev": {
"monolog/monolog": "^2.3",
"phpunit/phpunit": "^9"
"monolog/monolog": "^3.0",
"phpunit/phpunit": "^10.0 || ^11.0"
},
"suggest": {
"monolog/monolog": "Allow logging debug information"
@@ -67,59 +67,50 @@
],
"support": {
"issues": "https://github.com/fivefilters/readability.php/issues",
"source": "https://github.com/fivefilters/readability.php/tree/v3.1.6"
"source": "https://github.com/fivefilters/readability.php/tree/v3.3.2"
},
"time": "2023-06-15T18:06:49+00:00"
"time": "2025-03-07T18:17:00+00:00"
},
{
"name": "league/uri",
"version": "6.7.2",
"version": "7.5.1",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/uri.git",
"reference": "d3b50812dd51f3fbf176344cc2981db03d10fe06"
"reference": "81fb5145d2644324614cc532b28efd0215bda430"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/uri/zipball/d3b50812dd51f3fbf176344cc2981db03d10fe06",
"reference": "d3b50812dd51f3fbf176344cc2981db03d10fe06",
"url": "https://api.github.com/repos/thephpleague/uri/zipball/81fb5145d2644324614cc532b28efd0215bda430",
"reference": "81fb5145d2644324614cc532b28efd0215bda430",
"shasum": ""
},
"require": {
"ext-json": "*",
"league/uri-interfaces": "^2.3",
"php": "^7.4 || ^8.0",
"psr/http-message": "^1.0"
"league/uri-interfaces": "^7.5",
"php": "^8.1"
},
"conflict": {
"league/uri-schemes": "^1.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^v3.3.2",
"nyholm/psr7": "^1.5",
"php-http/psr7-integration-tests": "^1.1",
"phpstan/phpstan": "^1.2.0",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-phpunit": "^1.0.0",
"phpstan/phpstan-strict-rules": "^1.1.0",
"phpunit/phpunit": "^9.5.10",
"psr/http-factory": "^1.0"
},
"suggest": {
"ext-fileinfo": "Needed to create Data URI from a filepath",
"ext-intl": "Needed to improve host validation",
"league/uri-components": "Needed to easily manipulate URI objects",
"psr/http-factory": "Needed to use the URI factory"
"ext-bcmath": "to improve IPV4 host parsing",
"ext-fileinfo": "to create Data URI from file contennts",
"ext-gmp": "to improve IPV4 host parsing",
"ext-intl": "to handle IDN host with the best performance",
"jeremykendall/php-domain-parser": "to resolve Public Suffix and Top Level Domain",
"league/uri-components": "Needed to easily manipulate URI objects components",
"php-64bit": "to improve IPV4 host parsing",
"symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "6.x-dev"
"dev-master": "7.x-dev"
}
},
"autoload": {
"psr-4": {
"League\\Uri\\": "src"
"League\\Uri\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -159,8 +150,8 @@
"support": {
"docs": "https://uri.thephpleague.com",
"forum": "https://thephpleague.slack.com",
"issues": "https://github.com/thephpleague/uri/issues",
"source": "https://github.com/thephpleague/uri/tree/6.7.2"
"issues": "https://github.com/thephpleague/uri-src/issues",
"source": "https://github.com/thephpleague/uri/tree/7.5.1"
},
"funding": [
{
@@ -168,46 +159,44 @@
"type": "github"
}
],
"time": "2022-09-13T19:50:42+00:00"
"time": "2024-12-08T08:40:02+00:00"
},
{
"name": "league/uri-interfaces",
"version": "2.3.0",
"version": "7.5.0",
"source": {
"type": "git",
"url": "https://github.com/thephpleague/uri-interfaces.git",
"reference": "00e7e2943f76d8cb50c7dfdc2f6dee356e15e383"
"reference": "08cfc6c4f3d811584fb09c37e2849e6a7f9b0742"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/00e7e2943f76d8cb50c7dfdc2f6dee356e15e383",
"reference": "00e7e2943f76d8cb50c7dfdc2f6dee356e15e383",
"url": "https://api.github.com/repos/thephpleague/uri-interfaces/zipball/08cfc6c4f3d811584fb09c37e2849e6a7f9b0742",
"reference": "08cfc6c4f3d811584fb09c37e2849e6a7f9b0742",
"shasum": ""
},
"require": {
"ext-json": "*",
"php": "^7.2 || ^8.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^2.19",
"phpstan/phpstan": "^0.12.90",
"phpstan/phpstan-phpunit": "^0.12.19",
"phpstan/phpstan-strict-rules": "^0.12.9",
"phpunit/phpunit": "^8.5.15 || ^9.5"
"ext-filter": "*",
"php": "^8.1",
"psr/http-factory": "^1",
"psr/http-message": "^1.1 || ^2.0"
},
"suggest": {
"ext-intl": "to use the IDNA feature",
"symfony/intl": "to use the IDNA feature via Symfony Polyfill"
"ext-bcmath": "to improve IPV4 host parsing",
"ext-gmp": "to improve IPV4 host parsing",
"ext-intl": "to handle IDN host with the best performance",
"php-64bit": "to improve IPV4 host parsing",
"symfony/polyfill-intl-idn": "to handle IDN host via the Symfony polyfill if ext-intl is not present"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.x-dev"
"dev-master": "7.x-dev"
}
},
"autoload": {
"psr-4": {
"League\\Uri\\": "src/"
"League\\Uri\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
@@ -221,17 +210,32 @@
"homepage": "https://nyamsprod.com"
}
],
"description": "Common interface for URI representation",
"homepage": "http://github.com/thephpleague/uri-interfaces",
"description": "Common interfaces and classes for URI representation and interaction",
"homepage": "https://uri.thephpleague.com",
"keywords": [
"data-uri",
"file-uri",
"ftp",
"hostname",
"http",
"https",
"parse_str",
"parse_url",
"psr-7",
"query-string",
"querystring",
"rfc3986",
"rfc3987",
"rfc6570",
"uri",
"url"
"url",
"ws"
],
"support": {
"issues": "https://github.com/thephpleague/uri-interfaces/issues",
"source": "https://github.com/thephpleague/uri-interfaces/tree/2.3.0"
"docs": "https://uri.thephpleague.com",
"forum": "https://thephpleague.slack.com",
"issues": "https://github.com/thephpleague/uri-src/issues",
"source": "https://github.com/thephpleague/uri-interfaces/tree/7.5.0"
},
"funding": [
{
@@ -239,20 +243,20 @@
"type": "github"
}
],
"time": "2021-06-28T04:27:21+00:00"
"time": "2024-12-08T08:18:47+00:00"
},
{
"name": "masterminds/html5",
"version": "2.8.1",
"version": "2.9.0",
"source": {
"type": "git",
"url": "https://github.com/Masterminds/html5-php.git",
"reference": "f47dcf3c70c584de14f21143c55d9939631bc6cf"
"reference": "f5ac2c0b0a2eefca70b2ce32a5809992227e75a6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Masterminds/html5-php/zipball/f47dcf3c70c584de14f21143c55d9939631bc6cf",
"reference": "f47dcf3c70c584de14f21143c55d9939631bc6cf",
"url": "https://api.github.com/repos/Masterminds/html5-php/zipball/f5ac2c0b0a2eefca70b2ce32a5809992227e75a6",
"reference": "f5ac2c0b0a2eefca70b2ce32a5809992227e75a6",
"shasum": ""
},
"require": {
@@ -260,7 +264,7 @@
"php": ">=5.3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.7.21 || ^6 || ^7 || ^8"
"phpunit/phpunit": "^4.8.35 || ^5.7.21 || ^6 || ^7 || ^8 || ^9"
},
"type": "library",
"extra": {
@@ -304,31 +308,32 @@
],
"support": {
"issues": "https://github.com/Masterminds/html5-php/issues",
"source": "https://github.com/Masterminds/html5-php/tree/2.8.1"
"source": "https://github.com/Masterminds/html5-php/tree/2.9.0"
},
"time": "2023-05-10T11:58:31+00:00"
"time": "2024-03-31T07:05:07+00:00"
},
{
"name": "psr/http-message",
"version": "1.1",
"name": "psr/http-factory",
"version": "1.1.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba"
"url": "https://github.com/php-fig/http-factory.git",
"reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
"reference": "cb6ce4845ce34a8ad9e68117c10ee90a29919eba",
"url": "https://api.github.com/repos/php-fig/http-factory/zipball/2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"reference": "2b4765fddfe3b508ac62f829e852b1501d3f6e8a",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
"php": ">=7.1",
"psr/http-message": "^1.0 || ^2.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
"dev-master": "1.0.x-dev"
}
},
"autoload": {
@@ -343,7 +348,61 @@
"authors": [
{
"name": "PHP-FIG",
"homepage": "http://www.php-fig.org/"
"homepage": "https://www.php-fig.org/"
}
],
"description": "PSR-17: Common interfaces for PSR-7 HTTP message factories",
"keywords": [
"factory",
"http",
"message",
"psr",
"psr-17",
"psr-7",
"request",
"response"
],
"support": {
"source": "https://github.com/php-fig/http-factory"
},
"time": "2024-04-15T12:06:14+00:00"
},
{
"name": "psr/http-message",
"version": "2.0",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message.git",
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message/zipball/402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"reference": "402d35bcb92c70c026d1a6a9883f06b2ead23d71",
"shasum": ""
},
"require": {
"php": "^7.2 || ^8.0"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Psr\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Common interface for HTTP messages",
@@ -357,22 +416,22 @@
"response"
],
"support": {
"source": "https://github.com/php-fig/http-message/tree/1.1"
"source": "https://github.com/php-fig/http-message/tree/2.0"
},
"time": "2023-04-04T09:50:52+00:00"
"time": "2023-04-04T09:54:51+00:00"
},
{
"name": "psr/log",
"version": "3.0.0",
"version": "3.0.2",
"source": {
"type": "git",
"url": "https://github.com/php-fig/log.git",
"reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001"
"reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/log/zipball/fe5ea303b0887d5caefd3d431c3e61ad47037001",
"reference": "fe5ea303b0887d5caefd3d431c3e61ad47037001",
"url": "https://api.github.com/repos/php-fig/log/zipball/f16e1d5863e37f8d8c2a01719f5b34baa2b714d3",
"reference": "f16e1d5863e37f8d8c2a01719f5b34baa2b714d3",
"shasum": ""
},
"require": {
@@ -407,18 +466,18 @@
"psr-3"
],
"support": {
"source": "https://github.com/php-fig/log/tree/3.0.0"
"source": "https://github.com/php-fig/log/tree/3.0.2"
},
"time": "2021-07-14T16:46:02+00:00"
"time": "2024-09-11T13:17:53+00:00"
}
],
"packages-dev": [],
"aliases": [],
"minimum-stability": "stable",
"stability-flags": [],
"stability-flags": {},
"prefer-stable": false,
"prefer-lowest": false,
"platform": [],
"platform-dev": [],
"plugin-api-version": "2.3.0"
"platform": {},
"platform-dev": {},
"plugin-api-version": "2.6.0"
}

17
docker-compose.yml Normal file
View File

@@ -0,0 +1,17 @@
version: '3'
services:
alpinefind:
build: .
ports:
- "7000:80"
volumes:
- ./:/var/www/html
restart: unless-stopped
networks:
- supabase_default
- default
networks:
supabase_default:
external: true

13
docker-entrypoint.sh Normal file
View File

@@ -0,0 +1,13 @@
#!/bin/bash
set -e
# Exécuter composer install si le répertoire vendor n'existe pas
if [ ! -d "vendor" ]; then
composer install --no-interaction --optimize-autoloader
fi
# Ajuster les permissions
chown -R www-data:www-data /var/www/html
# Passer au processus principal
exec "$@"

View File

@@ -28,14 +28,20 @@
<html>
<head>
<title>FrogFind Image Viewer</title>
<title>AlpineFind Image Viewer</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
</head>
<body">
<small><a href="<?php echo $_SERVER['HTTP_REFERER'] ?>">< Back to previous page</a></small>
<body style="margin: 5px; padding: 0;">
<small><a href="<?php echo $_SERVER['HTTP_REFERER'] ?>">
< Back to previous page</a></small>
<p><small><b>Viewing image:</b> <?php echo $url ?></small></p>
<img src="/image_compressed.php?i=<?php echo $url; ?>">
<br><br>
<small><a href="<?php echo $_SERVER['HTTP_REFERER'] ?>">< Back to previous page</a></small>
<small><a href="<?php echo $_SERVER['HTTP_REFERER'] ?>">
< Back to previous page</a></small>
</body>
</html>

View File

@@ -31,10 +31,10 @@ $raw_imagex = imagesx($raw_image);
$raw_imagey = imagesy($raw_image);
if ($raw_imagex >= $raw_imagey) {
$dest_imagex = 300;
$dest_imagex = 240; // Réduit de 300 à 240
$dest_imagey = intval(($raw_imagey / $raw_imagex) * $dest_imagex);
} else {
$dest_imagey = 200;
$dest_imagey = 160; // Réduit de 200 à 160
$dest_imagex = intval(($raw_imagex / $raw_imagey) * $dest_imagey);
}
@@ -44,9 +44,9 @@ imagecopyresampled($dest_image, $raw_image, 0, 0, 0, 0, $dest_imagex, $dest_imag
header('Content-type: image/' . $filetype);
if ($filetype = "jpg") {
imagejpeg($dest_image,NULL,80); //80% quality
// Compression augmentée de 80% à 65%
imagejpeg($dest_image, NULL, 65);
} elseif ($filetype = "png") {
imagepng($dest_image,NULL,8); //80% compression
// Compression augmentée de 8 à 9 (plus compressé)
imagepng($dest_image, NULL, 9);
}
?>

133
index.php
View File

@@ -9,7 +9,20 @@ if(isset( $_GET['q'])) { // if there's a search query, show the results for it
$query = urlencode($_GET["q"]);
$show_results = TRUE;
$search_url = "https://html.duckduckgo.com/html?q=" . $query;
if(!$results_html = file_get_contents($search_url)) {
// Configuration de la pagination
$results_per_page = 5; // Nombre de résultats par page
$current_page = isset($_GET['p']) ? intval($_GET['p']) : 1;
if ($current_page < 1) $current_page = 1;
$context = stream_context_create([
'http' => [
'header' => "Cache-Control: no-cache\r\n" .
"Pragma: no-cache\r\n" .
"User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 2_0 like Mac OS X) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5A347 Safari/525.20\r\n"
]
]);
if (!$results_html = file_get_contents($search_url, false, $context)) {
$error_text .= "Failed to get results, sorry :( <br>";
}
$simple_results = $results_html;
@@ -20,8 +33,16 @@ if(isset( $_GET['q'])) { // if there's a search query, show the results for it
$result_blocks = explode('<h2 class="result__title">', $simple_results);
$total_results = count($result_blocks) - 1;
for ($x = 1; $x <= $total_results; $x++) {
if(strpos($result_blocks[$x], '<a class="badge--ad">')===false) { //only return non ads
// Calcul des paramètres de pagination
$total_pages = ceil($total_results / $results_per_page);
if ($total_pages == 0) $total_pages = 1; // Éviter la division par zéro
$start_result = ($current_page - 1) * $results_per_page + 1;
$end_result = min($start_result + $results_per_page - 1, $total_results);
// Affichage des résultats pour la page actuelle seulement
for ($x = $start_result; $x <= $end_result; $x++) {
if ($x <= $total_results && strpos($result_blocks[$x], '<a class="badge--ad">') === false) { //only return non ads
// result link, redirected through our proxy
$result_link = explode('class="result__a" href="', $result_blocks[$x])[1];
$result_topline = explode('">', $result_link);
@@ -40,10 +61,22 @@ if(isset( $_GET['q'])) { // if there's a search query, show the results for it
. $result_display_url . "</font></a><br>" . $result_snippet . "<br><br><hr>";
}
}
// Ajout des liens de pagination
$final_result_html .= "<br><center>";
if ($current_page > 1) {
$final_result_html .= "<a href='/?q=" . $query . "&p=" . ($current_page - 1) . "'>&lt; Previous</a> ";
}
$final_result_html .= "Page " . $current_page . " of " . $total_pages;
if ($current_page < $total_pages) {
$final_result_html .= " <a href='/?q=" . $query . "&p=" . ($current_page + 1) . "'>Next &gt;</a>";
}
$final_result_html .= "</center>";
}
//replace chars that old machines probably can't handle
function clean_str($str) {
function clean_str($str)
{
$str = str_replace("", "'", $str);
$str = str_replace("", "'", $str);
$str = str_replace("", '"', $str);
@@ -59,15 +92,63 @@ function clean_str($str) {
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<html>
<head>
<title>FrogFind!</title>
<title>AlpineFind!</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<style type="text/css">
a {
padding: 4px 0;
display: inline-block;
}
input[type="text"] {
font-size: 16px;
height: 24px;
margin-bottom: 8px;
width: 80%;
max-width: 280px;
}
input[type="submit"] {
font-size: 16px;
height: 32px;
padding: 2px 12px;
margin-top: 5px;
margin-bottom: 5px;
display: block;
}
.search-form {
margin: 10px 0;
}
</style>
<script type="text/javascript">
function showLoading() {
document.getElementById('loading').style.display = 'inline';
return true;
}
</script>
</head>
<body>
<?php if($show_results) { // there's a search query in q, so show search results ?>
<body style="margin: 5px; padding: 0;">
<form action="/" method="get">
<a href="/"><font size=6 color="#008000">Frog</font><font size=6 color="#000000">Find!</font></a> Leap again: <input type="text" size="30" name="q" value="<?php echo urldecode($query) ?>">
<?php if ($show_results) { // there's a search query in q, so show search results
?>
<form action="/" method="get" onsubmit="return showLoading();" class="search-form">
<a href="/">
<font size=6 color="#008000">Alpine</font>
<font size=6 color="#000000">Find!</font>
</a>
<div style="margin: 8px 0;">
<p>Leap again:</p>
<input type="text" size="30" name="q" value="<?php echo urldecode($query) ?>">
<?php if (isset($_GET['p'])) { ?>
<input type="hidden" name="p" value="1">
<?php } ?>
</div>
<span id="loading" style="display: none;">Loading...</span>
<input type="submit" value="Ribbbit!">
</form>
<hr>
@@ -76,22 +157,36 @@ function clean_str($str) {
<br>
<?php echo $final_result_html ?>
<?php } else { // no search query, so show new search ?>
<br><br><center><h1><font size=7><font color="#008000">Frog</font>Find!</font></h1></center>
<center><h3>The Search Engine for Vintage Computers</h3></center>
<?php } else { // no search query, so show new search
?>
<br><br>
<center>
<form action="/" method="get">
Leap to: <input type="text" size="30" name="q"><br>
<input type="submit" value="Ribbbit!">
<h1>
<font size=7>
<font color="#008000">Alpine</font>Find!
</font>
</h1>
</center>
<center>
<h3>The Search Engine for Vintage Computers</h3>
</center>
<br><br>
<center>
<form action="/" method="get" onsubmit="return showLoading();">
<p>Leap to:</p>
<input type="text" size="30" name="q"><br>
<span id="loading" style="display: none;">Loading...</span>
<input type="submit" value="Ribbbit!" style="margin: 10px auto;">
</form>
</center>
<br><br><br>
<small><center>Built by <b><a href="https://youtube.com/ActionRetro">Action Retro</a></b> on YouTube | <a href="about.php">Why build such a thing?</a></center><br>
<small><center>Powered by DuckDuckGo</center></small>
<small>
<center>Built by <b><a href="https://youtube.com/ActionRetro">Action Retro</a></b> on YouTube | <a href="about.php">Why build such a thing?</a></center><br>
<small>
<center>Powered by DuckDuckGo</center>
</small>
</form>
</form>
<?php } ?>
</body>
</html>

View File

@@ -38,8 +38,7 @@ $headers = get_headers($article_url, true, $context);
if (!array_key_exists('Content-Type', $headers) || !array_key_exists('Content-Length', $headers)) {
$error_text .= "Failed to get the article, its server did not return expected details :( <br>";
}
else {
} else {
// Attempt to handle downloads or other mime-types by passing proxying them through.
if (!in_array($headers['Content-Type'], $compatible_content_types)) {
$filesize = $headers['Content-Length'];
@@ -49,8 +48,7 @@ else {
echo 'Failed to proxy file download, it\'s too large. :( <br>';
echo 'You can try downloading the file directly: ' . $article_url;
die();
}
else {
} else {
$contentType = $headers['Content-Type'];
// Only use the last-provided content type if an array was returned (ie. when there were redirects involved)
if (is_array($contentType)) {
@@ -107,7 +105,8 @@ try {
}
//replace chars that old machines probably can't handle
function clean_str($str) {
function clean_str($str)
{
$str = str_replace("", "'", $str);
$str = str_replace("", "'", $str);
$str = str_replace("", '"', $str);
@@ -121,13 +120,35 @@ function clean_str($str) {
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<html>
<head>
<title><?php echo $readability->getTitle(); ?></title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<style type="text/css">
a {
padding: 4px 0;
display: inline-block;
}
input[type="text"] {
font-size: 16px;
height: 24px;
}
input[type="submit"] {
font-size: 16px;
height: 32px;
padding: 2px 8px;
}
</style>
</head>
<body>
<body style="margin: 5px; padding: 0;">
<p>
<form action="/read.php" method="get">
<a href="/">Back to <b><font color="#008000">Frog</font><font color="000000">Find!</font></a></b> | Browsing URL: <input type="text" size="38" name="a" value="<?php echo $article_url ?>">
<a href="/">Back to <b>
<font color="#008000">Alpine</font>
<font color="000000">Find!</font></a></b> | Browsing URL: <input type="text" size="38" name="a" value="<?php echo $article_url ?>">
<input type="submit" value="Go!">
</form>
</p>
@@ -147,7 +168,12 @@ function clean_str($str) {
echo $imgline_html;
}
?></small></p>
<?php if($error_text) { echo "<p><font color='red'>" . $error_text . "</font></p>"; } ?>
<p><font size="4"><?php echo $readable_article;?></font></p>
<?php if ($error_text) {
echo "<p><font color='red'>" . $error_text . "</font></p>";
} ?>
<p>
<font size="4"><?php echo $readable_article; ?></font>
</p>
</body>
</html>