From 57ebd7e1704597b1eea31610cd08c076ea7473cf Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 3 Dec 2018 13:10:55 +0100 Subject: New logic for less dependence on cache logic --- Zotlabs/Module/Photo.php | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index d85db7307..da5d4c39b 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -139,7 +139,7 @@ class Photo extends \Zotlabs\Web\Controller { $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), intval($resolution) ); @@ -156,20 +156,17 @@ class Photo extends \Zotlabs\Web\Controller { if(! in_array($resolution,[4,5,6])) $allowed = (-1); if($u === PHOTO_CACHE) { - // Cached image leak protection - if(! (local_channel() || $cache_mode['leak'])) { - header("Location: " . $r[0]['display_path']); - killme(); - } - // Revalidate cache - if($cache_mode['on'] && strtotime($r[0]['expires']) - 60 < time()) { - $cache = array( - 'url' => $r[0]['display_path'], - 'uid' => $r[0]['uid'] - ); + // Validate cache + $cache = array( + 'resid' => $photo, + 'uid' => $r[0]['uid'], + 'status' => true + ); + if($cache_mode['on']) call_hooks('cache_url_hook', $cache); - if(! $cache['status']) - http_status_exit(404,'not found'); + if((! (local_channel() || $cache_mode['leak'])) || (! $cache['status'])) { + header("Location: " . htmlspecialchars_decode($r[0]['display_path'])); + killme(); } } } @@ -184,7 +181,7 @@ class Photo extends \Zotlabs\Web\Controller { dbesc($photo), intval($resolution) ); - + $exists = (($e) ? true : false); if($exists && $allowed) { -- cgit v1.2.3 From 244c0d828a31447cb215251d88b0123508f0101d Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 3 Dec 2018 13:29:27 +0100 Subject: Update Photo.php --- Zotlabs/Module/Photo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index da5d4c39b..f96d478f2 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -160,7 +160,7 @@ class Photo extends \Zotlabs\Web\Controller { $cache = array( 'resid' => $photo, 'uid' => $r[0]['uid'], - 'status' => true + 'status' => false ); if($cache_mode['on']) call_hooks('cache_url_hook', $cache); -- cgit v1.2.3 From b586fcebabfad0c062deb3070d1679414595dc95 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 3 Dec 2018 21:21:23 +0100 Subject: Update Photo.php --- Zotlabs/Module/Photo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index f96d478f2..a73492ae2 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -164,7 +164,7 @@ class Photo extends \Zotlabs\Web\Controller { ); if($cache_mode['on']) call_hooks('cache_url_hook', $cache); - if((! (local_channel() || $cache_mode['leak'])) || (! $cache['status'])) { + if(! $cache['status'] && $cache_mode['leak']) { header("Location: " . htmlspecialchars_decode($r[0]['display_path'])); killme(); } -- cgit v1.2.3 From 1c44912aff2c7f026fe1e5e74eb1d70920d17747 Mon Sep 17 00:00:00 2001 From: Max Kostikov Date: Mon, 3 Dec 2018 21:33:32 +0100 Subject: Update Photo.php --- Zotlabs/Module/Photo.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php index a73492ae2..ddff3a68e 100644 --- a/Zotlabs/Module/Photo.php +++ b/Zotlabs/Module/Photo.php @@ -164,7 +164,7 @@ class Photo extends \Zotlabs\Web\Controller { ); if($cache_mode['on']) call_hooks('cache_url_hook', $cache); - if(! $cache['status'] && $cache_mode['leak']) { + if(! $cache['status']) { header("Location: " . htmlspecialchars_decode($r[0]['display_path'])); killme(); } -- cgit v1.2.3 From 7894fed7413ab3bd782bf939b17ca70bf0196d28 Mon Sep 17 00:00:00 2001 From: Mario Vavti Date: Mon, 10 Dec 2018 10:37:29 +0100 Subject: add photo_view_filter hook and fix minor issue with unset auto_save_draft variable which resultet in a javascript error --- Zotlabs/Module/Photos.php | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'Zotlabs') diff --git a/Zotlabs/Module/Photos.php b/Zotlabs/Module/Photos.php index 21f6293ef..b87c586da 100644 --- a/Zotlabs/Module/Photos.php +++ b/Zotlabs/Module/Photos.php @@ -1122,6 +1122,7 @@ class Photos extends \Zotlabs\Web\Controller { $comments = ''; if(! $r) { if($observer && ($can_post || $can_comment)) { + $feature_auto_save_draft = ((feature_enabled($owner_uid, 'auto_save_draft')) ? "true" : "false"); $commentbox = replace_macros($cmnt_tpl,array( '$return_path' => '', '$mode' => 'photos', @@ -1137,7 +1138,8 @@ class Photos extends \Zotlabs\Web\Controller { '$submit' => t('Submit'), '$preview' => t('Preview'), '$ww' => '', - '$feature_encrypt' => false + '$feature_encrypt' => false, + '$auto_save_draft' => $feature_auto_save_draft )); } } @@ -1270,8 +1272,14 @@ class Photos extends \Zotlabs\Web\Controller { if(feature_enabled($owner_uid,'dislike')) $response_verbs[] = 'dislike'; - $responses = get_responses($conv_responses,$response_verbs,'',$link_item); + + $hookdata = [ + 'onclick' => '$.colorbox({href: \'' . $photo['href'] . '\'}); return false;', + 'raw_photo' => $ph[0], + 'nickname' => \App::$data['channel']['channel_address'] + ]; + call_hooks('photo_view_filter', $hookdata); $photo_tpl = get_markup_template('photo_view.tpl'); $o .= replace_macros($photo_tpl, array( @@ -1309,6 +1317,7 @@ class Photos extends \Zotlabs\Web\Controller { '$comments' => $comments, '$commentbox' => $commentbox, '$paginate' => $paginate, + '$onclick' => $hookdata['onclick'] )); \App::$data['photo_html'] = $o; -- cgit v1.2.3