streams/Zotlabs/Module/Ca.php

44 lines
1.1 KiB
PHP
Raw Normal View History

2020-03-05 04:07:26 +00:00
<?php
namespace Zotlabs\Module;
use Zotlabs\Web\Controller;
class Ca extends Controller {
function get() {
if (argc() > 1) {
$path = 'cache/img/' . substr(argv(1),0,2) . '/' . argv(1);
if (file_exists($path) && filesize($path)) {
2020-03-05 04:07:26 +00:00
$x = @getimagesize($path);
if ($x) {
header('Content-Type: ' . $x['mime']);
}
$cache = intval(get_config('system','photo_cache_time'));
if (! $cache) {
$cache = (3600 * 24); // 1 day
}
header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $cache) . ' GMT');
// Set browser cache age as $cache. But set timeout of 'shared caches'
// much lower in the event that infrastructure caching is present.
$smaxage = intval($cache/12);
header('Cache-Control: s-maxage=' . $smaxage . '; max-age=' . $cache . ';');
2020-03-05 04:07:26 +00:00
$infile = fopen($path,'rb');
$outfile = fopen('php://output','wb');
if ($infile && $outfile) {
pipe_streams($infile,$outfile);
}
2020-03-05 04:07:26 +00:00
fclose($infile);
fclose($outfile);
killme();
}
2021-04-06 02:23:04 +00:00
2020-03-05 04:07:26 +00:00
if ($_GET['url']) {
goaway($url);
}
}
http_status_exit(404,'Not found');
}
}