From 26564c6b195d3d6416fad6b8d6da5829b1259c2e Mon Sep 17 00:00:00 2001 From: Paul Gear Date: Mon, 13 Apr 2015 19:51:16 +1000 Subject: [PATCH] Move & rename curl proxy function --- callback.php | 19 ++----------------- includes/functions.php | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/callback.php b/callback.php index 62a3d85dce..b9bc592d72 100644 --- a/callback.php +++ b/callback.php @@ -12,21 +12,6 @@ * the source code distribution for details. */ -function set_proxy($post) -{ - global $config; - if (isset($_ENV['https_proxy'])) { - $tmp = rtrim($_ENV['https_proxy'], "/"); - $proxystr = str_replace(array("http://", "https://"), "", $tmp); - $config['callback_proxy'] = $proxystr; - echo "Setting proxy to ".$proxystr." (from https_proxy=".$_ENV['https_proxy'].")\n"; - } - if (isset($config['callback_proxy'])) { - echo "Using ".$config['callback_proxy']." as proxy\n"; - curl_setopt($post, CURLOPT_PROXY, $config['callback_proxy']); - } -} - $enabled = dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'enabled'"); if ($enabled == 1) { @@ -93,7 +78,7 @@ if ($enabled == 1) { rtrim($fields, '&'); $post = curl_init(); - set_proxy($post); + set_curl_proxy($post); curl_setopt($post, CURLOPT_URL, $config['callback_post']); curl_setopt($post, CURLOPT_PROXY, count($submit)); curl_setopt($post, CURLOPT_POST, count($submit)); @@ -106,7 +91,7 @@ if ($enabled == 1) { $fields = "uuid=$uuid"; $clear = curl_init(); - set_proxy($post); + set_curl_proxy($post); curl_setopt($clear, CURLOPT_URL, $config['callback_clear']); curl_setopt($clear, CURLOPT_POST, count($clear)); curl_setopt($clear, CURLOPT_POSTFIELDS, $fields); diff --git a/includes/functions.php b/includes/functions.php index 5865dc3a79..701229ecfa 100755 --- a/includes/functions.php +++ b/includes/functions.php @@ -1140,4 +1140,17 @@ function guidv4($data) { return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); } -?> +function set_curl_proxy($post) +{ + global $config; + if (isset($_ENV['https_proxy'])) { + $tmp = rtrim($_ENV['https_proxy'], "/"); + $proxystr = str_replace(array("http://", "https://"), "", $tmp); + $config['callback_proxy'] = $proxystr; + echo "Setting proxy to ".$proxystr." (from https_proxy=".$_ENV['https_proxy'].")\n"; + } + if (isset($config['callback_proxy'])) { + echo "Using ".$config['callback_proxy']." as proxy\n"; + curl_setopt($post, CURLOPT_PROXY, $config['callback_proxy']); + } +}