📱Add mobile support

This commit is contained in:
Victor Bodinaud
2025-03-18 11:26:37 +01:00
parent d70edb9f2e
commit dd78fcafd9
7 changed files with 391 additions and 226 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -4,30 +4,45 @@
<!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>
</head>
<body>
<title>FrogFind!</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;
}
<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) ?>">
<input type="submit" value="Ribbbit!">
h3 {
margin-top: 16px;
}
</style>
</head>
<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) ?>">
<input type="submit" value="Ribbbit!">
</form>
<hr>
<br>
<center>
<h1>What in the world is FrogFind?</h1>
<small>A quick FAQ on an unconventional search engine</small>
<h1>What in the world is FrogFind?</h1>
<small>A quick FAQ on an unconventional search engine</small>
</center>
<br>
<h3>Who made FrogFind?</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.
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 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"
}

View File

@@ -1,41 +1,47 @@
<?php
$url = "";
//get the image url
if (isset( $_GET['i'] ) ) {
$url = $_GET[ 'i' ];
} else {
exit();
}
$url = "";
//we can only do jpg and png here
if (strpos($url, ".jpg") && strpos($url, ".jpeg") && strpos($url, ".png") != true ) {
echo strpos($url, ".jpg");
echo "Unsupported file type :(";
exit();
}
//get the image url
if (isset($_GET['i'])) {
$url = $_GET['i'];
} else {
exit();
}
//image needs to start with http
if (substr( $url, 0, 4 ) != "http") {
echo("Image failed :(");
exit();
}
//we can only do jpg and png here
if (strpos($url, ".jpg") && strpos($url, ".jpeg") && strpos($url, ".png") != true) {
echo strpos($url, ".jpg");
echo "Unsupported file type :(";
exit();
}
//image needs to start with http
if (substr($url, 0, 4) != "http") {
echo ("Image failed :(");
exit();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 2.0//EN">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<html>
<head>
<title>FrogFind Image Viewer</title>
</head>
<body">
<small><a href="<?php echo $_SERVER['HTTP_REFERER'] ?>">< Back to previous page</a></small>
<html>
<head>
<title>FrogFind Image Viewer</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
</head>
<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>
</body>
</html>
<small><a href="<?php echo $_SERVER['HTTP_REFERER'] ?>">
< Back to previous page</a></small>
</body>
</html>

View File

@@ -5,14 +5,14 @@ $filetype = "";
$raw_image = NULL;
//get the image url
if (isset( $_GET['i'] ) ) {
$url = $_GET[ 'i' ];
if (isset($_GET['i'])) {
$url = $_GET['i'];
} else {
exit();
}
//an image will start with http, anything else is sus
if (substr( $url, 0, 4 ) != "http") {
if (substr($url, 0, 4) != "http") {
exit();
}
@@ -31,22 +31,20 @@ $raw_imagex = imagesx($raw_image);
$raw_imagey = imagesy($raw_image);
if ($raw_imagex >= $raw_imagey) {
$dest_imagex = 300;
$dest_imagey = intval(($raw_imagey / $raw_imagex) * $dest_imagex);
$dest_imagex = 240; // Réduit de 300 à 240
$dest_imagey = intval(($raw_imagey / $raw_imagex) * $dest_imagex);
} else {
$dest_imagey = 200;
$dest_imagex = intval(($raw_imagex / $raw_imagey) * $dest_imagey);
$dest_imagey = 160; // Réduit de 200 à 160
$dest_imagex = intval(($raw_imagex / $raw_imagey) * $dest_imagey);
}
$dest_image = imagecreatetruecolor($dest_imagex, $dest_imagey);
imagecopyresampled($dest_image, $raw_image, 0, 0, 0, 0, $dest_imagex, $dest_imagey, $raw_imagex, $raw_imagey);
header('Content-type: image/' . $filetype);
header('Content-type: image/' . $filetype);
if ($filetype = "jpg") {
imagejpeg($dest_image,NULL,80); //80% quality
imagejpeg($dest_image, NULL, 80); //80% quality
} elseif ($filetype = "png") {
imagepng($dest_image,NULL,8); //80% compression
imagepng($dest_image, NULL, 8); //80% compression
}
?>

153
index.php
View File

@@ -5,29 +5,36 @@ $show_results = FALSE;
$results_html = "";
$final_result_html = "<hr>";
if(isset( $_GET['q'])) { // if there's a search query, show the results for it
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)) {
$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;
$simple_results = str_replace( 'strong>', 'b>', $simple_results ); //change <strong> to <b>
$simple_results = str_replace( 'em>', 'i>', $simple_results ); //change <em> to <i>
$simple_results = $results_html;
$simple_results = str_replace('strong>', 'b>', $simple_results); //change <strong> to <b>
$simple_results = str_replace('em>', 'i>', $simple_results); //change <em> to <i>
$simple_results = clean_str($simple_results);
$result_blocks = explode('<h2 class="result__title">', $simple_results);
$total_results = count($result_blocks)-1;
$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
if (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);
$result_link = str_replace( '//duckduckgo.com/l/?uddg=', '/read.php?a=', $result_topline[0]);
$result_link = str_replace('//duckduckgo.com/l/?uddg=', '/read.php?a=', $result_topline[0]);
// result title
$result_title = str_replace("</a>","",explode("\n", $result_topline[1]));
$result_title = str_replace("</a>", "", explode("\n", $result_topline[1]));
// result display url
$result_display_url = explode('class="result__url"', $result_blocks[$x])[1];
$result_display_url = trim(explode("\n", $result_display_url)[1]);
@@ -36,20 +43,21 @@ if(isset( $_GET['q'])) { // if there's a search query, show the results for it
$result_snippet = explode('">', $result_snippet)[1];
$result_snippet = explode('</a>', $result_snippet)[0];
$final_result_html .= "<br><a href='" . $result_link . "'><font size='4'><b>" . $result_title[0] . "</b></font><br><font color='#008000' size='2'>"
. $result_display_url . "</font></a><br>" . $result_snippet . "<br><br><hr>";
$final_result_html .= "<br><a href='" . $result_link . "'><font size='4'><b>" . $result_title[0] . "</b></font><br><font color='#008000' size='2'>"
. $result_display_url . "</font></a><br>" . $result_snippet . "<br><br><hr>";
}
}
}
//replace chars that old machines probably can't handle
function clean_str($str) {
$str = str_replace( "", "'", $str );
$str = str_replace( "", "'", $str );
$str = str_replace( "", '"', $str );
$str = str_replace( "", '"', $str );
$str = str_replace( "", '-', $str );
$str = str_replace( "&#x27;", "'", $str );
function clean_str($str)
{
$str = str_replace("", "'", $str);
$str = str_replace("", "'", $str);
$str = str_replace("", '"', $str);
$str = str_replace("", '"', $str);
$str = str_replace("", '-', $str);
$str = str_replace("&#x27;", "'", $str);
return $str;
}
@@ -59,39 +67,92 @@ function clean_str($str) {
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<html>
<head>
<title>FrogFind!</title>
<title>FrogFind!</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>
</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) ?>">
<input type="submit" value="Ribbbit!">
</form>
<hr>
<br>
<center>Search Results for <b><?php echo strip_tags(urldecode($query)) ?></b></center>
<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>
<br><br>
<center>
<form action="/" method="get">
Leap to: <input type="text" size="30" name="q"><br>
<input type="submit" value="Ribbbit!">
</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>
</form>
</form>
<?php if ($show_results) { // there's a search query in q, so show search results
?>
<?php } ?>
<form action="/" method="get" class="search-form">
<a href="/">
<font size=6 color="#008000">Frog</font>
<font size=6 color="#000000">Find!</font>
</a>
<div style="margin: 8px 0;">Leap again: <br>
<input type="text" size="30" name="q" value="<?php echo urldecode($query) ?>">
</div>
<input type="submit" value="Ribbbit!">
</form>
<hr>
<br>
<center>Search Results for <b><?php echo strip_tags(urldecode($query)) ?></b></center>
<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>
<br><br>
<center>
<form action="/" method="get">
Leap to: <br>
<input type="text" size="30" name="q"><br>
<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>
</form>
</form>
<?php } ?>
</body>
</html>

104
read.php
View File

@@ -17,15 +17,15 @@ $compatible_content_types = [
// a direct link to the file.
$proxy_download_max_filesize = 8000000; // ~ 8Mb
if( isset( $_GET['a'] ) ) {
if (isset($_GET['a'])) {
$article_url = $_GET["a"];
} else {
echo "What do you think you're doing... >:(";
exit();
}
if (substr( $article_url, 0, 4 ) != "http") {
echo("That's not a web page :(");
if (substr($article_url, 0, 4) != "http") {
echo ("That's not a web page :(");
die();
}
@@ -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,12 +48,11 @@ 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)) {
$contentType = $contentType[count($contentType)-1];
$contentType = $contentType[count($contentType) - 1];
}
$filename = basename($url['path']);
@@ -63,12 +61,12 @@ else {
if (!$filename) {
$filename = "download";
}
// Set the content headers based on the file we're proxying through.
header('Content-Type: ' . $contentType);
header('Content-Length: ' . $filesize);
// Set the content-disposition to encourage the browser to download the file.
header('Content-Disposition: attachment; filename="'. $filename . '"');
header('Content-Disposition: attachment; filename="' . $filename . '"');
// Use readfile
readfile($article_url);
@@ -89,50 +87,73 @@ $configuration
$readability = new Readability($configuration);
if(!$article_html = file_get_contents($article_url)) {
if (!$article_html = file_get_contents($article_url)) {
$error_text .= "Failed to get the article :( <br>";
}
try {
$readability->parse($article_html);
$readable_article = strip_tags($readability->getContent(), '<a><ol><ul><li><br><p><small><font><b><strong><i><em><blockquote><h1><h2><h3><h4><h5><h6>');
$readable_article = str_replace( 'strong>', 'b>', $readable_article ); //change <strong> to <b>
$readable_article = str_replace( 'em>', 'i>', $readable_article ); //change <em> to <i>
$readable_article = str_replace('strong>', 'b>', $readable_article); //change <strong> to <b>
$readable_article = str_replace('em>', 'i>', $readable_article); //change <em> to <i>
$readable_article = clean_str($readable_article);
$readable_article = str_replace( 'href="http', 'href="/read.php?a=http', $readable_article ); //route links through proxy
$readable_article = str_replace('href="http', 'href="/read.php?a=http', $readable_article); //route links through proxy
} catch (ParseException $e) {
$error_text .= 'Sorry! ' . $e->getMessage() . '<br>';
}
//replace chars that old machines probably can't handle
function clean_str($str) {
$str = str_replace( "", "'", $str );
$str = str_replace( "", "'", $str );
$str = str_replace( "", '"', $str );
$str = str_replace( "", '"', $str );
$str = str_replace( "", '-', $str );
function clean_str($str)
{
$str = str_replace("", "'", $str);
$str = str_replace("", "'", $str);
$str = str_replace("", '"', $str);
$str = str_replace("", '"', $str);
$str = str_replace("", '-', $str);
return $str;
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 2.0//EN">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<html>
<head>
<title><?php echo $readability->getTitle();?></title>
</head>
<body>
<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 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 ?>">
<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 ?>">
<input type="submit" value="Go!">
</form>
</form>
</p>
<hr>
<h1><?php echo clean_str($readability->getTitle());?></h1>
<h1><?php echo clean_str($readability->getTitle()); ?></h1>
<p> <?php
$img_num = 0;
$imgline_html = "View page images:";
@@ -143,11 +164,16 @@ function clean_str($str) {
$imgline_html .= " <a href='image.php?i=" . $image_url . "'>[$img_num]</a> ";
}
endforeach;
if($img_num>0) {
echo $imgline_html ;
if ($img_num > 0) {
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>
</body>
</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>
</body>
</html>