public function askKnownHosts() { $endpoint_url = $this['url'] . "fetch_known_hosts" . "?from=" . urlencode(studip_utf8encode($GLOBALS['LERNMARKTPLATZ_PREFERRED_URI'] ?: $GLOBALS['ABSOLUTE_URI_STUDIP'] . "plugins.php/lernmarktplatz/endpoints/")); $output = @file_get_contents($endpoint_url); if ($output) { $output = studip_utf8decode(json_decode($output, true)); foreach ((array) $output['hosts'] as $host_data) { $host = LernmarktplatzHost::findByPublic_key($host_data['public_key']); if (!$host) { $host = new LernmarktplatzHost(); $host['public_key'] = preg_replace("/\r/", "", $host_data['public_key']); $host['url'] = $host_data['url']; } if ($host['last_updated'] < time() - 60 * 60 * 8) { $host->fetchPublicKey(); } $host->store(); } } }