Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Community Cafe (http://www.bvlist.com/forumdisplay.php?f=18)
-   -   Image Proxy (http://www.bvlist.com/showthread.php?t=11475)

darkalchemy 10th February 2018 15:12

Image Proxy
 
Simple-Image-Proxyhttps://travis-ci.org/darkalchemy/Si...?branch=master
The purpose of this image proxy is to reduce the exposure of the requesting sites url, when hot-linking images, by using the image proxy to make the http request, store the image and return the image from the image proxy in an http response.

This could also be used to serve images that are using http links on your https site. Thereby not opening up a security hole.

This image proxy will store an optimized for web version of the original image and can return that image in any dimensions that are included with the http request.

How To:
get the code
Code:

git clone https://github.com/darkalchemy/Simple-Image-Proxy.git image-proxy
set ownership
Code:

chown -R www-data:www-data image-proxy
install dependancies
Code:

cd image-proxy
composer install

set webroot to path image-proxy/public
edit settings.php
Code:

replace the uid and key with values given to the requsting site. These values must match.
Usage by the requsting site
add class with composer
Code:

composer require blocktrail/cryptojs-aes-php
use class in site
Code:

use Blocktrail\CryptoJSAES\CryptoJSAES;
to return image without modification
Code:

$encrypted = CryptoJSAES::encrypt($url, $key);
return 'http://image_proxy_url/image?' . base64_encode($encrypted . '&uid=' . uid);

to return image and resize the image
Code:

$encrypted = CryptoJSAES::encrypt("$url&width={$width}&height={$height}", $key);
return 'http://image_proxy_url/image?' . base64_encode($encrypted . '&uid=' . uid);

This image proxy is in use with Pu-239, if you care to see it, but can be used with any site that makes a proper request.

How to add to your site.

The code is licensed MIT and is available on github.
https://github.com/darkalchemy/Simple-Image-Proxy

Tedmorris 17th December 2018 03:27

Whats Pu-239? Ive searched the forums and cant find it i wanted to see the image proxy in action.

darkalchemy 17th December 2018 04:02

Quote:

Originally Posted by Tedmorris (Post 53003)
Whats Pu-239? Ive searched the forums and cant find it i wanted to see the image proxy in action.

Really, you searched for it?

https://www.bvlist.com/forumdisplay.php?f=128
https://pu-239.pw
https://github.com/darkalchemy/Pu-239


But, I removed the code for Image Proxy from GitHub because I could not make the images cache in the browser. So, I rolled the code into Pu-239. Now, the Image Proxy simply fetches the external image, manipulates it as desired, stores it and then displays it as an internal image.

And.... every externally linked image displayed in my code is run through the Image Proxy, which can be disabled if desired.

Tedmorris 17th December 2018 06:31

Thx m8, maybe i used the wrong search word. I tried Pu-239 with no results.

darkalchemy 17th December 2018 06:39

No worries, just giving you a hard time.

Tedmorris 17th December 2018 11:29

All good m8, that many ppl post without looking that it kinda goes unsaid and if you found it by doing a search then im doing something wrong and should be pulled up on it lol

Ive checked out the source and see where it refrences the images to the proxy but im confused about the whole setup and im undecided about what to do.

darkalchemy 17th December 2018 14:49

Sorry, but you can't just pull it out of my code to use it in another. But, you can look at the function url_proxy() and the ImageProxy class.

Those 2 are responsible for handling the image proxy.


All times are GMT +2. The time now is 22:41.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.