+ URL_PREFIX proxy

This commit is contained in:
Miroslav Šedivý 2020-02-21 17:57:26 +01:00
parent f8ed38f556
commit 9fbb2f0869
3 changed files with 21 additions and 7 deletions

View file

@ -134,7 +134,7 @@ To check if your server is set up correctly, turn on a debug mode (in config add
* Make posts available for **everyone**, **only you** or just for **friends**.
* Extra fields in post: **Feeling**, **With** and **At**.
* Hide posts from timeline so they are visible only when you need them to be.
* All pasted links will get preview with page title, description and image.
* All pasted links will get preview with page title, description and image (can be configured proxy).
* Upload images using button *(for mobile)*.
* Upload images using drag & drop *(drop it into textarea)*.
* Upload images using CTRL + V *(paste it into textarea)*.

View file

@ -244,25 +244,33 @@ class Post
}
preg_match('/^https?:\/\/(www\.)?([^:\/\s]+)(.*)?$/i', $l, $url);
$curl_request_url = $l;
// Get content
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $l);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (compatible; Proxycat/1.1)");
curl_setopt($ch, CURLOPT_REFERER, '');
// Proxy settings
if($proxy = Config::get_safe("proxy", false)){
curl_setopt($ch, CURLOPT_PROXY, $proxy);
$proxytype = Config::get_safe("proxytype", false);
$proxyauth = Config::get_safe("proxyauth", false);
if($proxytype === 'URL_PREFIX'){
$curl_request_url = $proxy.$curl_request_url;
if($proxyauth = Config::get_safe("proxyauth", false)){
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
}
if($proxyauth){
curl_setopt($ch, CURLOPT_USERPWD, $proxyauth);
}
} else {
curl_setopt($ch, CURLOPT_PROXY, $proxy);
if($proxyauth){
curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxyauth);
}
if($proxytype = Config::get_safe("proxytype", false)){
switch ($proxytype) {
case 'CURLPROXY_SOCKS4':
$proxytype = CURLPROXY_SOCKS4;
@ -280,6 +288,7 @@ class Post
}
}
curl_setopt($ch, CURLOPT_URL, $curl_request_url);
$html = curl_exec($ch);
curl_close($ch);

View file

@ -50,6 +50,11 @@ logs_path = data/logs/
;proxytype = CURLPROXY_SOCKS4
;proxytype = CURLPROXY_SOCKS5
;URL_PREFIX type:
;proxy = http://your.page.com/proxy.cgi?
;proxyauth = username:password
;proxytype = URL_PREFIX
[system]
system_name = blog
version = 1.252