From fc945b6f9afbf2e9ed84cad1cb3c2f72a18ccecb Mon Sep 17 00:00:00 2001 From: Frank Tackitt Date: Thu, 1 Feb 2018 08:39:56 -0800 Subject: [PATCH] imgur.kageurufu.net migration --- .gitattributes | 22 ------ .gitignore | 1 + .htaccess | 5 ++ index.php | 186 +++++++++++++++++++++++++++++++++++++++++-------- 4 files changed, 162 insertions(+), 52 deletions(-) delete mode 100644 .gitattributes create mode 100644 .htaccess diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 412eeda..0000000 --- a/.gitattributes +++ /dev/null @@ -1,22 +0,0 @@ -# Auto detect text files and perform LF normalization -* text=auto - -# Custom for Visual Studio -*.cs diff=csharp -*.sln merge=union -*.csproj merge=union -*.vbproj merge=union -*.fsproj merge=union -*.dbproj merge=union - -# Standard to msysgit -*.doc diff=astextplain -*.DOC diff=astextplain -*.docx diff=astextplain -*.DOCX diff=astextplain -*.dot diff=astextplain -*.DOT diff=astextplain -*.pdf diff=astextplain -*.PDF diff=astextplain -*.rtf diff=astextplain -*.RTF diff=astextplain diff --git a/.gitignore b/.gitignore index 5ebd21a..3b43a30 100644 --- a/.gitignore +++ b/.gitignore @@ -161,3 +161,4 @@ pip-log.txt # Mac crap .DS_Store +cache diff --git a/.htaccess b/.htaccess new file mode 100644 index 0000000..2e0ac51 --- /dev/null +++ b/.htaccess @@ -0,0 +1,5 @@ +RewriteEngine On + +RewriteRule ^(a|gallery)/([a-zA-Z0-9]{5,})$ /?$1/$2 +RewriteRule ^([a-zA-Z0-9]{5,32})$ /?$1 +RewriteRule ^([a-zA-Z0-9]{5,})\.(png|jpe?g|gifv?|webm|mp4)$ /?$1.$2 diff --git a/index.php b/index.php index 67d170c..f713c98 100644 --- a/index.php +++ b/index.php @@ -1,34 +1,160 @@ array('timeout'=>15))); - //Prevent long running timed out downloads, but long enough to get large files -$image = @file_get_contents('http://i.imgur.com/'.$imgur,0,$con); - //download the image into a variable -if(!$image) die('Cannot retrieve imgur file'); - //If the download failed, exit -file_put_contents($fname, $image); - //Save the image to cache -header('Content-type: image'); - //Set the header so browsers will display it -echo $image; - //print the image + +if (!$_SERVER['QUERY_STRING']) { +?> + + +
+

Imgur Proxy

+ +

BETA MODE

+ +
+
Image
+
/imagehash
+
Gallery
+
/a/albumhash
+
/gallery/albumhash
+
GIFV
+
/hash.gifv
+
+
+ + + +album_images->images; +?> + + + + + + + + + description?> + + + + + + + + + + +

+ If the gifv isn't playing here, try the direct + mp4, + webm, or + gif links +

+ +buffer($image)); + header('Cache-Control: public, max-age=31556926'); + die($image); +} ?>