Logger::notice('Got exception', ['code' => $th->getCode(), 'message' => $th->getMessage()]);
return [];
}
+
$ssl_connection_error = ($curlResult->getErrorNumber() == CURLE_COULDNT_CONNECT) || ($curlResult->getReturnCode() == 0);
+
+ $host_url = $host;
+
if ($curlResult->isSuccess()) {
$xml = $curlResult->getBodyString();
$xrd = XML::parseString($xml, true);
if (!empty($url)) {
$host_url = 'https://' . $host;
- } else {
- $host_url = $host;
}
} elseif ($curlResult->isTimeout()) {
Logger::info('Probing timeout', ['url' => $ssl_url]);
public static function getWebfingerArray(string $uri): array
{
$parts = parse_url($uri);
+ $lrdd = [];
if (!empty($parts['scheme']) && !empty($parts['host'])) {
$host = $parts['host'];
$addr = '';
$path_parts = explode('/', trim($parts['path'] ?? '', '/'));
- if (!empty($path_parts)) {
+ if (is_array($path_parts)) {
$nick = ltrim(end($path_parts), '@');
$addr = $nick . '@' . $host;
}
return null;
}
+ $detected = '';
+
// First try the address because this is the primary purpose of webfinger
- if (!empty($addr)) {
+ if ($addr !== '') {
$detected = $addr;
$path = str_replace('{uri}', urlencode('acct:' . $addr), $template);
$webfinger = self::webfinger($path, $type);
*/
private static function zot(array $webfinger, array $data): array
{
+ $zot_url = '';
+
foreach ($webfinger['links'] as $link) {
if (($link['rel'] == 'http://purl.org/zot/protocol/6.0') && !empty($link['href'])) {
$zot_url = $link['href'];
}
}
- if (empty($zot_url)) {
+ if ($zot_url === '') {
return $data;
}
$data['url'] = $link['href'];
}
}
-
+
$data = self::pollZot($zot_url, $data);
if (!empty($data['url']) && !empty($webfinger['aliases']) && is_array($webfinger['aliases'])) {
&& !empty($data['guid'])
&& !empty($data['baseurl'])
&& !empty($data['pubkey'])
- && !empty($hcard_url)
+ && $hcard_url !== ''
) {
$data['network'] = Protocol::DIASPORA;
$data['manually-approve'] = false;
$password = '';
openssl_private_decrypt(hex2bin($mailacct['pass']), $password, $user['prvkey']);
$mbox = Email::connect($mailbox, $mailacct['user'], $password);
- if (!$mbox) {
+ if ($mbox === false) {
return [];
}
}
}
- if (!empty($mbox)) {
+ if ($mbox !== false) {
imap_close($mbox);
}
Logger::info('Mail is enabled');
- $mbox = null;
+ $mbox = false;
$user = DBA::selectFirst('user', ['prvkey'], ['uid' => $importer_uid]);
$condition = ["`server` != ? AND `user` != ? AND `port` != ? AND `uid` = ?", '', '', 0, $importer_uid];
$mbox = Email::connect($mailbox, $mailconf['user'], $password);
unset($password);
Logger::notice('Connect', ['user' => $mailconf['user']]);
- if ($mbox) {
- $fields = ['last_check' => $updated];
- DBA::update('mailacct', $fields, ['id' => $mailconf['id']]);
- Logger::notice('Connected', ['user' => $mailconf['user']]);
- } else {
+
+ if ($mbox === false) {
Logger::notice('Connection error', ['user' => $mailconf['user'], 'error' => imap_errors()]);
return false;
}
+
+ $fields = ['last_check' => $updated];
+ DBA::update('mailacct', $fields, ['id' => $mailconf['id']]);
+ Logger::notice('Connected', ['user' => $mailconf['user']]);
}
- if (empty($mbox)) {
+ if ($mbox === false) {
return false;
}