[1mdiff --git a/INSTALL.md b/INSTALL.md[m
[1mnew file mode 100644[m
[1mindex 0000000..8872eba[m
[1m--- /dev/null[m
[1m+++ b/INSTALL.md[m
[36m@@ -0,0 +1,56 @@[m
[32m+[m[32m# Installation[m
[32m+[m
[32m+[m[32m## Install ImageMagick[m
[32m+[m
[32m+[m[32mMake sure ImageMagick is installed.[m
[32m+[m
[32m+[m[32mHowever this works on whatever distribution of whatever operating system you use.[m
[32m+[m
[32m+[m[32mIf you do not have access to the command convert
then this will not work.[m
[32m+[m
[32m+[m[32m## Add a webserver[m
[32m+[m
[32m+[m[32mCopy brutalproxy to a directory and create a webserver to point to that directory.[m
[32m+[m
[32m+[m[32mMake sure brutalproxy is owned by the same user as the webserver. If you use Nginx on a Debian-like linux, this is probaby www-data. If you need a server block because you don't understand how Nginx works, it should look something like this:[m
[32m+[m
[32m+[m[32m```[m
[32m+[m[32mserver {[m
[32m+[m[32m listen 80;[m
[32m+[m[32m server_name proxy.brutal.url;[m
[32m+[m
[32m+[m[32m root /var/www/brutalproxy;[m
[32m+[m[32m index index.php;[m
[32m+[m
[32m+[m[32m location ~ .php$ {[m
[32m+[m[32m try_files $uri =404;[m
[32m+[m[32m fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;[m
[32m+[m[32m fastcgi_index index.php;[m
[32m+[m[32m fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;[m
[32m+[m[32m include fastcgi_params;[m
[32m+[m[32m }[m
[32m+[m[32m}[m
[32m+[m[32m```[m
[32m+[m
[32m+[m[32mYou might want to add some kind of password control too so people don't casually hijack this to download bad things.[m
[32m+[m
[32m+[m[32m## Add a cron job[m
[32m+[m
[32m+[m[32mEdit cleanup.sh to point to where you installed brutalproxy.[m
[32m+[m
[32m+[m[32mCreate a cron job to run cleanup.sh once a day. This will sweep out any old files from the cache so you don't burn up your disk space.[m
[32m+[m
[32m+[m[32m```[m
[32m+[m[32m0 12 * * * root /var/www/brutalproxy/cleanup.sh[m
[32m+[m[32m```[m
[32m+[m
[32m+[m[32m## Patch Brutaldon[m
[32m+[m
[32m+[m[32mOpen brutaldon.patch with your favorite text editor and replace "http://proxy.brutal.url" with the actual URL where you are running brutalproxy.[m
[32m+[m
[32m+[m[32mSave.[m
[32m+[m
[32m+[m[32mApply the patch to your Brutaldon installation.[m
[32m+[m
[32m+[m[32mRestart Brutaldon.[m
[32m+[m
[1mdiff --git a/LICENSE b/LICENSE[m
[1mnew file mode 100644[m
[1mindex 0000000..d168027[m
[1m--- /dev/null[m
[1m+++ b/LICENSE[m
[36m@@ -0,0 +1,7 @@[m
[32m+[m[32mThis work is released to the Public Domain.[m
[32m+[m
[32m+[m[32mThe author, Anonymous, has dedicated the work to the public domain by waiving all copyright and related or neighboring rights to this work worldwide under copyright law including all related and neighboring rights.[m
[32m+[m
[32m+[m[32mEven beyond the extent allowed by law: if your law does not allow a creator to give his work to the public domain then your law is fake and gay and retarded.[m
[32m+[m
[32m+[m[32mYou can copy, modify, distribute and create derivative work, even for commercial purposes, all without asking permission.[m
[1mdiff --git a/README.md b/README.md[m
[1mnew file mode 100644[m
[1mindex 0000000..621f4b0[m
[1m--- /dev/null[m
[1m+++ b/README.md[m
[36m@@ -0,0 +1,21 @@[m
[32m+[m[32m# brutalproxy[m
[32m+[m
[32m+[m[32m## Why make this?[m
[32m+[m
[32m+[m[32mGoogle and browser developers broke the World Wide Web.[m
[32m+[m
[32m+[m[32mThe cancer of SSL everywhere, enforced by browsers redirecting to HTTPS and Google downranking pages that don't use HTTPS.[m
[32m+[m
[32m+[m[32mThis affects almost every server in 2024, and the Fediverse is not immune.[m
[32m+[m
[32m+[m[32mBrutaldon gets halfway to a solution since you can run it on port 80 and let your server negotiate communication with all the HTTPS-only Fediverse servers. Unfortunately, images still won't load.[m
[32m+[m
[32m+[m[32mEven if you can get an image pulled down to your computer, there is a good chance of it being Googleshit WEBP that isn't supported.[m
[32m+[m
[32m+[m[32m## How does it work?[m
[32m+[m
[32m+[m[32mThis is a dead simple caching proxy that downloads images over HTTPS, processes it with ImageMagick to remove malicious payloads and reduce the size, and sends it over port 80 to your legacy browser.[m
[32m+[m
[32m+[m[32mIt includes a simple template patch for Brutaldon to alter its image links so that they go yo your proxy instead of the actual server.[m
[32m+[m
[32m+[m[32mImages are downloaded and stored using an sha1 hash of the full URL.[m
[1mdiff --git a/brutaldon.patch b/brutaldon.patch[m
[1mnew file mode 100644[m
[1mindex 0000000..b9eb0ce[m
[1m--- /dev/null[m
[1m+++ b/brutaldon.patch[m
[36m@@ -0,0 +1,191 @@[m
[32m+[m[32mdiff --color -Naur brutaldon/brutaldon/templates/accounts/account_partial.html ../brutaldon/brutaldon/templates/accounts/account_partial.html[m
[32m+[m[32m--- brutaldon/brutaldon/templates/accounts/account_partial.html 2025-01-12 07:16:02.990452094 -0500[m
[32m+[m[32m+++ ../brutaldon/brutaldon/templates/accounts/account_partial.html 2025-01-11 12:26:07.630934344 -0500[m
[32m+[m[32m@@ -1,7 +1,7 @@[m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m- <img src="{{ account.user.avatar_static }}"[m
[32m+[m[32m+ <img src="http://proxy.brutal.url/preview.php?{{ account.user.avatar_static }}"[m
[32m+[m[32m alt="{{ account.user.acct }}"[m
[32m+[m[32m height="64" width="64">[m
[32m+[m[32m [m
[32m+[m[32mdiff --color -Naur brutaldon/brutaldon/templates/base.html ../brutaldon/brutaldon/templates/base.html[m
[32m+[m[32m--- brutaldon/brutaldon/templates/base.html 2025-01-12 07:16:02.990452094 -0500[m
[32m+[m[32m+++ ../brutaldon/brutaldon/templates/base.html 2025-01-11 12:25:55.401743609 -0500[m
[32m+[m[32m@@ -82,7 +82,7 @@[m
[32m+[m[32m [m
[32m+[m[32m <a class="navbar-item" href="{% url "home" %}">[m
[32m+[m[32m {% if own_acct %}[m
[32m+[m[32m- <img src="{{ own_acct.avatar_static }}"[m
[32m+[m[32m+ <img src="http://proxy.brutal.url/preview.php?{{ own_acct.avatar_static }}"[m
[32m+[m[32m class="image is-32x32 avatar"[m
[32m+[m[32m height="32" width="32"[m
[32m+[m[32m alt="Brutaldon ('{{ own_acct.username }}')">[m
[32m+[m[32mdiff --color -Naur brutaldon/brutaldon/templates/main/block.html ../brutaldon/brutaldon/templates/main/block.html[m
[32m+[m[32m--- brutaldon/brutaldon/templates/main/block.html 2025-01-12 07:16:02.990452094 -0500[m
[32m+[m[32m+++ ../brutaldon/brutaldon/templates/main/block.html 2025-01-11 12:28:06.934550057 -0500[m
[32m+[m[32m@@ -15,7 +15,7 @@[m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m <a href="{% url "user" user.acct %}">[m
[32m+[m[32m- <img src="{{ user.avatar }}"[m
[32m+[m[32m+ <img src="http://proxy.brutal.url/preview.php?{{ user.avatar }}"[m
[32m+[m[32m height="64" width="64"[m
[32m+[m[32m alt="">[m
[32m+[m[32m [m
[32m+[m[32mdiff --color -Naur brutaldon/brutaldon/templates/main/follow.html ../brutaldon/brutaldon/templates/main/follow.html[m
[32m+[m[32m--- brutaldon/brutaldon/templates/main/follow.html 2025-01-12 07:16:02.990452094 -0500[m
[32m+[m[32m+++ ../brutaldon/brutaldon/templates/main/follow.html 2025-01-11 12:27:09.973004273 -0500[m
[32m+[m[32m@@ -17,7 +17,7 @@[m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m <a href="{% url "user" user.acct %}">[m
[32m+[m[32m- <img src="{{ user.avatar }}"[m
[32m+[m[32m+ <img src="http://proxy.brutal.url/preview.php?{{ user.avatar }}"[m
[32m+[m[32m height="64" width="64"[m
[32m+[m[32m alt="">[m
[32m+[m[32m [m
[32m+[m[32mdiff --color -Naur brutaldon/brutaldon/templates/main/mute.html ../brutaldon/brutaldon/templates/main/mute.html[m
[32m+[m[32m--- brutaldon/brutaldon/templates/main/mute.html 2025-01-12 07:16:02.990452094 -0500[m
[32m+[m[32m+++ ../brutaldon/brutaldon/templates/main/mute.html 2025-01-11 12:28:15.475381572 -0500[m
[32m+[m[32m@@ -15,7 +15,7 @@[m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m <a href="{% url "user" user.acct %}">[m
[32m+[m[32m- <img src="{{ user.avatar }}"[m
[32m+[m[32m+ <img src="http://proxy.brutal.url/preview.php?{{ user.avatar }}"[m
[32m+[m[32m height="64" width="64"[m
[32m+[m[32m alt="">[m
[32m+[m[32m [m
[32m+[m[32mdiff --color -Naur brutaldon/brutaldon/templates/main/notifications.html ../brutaldon/brutaldon/templates/main/notifications.html[m
[32m+[m[32m--- brutaldon/brutaldon/templates/main/notifications.html 2025-01-12 07:16:02.990452094 -0500[m
[32m+[m[32m+++ ../brutaldon/brutaldon/templates/main/notifications.html 2025-01-11 12:29:14.797156861 -0500[m
[32m+[m[32m@@ -83,7 +83,7 @@[m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m- <img src="{{ note.account.avatar_static }}" alt=""[m
[32m+[m[32m+ <img src="http://proxy.brutal.url/preview.php?{{ note.account.avatar_static }}" alt=""[m
[32m+[m[32m height="64" width="64">[m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32mdiff --color -Naur brutaldon/brutaldon/templates/main/post_minimal_partial.html ../brutaldon/brutaldon/templates/main/post_minimal_partial.html[m
[32m+[m[32m--- brutaldon/brutaldon/templates/main/post_minimal_partial.html 2025-01-12 07:16:02.990452094 -0500[m
[32m+[m[32m+++ ../brutaldon/brutaldon/templates/main/post_minimal_partial.html 2025-01-11 12:29:51.368717186 -0500[m
[32m+[m[32m@@ -30,7 +30,7 @@[m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m <a href="{% url "user" own_acct.acct %}" class="image avatar is-48x48 level-item">[m
[32m+[m[32m- <img src="{{ own_acct.avatar_static }}" alt="[{{ own_acct.acct }}]"[m
[32m+[m[32m+ <img src="http://proxy.brutal.url/preview.php?{{ own_acct.avatar_static }}" alt="[{{ own_acct.acct }}]"[m
[32m+[m[32m height="48" width="48">[m
[32m+[m[32m [m
[32m+[m[32m <input type="submit" class="button is-primary level-item"[m
[32m+[m[32mdiff --color -Naur brutaldon/brutaldon/templates/main/post_partial.html ../brutaldon/brutaldon/templates/main/post_partial.html[m
[32m+[m[32m--- brutaldon/brutaldon/templates/main/post_partial.html 2025-01-12 07:16:02.990452094 -0500[m
[32m+[m[32m+++ ../brutaldon/brutaldon/templates/main/post_partial.html 2025-01-11 12:27:43.748292669 -0500[m
[32m+[m[32m@@ -125,7 +125,7 @@[m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m <a href="{% url "user" own_acct.acct %}" class="image avatar is-48x48 level-item" >[m
[32m+[m[32m- <img src="{{ own_acct.avatar_static }}" alt="[{{ own_acct.acct }}]"[m
[32m+[m[32m+ <img src="http://proxy.brutal.url/preview.php?{{ own_acct.avatar_static }}" alt="[{{ own_acct.acct }}]"[m
[32m+[m[32m height="48" width="48">[m
[32m+[m[32m [m
[32m+[m[32m <input type="submit" class="button is-primary level-item"[m
[32m+[m[32mdiff --color -Naur brutaldon/brutaldon/templates/main/search_results.html ../brutaldon/brutaldon/templates/main/search_results.html[m
[32m+[m[32m--- brutaldon/brutaldon/templates/main/search_results.html 2025-01-12 07:16:02.990452094 -0500[m
[32m+[m[32m+++ ../brutaldon/brutaldon/templates/main/search_results.html 2025-01-11 12:26:56.487691304 -0500[m
[32m+[m[32m@@ -45,7 +45,7 @@[m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m <a href="{% url "user" user.acct %}">[m
[32m+[m[32m- <img src="{{ user.avatar }}"[m
[32m+[m[32m+ <img src="http://proxy.brutal.url/preview.php?{{ user.avatar }}"[m
[32m+[m[32m alt=""[m
[32m+[m[32m height="64" width="64">[m
[32m+[m[32m [m
[32m+[m[32mdiff --color -Naur brutaldon/brutaldon/templates/main/toot_partial.html ../brutaldon/brutaldon/templates/main/toot_partial.html[m
[32m+[m[32m--- brutaldon/brutaldon/templates/main/toot_partial.html 2025-01-12 07:16:02.990452094 -0500[m
[32m+[m[32m+++ ../brutaldon/brutaldon/templates/main/toot_partial.html 2025-01-11 08:02:04.158784744 -0500[m
[32m+[m[32m@@ -14,7 +14,7 @@[m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m <a href="{% url "user" toot.account.acct %}">[m
[32m+[m[32m- <img loading="auto" src="{{ toot.account.avatar_static }}"[m
[32m+[m[32m+ <img loading="auto" src="http://proxy.brutal.url/preview.php?{{ toot.account.avatar_static }}"[m
[32m+[m[32m height="64" width="64" float="left"[m
[32m+[m[32m alt="">[m
[32m+[m[32m [m
[32m+[m[32m@@ -22,7 +22,7 @@[m
[32m+[m[32m {% if reblog %}[m
[32m+[m[32m [m
[32m+[m[32m <a href="{% url "user" reblog_by %}">[m
[32m+[m[32m- <img loading="auto" src ="{{ reblog_icon }}" alt=""[m
[32m+[m[32m+ <img loading="auto" src ="http://proxy.brutal.url/preview.php?{{ reblog_icon }}" alt=""[m
[32m+[m[32m height="32" width="32">[m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m@@ -74,7 +74,7 @@[m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m <img loading="lazy" alt="{{ toot.card.title }}"[m
[32m+[m[32m- src="{{ toot.card.image }}"[m
[32m+[m[32m+ src="http://proxy.brutal.url/preview.php?{{ toot.card.image }}"[m
[32m+[m[32m class="is-max-128" width="128" height="128">[m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m@@ -99,11 +99,11 @@[m
[32m+[m[32m {% for media in toot.media_attachments %}[m
[32m+[m[32m {% if media.type == "image" %}[m
[32m+[m[32m [m
[32m+[m[32m- [m
[32m+[m[32m+ [m
[32m+[m[32m {% if toot.sensitive and not preferences.preview_sensitive %}[m
[32m+[m[32m <img loading="lazy" src="{% static "images/sensitive.png" %}"[m
[32m+[m[32m {% else %}[m
[32m+[m[32m- <img loading="lazy" src="{{ media.preview_url }}"[m
[32m+[m[32m+ <img loading="lazy" src="http://proxy.brutal.url/preview.php?{{ media.preview_url }}"[m
[32m+[m[32m {% endif %}[m
[32m+[m[32m alt="{% if media.description %}[m
[32m+[m[32m {{ media.description }}[m
[32m+[m[32m@@ -124,11 +124,11 @@[m
[32m+[m[32m width="256" height="256"[m
[32m+[m[32m poster="{{ media.preview_url }}">[m
[32m+[m[32m [m
[32m+[m[32m- [m
[32m+[m[32m+ [m
[32m+[m[32m {% if toot.sensitive and not preferences.preview_sensitive %}[m
[32m+[m[32m <img loading="lazy" src="{% static "images/sensitive.png" %}"[m
[32m+[m[32m {% else %}[m
[32m+[m[32m- <img loading="lazy" src="{{ media.preview_url }}"[m
[32m+[m[32m+ <img loading="lazy" src="http://proxy.brutal.url/preview.php?{{ media.preview_url }}"[m
[32m+[m[32m {% endif %}[m
[32m+[m[32m alt="{% if media.description %}[m
[32m+[m[32m {{ media.description }}[m
[32m+[m[32mdiff --color -Naur brutaldon/brutaldon/templates/main/user.html ../brutaldon/brutaldon/templates/main/user.html[m
[32m+[m[32m--- brutaldon/brutaldon/templates/main/user.html 2025-01-12 07:16:02.990452094 -0500[m
[32m+[m[32m+++ ../brutaldon/brutaldon/templates/main/user.html 2025-01-11 12:28:59.891705759 -0500[m
[32m+[m[32m@@ -21,7 +21,7 @@[m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m- <img src="{{ user.avatar }}" alt="Avatar"[m
[32m+[m[32m+ <img src="http://proxy.brutal.url/preview.php?{{ user.avatar }}" alt="Avatar"[m
[32m+[m[32m height="96" width="96">[m
[32m+[m[32m {% if user.locked %}[m
[32m+[m[32m [m
[32m+[m[32mdiff --color -Naur brutaldon/brutaldon/templates/requests/request_partial.html ../brutaldon/brutaldon/templates/requests/request_partial.html[m
[32m+[m[32m--- brutaldon/brutaldon/templates/requests/request_partial.html 2025-01-12 07:16:02.990452094 -0500[m
[32m+[m[32m+++ ../brutaldon/brutaldon/templates/requests/request_partial.html 2025-01-11 12:26:31.045214110 -0500[m
[32m+[m[32m@@ -1,7 +1,7 @@[m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m [m
[32m+[m[32m- <img src="{{ request.avatar_static }}"[m
[32m+[m[32m+ <img src="http://proxy.brutal.url/preview.php?{{ request.avatar_static }}"[m
[32m+[m[32m alt="{{ request.acct }}"[m
[32m+[m[32m height="64" width="64">[m
[32m+[m[32m [m
[32m+[m
[1mdiff --git a/cache.php b/cache.php[m
[1mnew file mode 100644[m
[1mindex 0000000..cd1dd35[m
[1m--- /dev/null[m
[1m+++ b/cache.php[m
[36m@@ -0,0 +1,18 @@[m
[32m+[m[32m<?php[m
[32m+[m
[32m+[m[32minclude("init.php");[m
[32m+[m
[32m+[m[32m// Get file if not cached yet[m
[32m+[m[32mif(!file_exists("$dir/cache/$hash.$ext"))[m
[32m+[m[32m include("fetch.php");[m
[32m+[m
[32m+[m[32m// Replace webp with jpeg[m
[32m+[m[32mif($ext == "webp")[m
[32m+[m[32m $ext = "jpg";[m
[32m+[m
[32m+[m[32m// Write HTTP headers and cache file[m
[32m+[m[32mwrite_octet("$dir/cache/$hash.$ext", $ext, $expire);[m
[32m+[m
[32m+[m[32mexit;[m
[32m+[m
[32m+[m[32m?>[m
[1mdiff --git a/cache/.empty b/cache/.empty[m
[1mnew file mode 100644[m
[1mindex 0000000..e69de29[m
[1mdiff --git a/cleanup.sh b/cleanup.sh[m
[1mnew file mode 100755[m
[1mindex 0000000..856c7de[m
[1m--- /dev/null[m
[1m+++ b/cleanup.sh[m
[36m@@ -0,0 +1,3 @@[m
[32m+[m[32m#!/bin/sh[m
[32m+[m[32mfind /var/www/brutalproxy/cache -mtime +3 -type f -delete[m
[32m+[m[32mfind /var/www/brutalproxy/preview -mtime +3 -type f -delete[m
[1mdiff --git a/fetch.php b/fetch.php[m
[1mnew file mode 100644[m
[1mindex 0000000..7d2ed88[m
[1m--- /dev/null[m
[1m+++ b/fetch.php[m
[36m@@ -0,0 +1,34 @@[m
[32m+[m[32m<?php[m
[32m+[m
[32m+[m[32m// Fetch file if not exists in cache[m
[32m+[m[32mif(!file_exists("$dir/proxy/$hash.$ext")) {[m
[32m+[m
[32m+[m[32m ini_set('default_socket_timeout', $timeout);[m
[32m+[m[32m file_put_contents("$dir/temp/$hash.$ext", file_get_contents($img));[m
[32m+[m
[32m+[m[32m //[m
[32m+[m[32m // Parse all files through ImageMagick to remove potential malware payloads[m
[32m+[m[32m //[m
[32m+[m
[32m+[m[32m // JPEG files[m
[32m+[m[32m if($ext == "jpg" || $ext == "jpeg") {[m
[32m+[m[32m exec("convert -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG $dir/temp/$hash.$ext $dir/cache/$hash.$ext");[m
[32m+[m[32m exec("convert -resize 500x500> -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG $dir/temp/$hash.$ext $dir/preview/$hash.$ext");[m
[32m+[m[32m }[m
[32m+[m[32m // Convert WEBM to JPEG[m
[32m+[m[32m else if($ext == "webp") {[m
[32m+[m[32m exec("convert -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG $dir/temp/$hash.$ext $dir/cache/$hash.jpg");[m
[32m+[m[32m exec("convert -resize 500x500> -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG $dir/temp/$hash.$ext $dir/preview/$hash.jpg");[m
[32m+[m[32m }[m
[32m+[m[32m // PNG and GIF[m
[32m+[m[32m else {[m
[32m+[m[32m exec("convert -sampling-factor 4:2:0 -strip $dir/temp/$hash.$ext $dir/cache/$hash.$ext");[m
[32m+[m[32m exec("convert -resize 500x500> -sampling-factor 4:2:0 -strip $dir/temp/$hash.$ext $dir/preview/$hash.$ext");[m
[32m+[m[32m }[m
[32m+[m
[32m+[m[32m // Remove temp file[m
[32m+[m[32m unlink("$dir/temp/$hash.$ext");[m
[32m+[m
[32m+[m[32m}[m
[32m+[m
[32m+[m[32m?>[m
[1mdiff --git a/index.php b/index.php[m
[1mnew file mode 100644[m
[1mindex 0000000..7e1282a[m
[1m--- /dev/null[m
[1m+++ b/index.php[m
[36m@@ -0,0 +1,15 @@[m
[32m+[m[32m[m
[32m+[m
[32m+[m[32m [m
[32m+[m[32m You are lost[m
[32m+[m[32m [m
[32m+[m
[32m+[m[32m [m
[32m+[m[32m You are lost[m
[32m+[m[32m This is a proxy used to fetch images from the Fediverse for display in the Brutaldon client.[m
[32m+[m[32m You should never end up at this URL. What are you doing?[m
[32m+[m[32m Since you are here, I'll tell you there are currently files in the cache and they occupy of disk space.[m
[32m+[m[32m Now go away.[m
[32m+[m[32m [m
[32m+[m
[32m+[m[32m[m
[1mdiff --git a/init.php b/init.php[m
[1mnew file mode 100644[m
[1mindex 0000000..9aa137e[m
[1m--- /dev/null[m
[1m+++ b/init.php[m
[36m@@ -0,0 +1,34 @@[m
[32m+[m[32m<?php[m
[32m+[m
[32m+[m[32m// Set installation dir[m
[32m+[m[32m$dir = "/var/www/brutalproxy";[m
[32m+[m
[32m+[m[32m// Set browser expiration[m
[32m+[m[32m$expire = 14 * 606024;[m
[32m+[m
[32m+[m[32m// Set timeout for file requests[m
[32m+[m[32m$timeout = 10;[m
[32m+[m
[32m+[m[32m// Create useful variables[m
[32m+[m[32m$img = $_SERVER['QUERY_STRING'];[m
[32m+[m[32m$ext = substr(strrchr($img, "."), 1);[m
[32m+[m[32m$hash = sha1($img);[m
[32m+[m
[32m+[m[32m// Give up and die if it is not a supported extension[m
[32m+[m[32m$types = array("jpg", "jpeg", "png", "gif", "webp");[m
[32m+[m[32mif(!in_array($ext, $types)) {[m
[32m+[m[32m exit();[m
[32m+[m[32m}[m
[32m+[m
[32m+[m[32m// Write file to output with HTTP headers[m
[32m+[m[32mfunction write_octet($file, $type, $expire) {[m
[32m+[m[32m $bytes = file_get_contents($file);[m
[32m+[m[32m header("Content-Type: image/$type");[m
[32m+[m[32m header("Content-Length: " . strlen($bytes));[m
[32m+[m[32m header("Cache-Control: public", true);[m
[32m+[m[32m header("Pragma: public", true);[m
[32m+[m[32m header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $expire) . ' GMT', true);[m
[32m+[m[32m echo $bytes;[m
[32m+[m[32m}[m
[32m+[m
[32m+[m[32m?>[m
[1mdiff --git a/preview.php b/preview.php[m
[1mnew file mode 100644[m
[1mindex 0000000..cbfbfc7[m
[1m--- /dev/null[m
[1m+++ b/preview.php[m
[36m@@ -0,0 +1,18 @@[m
[32m+[m[32m<?php[m
[32m+[m
[32m+[m[32minclude("init.php");[m
[32m+[m
[32m+[m[32m// Get file if not cached yet[m
[32m+[m[32mif(!file_exists("$dir/cache/$hash.$ext"))[m
[32m+[m[32m include("fetch.php");[m
[32m+[m
[32m+[m[32m// Replace webp with jpeg[m
[32m+[m[32mif($ext == "webp")[m
[32m+[m[32m $ext = "jpg";[m
[32m+[m
[32m+[m[32m// Write HTTP headers and preview file[m
[32m+[m[32mwrite_octet("$dir/preview/$hash.$ext", $ext, $expire);[m
[32m+[m
[32m+[m[32mexit;[m
[32m+[m
[32m+[m[32m?>[m
[1mdiff --git a/preview/.empty b/preview/.empty[m
[1mnew file mode 100644[m
[1mindex 0000000..e69de29[m
[1mdiff --git a/temp/.empty b/temp/.empty[m
[1mnew file mode 100644[m
[1mindex 0000000..e69de29[m
text/plain
This content has been proxied by September (ba2dc).