provide 'session' option to z_fetch_url to assist with remote fetches requiring magic auth
This commit is contained in:
parent
df6e75e1d6
commit
fa944fc526
@ -445,7 +445,7 @@ class Connedit extends \Zotlabs\Web\Controller {
|
|||||||
if($cmd === 'fetchvc') {
|
if($cmd === 'fetchvc') {
|
||||||
$url = str_replace('/channel/','/profile/',$orig_record[0]['xchan_url']) . '/vcard';
|
$url = str_replace('/channel/','/profile/',$orig_record[0]['xchan_url']) . '/vcard';
|
||||||
$recurse = 0;
|
$recurse = 0;
|
||||||
$x = z_fetch_url(zid($url),false,$recurse,['headers' => ['Cookie: PHPSESSID=' . session_id()]]);
|
$x = z_fetch_url(zid($url),false,$recurse,['session' => true]);
|
||||||
if($x['success']) {
|
if($x['success']) {
|
||||||
$h = new \Zotlabs\Web\HTTPHeaders($x['header']);
|
$h = new \Zotlabs\Web\HTTPHeaders($x['header']);
|
||||||
$fields = $h->fetch();
|
$fields = $h->fetch();
|
||||||
|
@ -91,6 +91,10 @@ function z_fetch_url($url, $binary = false, $redirects = 0, $opts = array()) {
|
|||||||
@curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
|
@curl_setopt($ch, CURLOPT_TIMEOUT, (($curl_time !== false) ? $curl_time : 60));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(x($opts,'session') && strpos($url,z_root()) === 0) {
|
||||||
|
@curl_setopt($ch, CURLOPT_HTTPHEADER, [ 'Cookie: PHPSESSID=' . session_id() ]);
|
||||||
|
}
|
||||||
|
|
||||||
if(x($opts,'http_auth')) {
|
if(x($opts,'http_auth')) {
|
||||||
// "username" . ':' . "password"
|
// "username" . ':' . "password"
|
||||||
@curl_setopt($ch, CURLOPT_USERPWD, $opts['http_auth']);
|
@curl_setopt($ch, CURLOPT_USERPWD, $opts['http_auth']);
|
||||||
|
Reference in New Issue
Block a user