'; $o .= '

' . t('Affiliated Sites') . '

'; $o .= '
' . t('This page provides information about related projects and websites that are currently known to this system. These are a small fraction of the thousands of affiliated fediverse websites.') . '
' . EOL; $ret = z_fetch_url($url); if ($ret['success']) { $j = json_decode($ret['body'],true); if ($j) { if ($j['sites']) { $projects = $this->sort_sites($j['sites']); foreach ($projects as $p => $v) { if (! $p) { continue; } $o .= '' . ucfirst($p) . '' . EOL; $o .= ''; $o .= ''; usort($v, [ $this, 'sort_versions' ]); foreach ($v as $jj) { if (strpos($jj['version'],' ')) { $x = explode(' ', $jj['version']); if ($x[1]) { $jj['version'] = $x[1]; } } $m = parse_url($jj['url']); $host = strtolower($m['host']); $location = '
 '; if (!empty($jj['location'])) { $location = '
' . $jj['location'] . ''; } $disabled = (($jj['access'] === 'private') ? true : false); $o .= ''; $o .= ''; } $o .= '
' . t('URL') . '' . t('Access Type') . '' . t('Registration Policy') . '' . t('Software') . '
' . (($disabled) ? '' : ' ') . $host . (($disabled) ? '' : '') . $location . '' . $jj['access'] . '' . (($disabled) ? ' ' : $jj['register']) . '' . ucwords($jj['project']) . (($jj['version']) ? ' ' . $jj['version'] : '') . '
'; $o .= '

'; } } $o .= '
'; } } return $o; } function sort_sites($a) { $ret = []; if($a) { foreach($a as $e) { $projectname = explode(' ',$e['project']); $ret[$projectname[0]][] = $e; } } $projects = array_keys($ret); rsort($projects); $newret = []; foreach($projects as $p) { $newret[$p] = $ret[$p]; } return $newret; } function sort_versions($a,$b) { return version_compare($b['version'],$a['version']); } }