Skip to content

Commit

Permalink
Update hybridauth/Hybrid/thirdparty/OpenID/LightOpenID.php
Browse files Browse the repository at this point in the history
  • Loading branch information
fedetorre committed Jul 19, 2012
1 parent 1a3a055 commit 4367bb5
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions hybridauth/Hybrid/thirdparty/OpenID/LightOpenID.php
Expand Up @@ -21,7 +21,7 @@ class LightOpenID
, $data;
private $identity, $claimed_id;
protected $server, $version, $trustRoot, $aliases, $identifier_select = false
, $ax = false, $sreg = false, $setup_url = null, $headers = array();
, $ax = false, $sreg = false, $setup_url = null, $headers = array(), $proxy = null;
static protected $ax_to_sreg = array(
'namePerson/friendly' => 'nickname',
'contact/email' => 'email',
Expand All @@ -34,8 +34,9 @@ class LightOpenID
'pref/timezone' => 'timezone',
);

function __construct($host)
function __construct($host, $proxy)
{
$this->proxy = $proxy;
$this->trustRoot = (strpos($host, '://') ? $host : 'http://' . $host);
if ((!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off')
|| (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])
Expand Down Expand Up @@ -126,7 +127,9 @@ protected function request_curl($url, $method='GET', $params=array(), $update_cl
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Accept: application/xrds+xml, */*'));

if($this->proxy){
curl_setopt( $ci, CURLOPT_PROXY, $this->proxy);
}
if($this->verify_peer !== null) {
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, $this->verify_peer);
if($this->capath) {
Expand Down Expand Up @@ -244,6 +247,9 @@ protected function request_streams($url, $method='GET', $params=array(), $update
),
);
$url = $url . ($params ? '?' . $params : '');
if($this->proxy){
$opts['http']['proxy'] = 'http://' . $this->proxy;
}
break;
case 'POST':
$opts = array(
Expand All @@ -256,6 +262,9 @@ protected function request_streams($url, $method='GET', $params=array(), $update
'CN_match' => parse_url($url, PHP_URL_HOST),
),
);
if($this->proxy){
$opts['http']['proxy'] = 'http://' . $this->proxy;
}
break;
case 'HEAD':
# We want to send a HEAD request,
Expand Down Expand Up @@ -312,7 +321,7 @@ protected function request_streams($url, $method='GET', $params=array(), $update
$this->headers = $this->parse_header_array($http_response_header, $update_claimed_id);
}

return file_get_contents($url, false, $context);
return $data;
}

protected function request($url, $method='GET', $params=array(), $update_claimed_id=false)
Expand Down

0 comments on commit 4367bb5

Please sign in to comment.