From a9a17a27cb75155a5bb798495e801840735ea215 Mon Sep 17 00:00:00 2001 From: plegall Date: Mon, 15 Feb 2016 15:02:16 +0100 Subject: feature #295, proxy support for fetchRemote --- admin/include/functions.php | 13 +++++++++++++ include/config_default.inc.php | 14 ++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/admin/include/functions.php b/admin/include/functions.php index 04a83d0bc..9a827d1d6 100644 --- a/admin/include/functions.php +++ b/admin/include/functions.php @@ -2076,6 +2076,8 @@ function cat_admin_access($category_id) */ function fetchRemote($src, &$dest, $get_data=array(), $post_data=array(), $user_agent='Piwigo', $step=0) { + global $conf; + // Try to retrieve data from local file? if (!url_is_remote($src)) { @@ -2111,6 +2113,17 @@ function fetchRemote($src, &$dest, $get_data=array(), $post_data=array(), $user_ if (function_exists('curl_init') && function_exists('curl_exec')) { $ch = @curl_init(); + + if (isset($conf['use_proxy']) && $conf['use_proxy']) + { + @curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, 0); + @curl_setopt($ch, CURLOPT_PROXY, $conf['proxy_server']); + if (isset($conf['proxy_auth']) && !empty($conf['proxy_auth'])) + { + @curl_setopt($ch, CURLOPT_PROXYUSERPWD, $conf['proxy_auth']); + } + } + @curl_setopt($ch, CURLOPT_URL, $src); @curl_setopt($ch, CURLOPT_HEADER, 1); @curl_setopt($ch, CURLOPT_USERAGENT, $user_agent); diff --git a/include/config_default.inc.php b/include/config_default.inc.php index f38942d15..f66dab486 100644 --- a/include/config_default.inc.php +++ b/include/config_default.inc.php @@ -832,4 +832,18 @@ $conf['log_level'] = 'DEBUG'; // Keep logs file during X days $conf['log_archive_days'] = 30; + +// +-----------------------------------------------------------------------+ +// | Proxy Settings | +// +-----------------------------------------------------------------------+ + +// If piwigo needs a http-proxy to connect to the internet, set this to true +$conf['use_proxy'] = false; + +// Connection string of the proxy +$conf['proxy_server'] = 'proxy.domain.org:port'; + +// If the http-proxy requires authentication, set username and password here +// e.g. username:password +$conf['proxy_auth'] = ''; ?> -- cgit v1.2.3