probe_url: Better detection for non-standard installations of GNU Social
This commit is contained in:
parent
e0147a24ad
commit
b7f270de28
|
@ -335,7 +335,7 @@ function scrape_feed($url) {
|
||||||
define ( 'PROBE_NORMAL', 0);
|
define ( 'PROBE_NORMAL', 0);
|
||||||
define ( 'PROBE_DIASPORA', 1);
|
define ( 'PROBE_DIASPORA', 1);
|
||||||
|
|
||||||
function probe_url($url, $mode = PROBE_NORMAL) {
|
function probe_url($url, $mode = PROBE_NORMAL, $level = 1) {
|
||||||
require_once('include/email.php');
|
require_once('include/email.php');
|
||||||
|
|
||||||
$result = array();
|
$result = array();
|
||||||
|
@ -804,13 +804,23 @@ function probe_url($url, $mode = PROBE_NORMAL) {
|
||||||
|
|
||||||
logger('probe_url: ' . print_r($result,true), LOGGER_DEBUG);
|
logger('probe_url: ' . print_r($result,true), LOGGER_DEBUG);
|
||||||
|
|
||||||
// Trying if it maybe a diaspora account
|
if ($level == 1) {
|
||||||
if (($result['network'] == NETWORK_FEED) OR ($result['addr'] == "")) {
|
// Trying if it maybe a diaspora account
|
||||||
require_once('include/bbcode.php');
|
if (($result['network'] == NETWORK_FEED) OR ($result['addr'] == "")) {
|
||||||
$address = GetProfileUsername($url, "", true);
|
require_once('include/bbcode.php');
|
||||||
$result2 = probe_url($address, $mode);
|
$address = GetProfileUsername($url, "", true);
|
||||||
if ($result2['network'] != "")
|
$result2 = probe_url($address, $mode, ++$level);
|
||||||
$result = $result2;
|
if ($result2['network'] != "")
|
||||||
|
$result = $result2;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Maybe it's some non standard GNU Social installation (Single user, subfolder or no uri rewrite)
|
||||||
|
if (($result['network'] == NETWORK_FEED) AND ($result['baseurl'] != "") AND ($result['nick'] != "")) {
|
||||||
|
$addr = $result['nick'].'@'.str_replace("http://", "", $result['baseurl']);
|
||||||
|
$result2 = probe_url($addr, $mode, ++$level);
|
||||||
|
if (($result2['network'] != "") AND ($result2['network'] != NETWORK_FEED))
|
||||||
|
$result = $result2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Cache::set("probe_url:".$mode.":".$url,serialize($result));
|
Cache::set("probe_url:".$mode.":".$url,serialize($result));
|
||||||
|
|
Loading…
Reference in a new issue