mirror of
https://github.com/FreshRSS/FreshRSS.git
synced 2026-01-17 17:57:54 -05:00
* PHPStan 2.0 fix https://github.com/FreshRSS/FreshRSS/issues/6989 https://github.com/phpstan/phpstan/releases/tag/2.0.0 https://github.com/phpstan/phpstan/blob/2.0.x/UPGRADING.md * More * More * Done * fix i18n CLI * Restore a PHPStan Next test For work towards PHPStan Level 10 * 4 more on Level 10 * fix getTagsForEntry * API at Level 10 * More Level 10 * Finish Minz at Level 10 * Finish CLI at Level 10 * Finish Controllers at Level 10 * More Level 10 * More * Pass bleedingEdge * Clean PHPStan options and add TODOs * Level 10 for main config * More * Consitency array vs. list * Sanitize themes get_infos * Simplify TagDAO->getTagsForEntries() * Finish reportAnyTypeWideningInVarTag * Prepare checkBenevolentUnionTypes and checkImplicitMixed * Fixes * Refix * Another fix * Casing of __METHOD__ constant
57 lines
1.5 KiB
PHP
57 lines
1.5 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
require(__DIR__ . '/../constants.php');
|
|
require(LIB_PATH . '/lib_rss.php'); //Includes class autoloader
|
|
require(LIB_PATH . '/favicons.php');
|
|
require(LIB_PATH . '/http-conditional.php');
|
|
|
|
function show_default_favicon(int $cacheSeconds = 3600): void {
|
|
$default_mtime = @filemtime(DEFAULT_FAVICON) ?: 0;
|
|
if (!httpConditional($default_mtime, $cacheSeconds, 2)) {
|
|
header('Content-Type: image/x-icon');
|
|
header('Content-Disposition: inline; filename="default_favicon.ico"');
|
|
readfile(DEFAULT_FAVICON);
|
|
}
|
|
}
|
|
|
|
$id = $_SERVER['QUERY_STRING'] ?? '0';
|
|
if (!is_string($id) || !ctype_xdigit($id)) {
|
|
$id = '0';
|
|
}
|
|
|
|
$txt = FAVICONS_DIR . $id . '.txt';
|
|
$ico = FAVICONS_DIR . $id . '.ico';
|
|
|
|
$ico_mtime = @filemtime($ico) ?: 0;
|
|
$txt_mtime = @filemtime($txt) ?: 0;
|
|
|
|
if ($ico_mtime == false || $ico_mtime < $txt_mtime || ($ico_mtime < time() - (mt_rand(15, 20) * 86400))) {
|
|
if ($txt_mtime == false) {
|
|
show_default_favicon(1800);
|
|
exit();
|
|
}
|
|
|
|
// no ico file or we should download a new one.
|
|
$url = file_get_contents($txt);
|
|
if ($url === false) {
|
|
show_default_favicon(1800);
|
|
exit();
|
|
}
|
|
if (!download_favicon($url, $ico)) {
|
|
// Download failed
|
|
if ($ico_mtime == false) {
|
|
show_default_favicon(86400);
|
|
exit();
|
|
}
|
|
|
|
touch($ico);
|
|
}
|
|
}
|
|
|
|
if (!httpConditional($ico_mtime, mt_rand(14, 21) * 86400, 2)) {
|
|
$ico_content_type = contentType($ico);
|
|
header('Content-Type: ' . $ico_content_type);
|
|
header('Content-Disposition: inline; filename="' . $id . '.ico"');
|
|
readfile($ico);
|
|
}
|