diff --git a/php/uploadFile.php b/php/uploadFile.php index bae12a5..22c7f58 100644 --- a/php/uploadFile.php +++ b/php/uploadFile.php @@ -39,6 +39,13 @@ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); + // BRE - Add proxy host if exists + if (defined('HTTP_PROXY_HOST')) { + curl_setopt($ch, CURLOPT_PROXY, "http://".HTTP_PROXY_HOST); + if (defined('HTTP_PROXY_USER')) { + curl_setopt($ch, CURLOPT_PROXYUSERPWD, HTTP_PROXY_USER); + } + } $data = curl_exec($ch); curl_close($ch); @@ -166,12 +173,12 @@ die(json_encode($response)); } - if ($file['size'] > DISK_QUOTA) + if (isset($file['size']) && ($file['size'] > DISK_QUOTA)) { $response = array( 'success' => false, 'error' => 'The file you selected is too big for allowed disk quota'); die(json_encode($response)); } - + if ($wsMgr->getWsSize() + $fileSize > DISK_QUOTA && $isFile) { $response = array( 'success' => false, 'error' => 'Please clean up you workspace. You are about to exceed available disk space'); @@ -185,7 +192,31 @@ die(json_encode($response)); } - if (!copy($remoteName, $localName)) + + // BRE - Add proxy host if exists + $result = FALSE; + if (defined('HTTP_PROXY_HOST')) { + $options = array( + 'http' => array( + 'method' => 'GET', + 'timeout' => '5', + 'user_agent' => 'PHP libxml agent', + 'ignore_errors' => true, + ) + ); + $options['http']['proxy'] = 'tcp://'.HTTP_PROXY_HOST; + $options['http']['request_fulluri'] = TRUE; + if (defined('HTTP_PROXY_USER')) { + $options['http']['header'] = "Proxy-Authorization: Basic ".base64_encode(HTTP_PROXY_USER); + } + $context = stream_context_create($options); + $result = copy($remoteName, $localName, $context); + } + else { + $result = copy($remoteName, $localName); + } + + if (!$result) { $response = array( 'success' => false, 'error' => 'Can\'t copy '.$fileName); die(json_encode($response)); -- libgit2 0.21.2