|
|
@ -242,20 +242,33 @@
|
|
|
|
str_replace("\\/", "/", $this->contents_sdir);
|
|
|
|
str_replace("\\/", "/", $this->contents_sdir);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static function source_cache_file(string $source_key) {
|
|
|
|
|
|
|
|
global $SOURCES_CACHE;
|
|
|
|
|
|
|
|
return "$SOURCES_CACHE/$source_key";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private static function fetch_source(string $source_key) {
|
|
|
|
private static function fetch_source(string $source_key) {
|
|
|
|
$url = CommunitySources::SOURCES[$source_key];
|
|
|
|
$url = CommunitySources::SOURCES[$source_key];
|
|
|
|
|
|
|
|
|
|
|
|
$contents = file_get_contents($url);
|
|
|
|
$contents = file_get_contents($url);
|
|
|
|
log_debug($http_response_header[0]);
|
|
|
|
log_debug($http_response_header[0]);
|
|
|
|
|
|
|
|
$cache_file = CommunitySources::source_cache_file($source_key);
|
|
|
|
|
|
|
|
|
|
|
|
if (!$contents) {
|
|
|
|
if ($contents) {
|
|
|
|
log_error("Could not fetch source from $url.");
|
|
|
|
file_put_contents($cache_file, $contents);
|
|
|
|
return "";
|
|
|
|
return $contents;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$contents = file_get_contents($cache_file);
|
|
|
|
|
|
|
|
if ($contents) {
|
|
|
|
|
|
|
|
log_warning("Could not fetch source from $url, using cache");
|
|
|
|
return $contents;
|
|
|
|
return $contents;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
log_error("Could not fetch source from $url.");
|
|
|
|
|
|
|
|
return "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @param string[][] $tags Array associating room IDs to tag arrays
|
|
|
|
* @param string[][] $tags Array associating room IDs to tag arrays
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -315,4 +328,6 @@
|
|
|
|
return $this->room_tags[$room_id];
|
|
|
|
return $this->room_tags[$room_id];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
file_exists($SOURCES_CACHE) or mkdir($SOURCES_CACHE, 0755, recursive: true);
|
|
|
|
?>
|
|
|
|
?>
|
|
|
|