Skip to content

Commit 9c99841

Browse files
author
Fabian Mielke
committed
Merge pull request #37 from webbird/master
allow to use a proxy (function setProxy($sProxyName,$sProxyPort=NULL))
2 parents a376351 + 424bd1d commit 9c99841

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

Immocaster/Immobilienscout/Immobilienscout.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,14 @@ protected function getContent($req,$sSecret=null,$aHeader=array())
206206
{
207207
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE');
208208
}
209+
if($this->_sProxyName)
210+
{
211+
curl_setopt($ch, CURLOPT_PROXY, $this->_sProxyName);
212+
if($this->_sProxyPort)
213+
{
214+
curl_setopt($ch, CURLOPT_PROXYPORT, $this->_sProxyPort);
215+
}
216+
}
209217
$result = curl_exec($ch);
210218
// Return information
211219
if($this->_bRequestDebug==true)

Immocaster/Immobilienscout/Rest.php

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ class Immocaster_Immobilienscout_Rest extends Immocaster_Immobilienscout
5555
*/
5656
protected $_sProtocol = 'http';
5757

58+
/**
59+
* Proxy
60+
**/
61+
protected $_sProxyName = NULL;
62+
protected $_sProxyPort = NULL;
63+
5864
/**
5965
* Der Constructor legt die Einstellungen für die
6066
* Verbindung fest und startet diese.
@@ -164,6 +170,22 @@ public function setStrictMode($bMode=false)
164170
return false;
165171
}
166172

173+
/**
174+
* Proxy-Einstellungen
175+
*
176+
* @param string $sProxyName Name (oder IP) des Proxy-Servers
177+
* @param string $sProxyPort optionaler Port (wird auf numeric geprueft)
178+
* @return void
179+
**/
180+
public function setProxy($sProxyName,$sProxyPort=NULL)
181+
{
182+
$this->_sProxyName = $sProxyName;
183+
if($sProxyPort&&is_numeric($sProxyPort))
184+
{
185+
$this->_sProxyPort = $sProxyPort;
186+
}
187+
}
188+
167189
/**
168190
* Authentifizierung ohne MySQL Datenbank aktivieren und deaktivieren.
169191
*
@@ -1405,6 +1427,14 @@ private function registerAccess($aArgs)
14051427
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
14061428
curl_setopt($ch, CURLOPT_HEADER, 0);
14071429
curl_setopt($ch, CURLOPT_HTTPHEADER, $opts['http']);
1430+
if($this->_sProxyName)
1431+
{
1432+
curl_setopt($ch, CURLOPT_PROXY, $this->_sProxyName);
1433+
if($this->_sProxyPort)
1434+
{
1435+
curl_setopt($ch, CURLOPT_PROXYPORT, $this->_sProxyPort);
1436+
}
1437+
}
14081438
$result = curl_exec($ch);
14091439
curl_close($ch);
14101440
}else{
@@ -1537,6 +1567,15 @@ private function _postVideoToPicsearch($aParameter)
15371567
curl_setopt($ch, CURLOPT_POSTFIELDS, $postValues);
15381568
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
15391569

1570+
if($this->_sProxyName)
1571+
{
1572+
curl_setopt($ch, CURLOPT_PROXY, $this->_sProxyName);
1573+
if($this->_sProxyPort)
1574+
{
1575+
curl_setopt($ch, CURLOPT_PROXYPORT, $this->_sProxyPort);
1576+
}
1577+
}
1578+
15401579
try
15411580
{
15421581
$httpDescription = curl_exec($ch);

0 commit comments

Comments
 (0)