Merge branch 'photocache' into 'dev'
Less dependence on cache logic See merge request hubzilla/core!1417
This commit is contained in:
commit
eaa52c19a8
@ -139,7 +139,7 @@ class Photo extends \Zotlabs\Web\Controller {
|
|||||||
$resolution = 1;
|
$resolution = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
$r = q("SELECT uid, photo_usage, expires, display_path FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1",
|
$r = q("SELECT uid, photo_usage, display_path FROM photo WHERE resource_id = '%s' AND imgscale = %d LIMIT 1",
|
||||||
dbesc($photo),
|
dbesc($photo),
|
||||||
intval($resolution)
|
intval($resolution)
|
||||||
);
|
);
|
||||||
@ -156,20 +156,17 @@ class Photo extends \Zotlabs\Web\Controller {
|
|||||||
if(! in_array($resolution,[4,5,6]))
|
if(! in_array($resolution,[4,5,6]))
|
||||||
$allowed = (-1);
|
$allowed = (-1);
|
||||||
if($u === PHOTO_CACHE) {
|
if($u === PHOTO_CACHE) {
|
||||||
// Cached image leak protection
|
// Validate cache
|
||||||
if(! (local_channel() || $cache_mode['leak'])) {
|
$cache = array(
|
||||||
header("Location: " . $r[0]['display_path']);
|
'resid' => $photo,
|
||||||
killme();
|
'uid' => $r[0]['uid'],
|
||||||
}
|
'status' => false
|
||||||
// Revalidate cache
|
);
|
||||||
if($cache_mode['on'] && strtotime($r[0]['expires']) - 60 < time()) {
|
if($cache_mode['on'])
|
||||||
$cache = array(
|
|
||||||
'url' => $r[0]['display_path'],
|
|
||||||
'uid' => $r[0]['uid']
|
|
||||||
);
|
|
||||||
call_hooks('cache_url_hook', $cache);
|
call_hooks('cache_url_hook', $cache);
|
||||||
if(! $cache['status'])
|
if(! $cache['status']) {
|
||||||
http_status_exit(404,'not found');
|
header("Location: " . htmlspecialchars_decode($r[0]['display_path']));
|
||||||
|
killme();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -184,7 +181,7 @@ class Photo extends \Zotlabs\Web\Controller {
|
|||||||
dbesc($photo),
|
dbesc($photo),
|
||||||
intval($resolution)
|
intval($resolution)
|
||||||
);
|
);
|
||||||
|
|
||||||
$exists = (($e) ? true : false);
|
$exists = (($e) ? true : false);
|
||||||
|
|
||||||
if($exists && $allowed) {
|
if($exists && $allowed) {
|
||||||
|
Reference in New Issue
Block a user