diff --git a/connect_class.php b/connect_class.php index 996549a..56dce4c 100644 --- a/connect_class.php +++ b/connect_class.php @@ -97,6 +97,7 @@ class connect_class { * @param array $add_header an array of headers to add to the request */ public function send_request($return_header = 0, $add_header = array(), $stop = false) { + global $CFG; $ch = curl_init(); if ($stop) { @@ -108,6 +109,13 @@ class connect_class { curl_setopt($ch, CURLOPT_URL, $this->_serverurl . $querystring); } + // Connect through a proxy if Moodle config says we should + if(isset($CFG->proxyhost)) { + curl_setopt($ch, CURLOPT_PROXY, $CFG->proxyhost); + if(isset($CFG->proxyport)) { + curl_setopt($ch, CURLOPT_PROXYPORT, $CFG->proxyport); + } + } curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $this->_xmlrequest);