Tommy 碎碎念

Tommy Wu's blog

« 上一篇 | 下一篇 »

Gallery 3 hide 模組的存取檢查修正
post by tommy @ 15 十二月, 2011 13:21

Gallery 3 中, 有提供一個 hide 模組, 用來隱藏某些相片, 在一般相簿的瀏覽時可以正常運作,  不讓被隱藏的項目被沒有足夠權限的人看到, 不過... 如果直接給該照片所在的 URL (不管是 Gallery 裡頭的網頁, 或是全圖與縮圖之類的連結), 就可以直接看到該相片, 完全失去隱藏的功用.

看了一下 hide 這模組的處理方式, 應該是直接在 viewable() 這個存取資料庫的方式中, 加上對 hidden_items 的檢查. 而正常的瀏覽時, 是使用這個方式來取得項目, 所以並不會看到被隱藏的項目.

不過在處理單一項目的連結時, 就不透過 viewable() 來處理, 而是直接用 id 去取得該項目, 所以這個檢查的動作就沒執行到了.

這個修正會在 hide 模組啟用時, 特別去做這個檢查, 以避免隱藏的項目被別人看到.

--- gallery3.orig/modules/gallery/helpers/access.php  2011-05-25 12:04:04.000000000 +0800
+++ gallery3/modules/gallery/helpers/access.php 2011-12-12 14:24:34.366137553 +0800
@@ -99,6 +99,16 @@
return true;
}
 
+ // twu2 add for hide module
+ if (module::is_active('hide')) {
+ if (!hide::can_view_hidden_items()) {
+ if (hide::is_hidden($item)) {
+ return false;
+ }
+ }
+ }
+ // twu2 end
+
// Use the nearest parent album (including the current item) so that we take advantage
// of the cache when checking many items in a single album.
$id = ($item->type == "album") ? $item->id : $item->parent_id;

這樣子, 在沒有權限時, 就會直接轉到主頁面, 而不會顯示不該顯示的東西.

PS. 記得也把 /var 底下的東西 rewrite 給 /file_proxy/ 去處理, 否則這個檢查也不能防止別人看到不能看的項目的全圖或縮圖.

Del.icio.us Furl HEMiDEMi Technorati MyShare
迴響
暱稱:
標題:
個人網頁:
電子郵件:
authimage

迴響

  

Bad Behavior 已經阻擋了 48 個過去 7 天試圖闖關的垃圾迴響與引用。
Power by LifeType. Template design by JamesHuang. Valid XHTML and CSS