Add proxy support to callback function

This commit is contained in:
Paul Gear
2015-04-13 19:37:12 +10:00
parent 7ac743723d
commit 93eab16e5a
2 changed files with 21 additions and 0 deletions
+18
View File
@@ -12,6 +12,21 @@
* 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;
printf("Setting proxy to %s (from https_proxy=%s)\n", $proxystr, $_ENV['https_proxy']);
}
if (isset($config['callback_proxy'])) {
printf("Using %s as proxy\n", $config['callback_proxy']);
curl_setopt($post, CURLOPT_PROXY, $config['callback_proxy']);
}
}
$enabled = dbFetchCell("SELECT `value` FROM `callback` WHERE `name` = 'enabled'");
if ($enabled == 1) {
@@ -78,7 +93,9 @@ if ($enabled == 1) {
rtrim($fields, '&');
$post = curl_init();
set_proxy($post);
curl_setopt($post, CURLOPT_URL, $config['callback_post']);
curl_setopt($post, CURLOPT_PROXY, count($submit));
curl_setopt($post, CURLOPT_POST, count($submit));
curl_setopt($post, CURLOPT_POSTFIELDS, $fields);
curl_setopt($post, CURLOPT_RETURNTRANSFER, 1);
@@ -89,6 +106,7 @@ if ($enabled == 1) {
$fields = "uuid=$uuid";
$clear = curl_init();
set_proxy($post);
curl_setopt($clear, CURLOPT_URL, $config['callback_clear']);
curl_setopt($clear, CURLOPT_POST, count($clear));
curl_setopt($clear, CURLOPT_POSTFIELDS, $fields);