コード例 #1
0
ファイル: endpoints.php プロジェクト: Krassmus/LehrMarktplatz
 protected function refreshHost($url)
 {
     $host_data = file_get_contents($url . "fetch_public_host_key");
     if ($host_data) {
         $host_data = studip_utf8decode(json_decode($host_data, true));
         if ($host_data) {
             $host = LernmarktplatzHost::findOneByUrl($url);
             if (!$host) {
                 $host = LernmarktplatzHost::findOneByPublic_key($host_data['public_key']);
             }
             if (!$host) {
                 $host = new LernmarktplatzHost();
             }
             $host['name'] = $host_data['name'];
             $host['url'] = Request::get("from");
             $host['public_key'] = $host_data['public_key'];
             $host['last_updated'] = time();
             if ($host->isNew()) {
                 $host['active'] = get_config("LERNMARKTPLATZ_ACTIVATE_NEW_HOSTS") ? 1 : 0;
             }
             $host->store();
         }
     }
 }