![]() |
|
can't get checkAccess() to work - Printable Version +- ZenphotoCMS Forum (https://forum.zenphoto.org) +-- Forum: Support (https://forum.zenphoto.org/forum-1.html) +--- Forum: General support (https://forum.zenphoto.org/forum-4.html) +--- Thread: can't get checkAccess() to work (/thread-10496.html) |
can't get checkAccess() to work - ERamseth - 2012-10-10 So I've written a script which serves videos to jplayer from a directory that isn't normally visible to web browsers. I'm trying to incorporate checkAccess() into the script so it can only pull files for a user who should be able to access said files. So far I've added `define('SERVERPATH',str_replace('\','/',dirname(FILE)).'/zp'); define('WEBPATH','/'.basename(dirname(FILE)).'/zp'); require_once(SERVERPATH.'/zp-core/template-functions.php');` to my script and have done `zp_load_gallery(); zp_load_album('$albumName'); zp_load_image($albumName, $imageName);` with valid directory and file names. when I try
I never get a result (I assume that means it thinks I don't have access). I have tried it both logged in and logged out and it makes no difference. I know the $_zp_current_image seems to be working in other areas... I can get valid width and height; and isProtected() returns 1. Is there anything glaringly wrong with what I've done in my code that might be causing me problems? can't get checkAccess() to work - acrylian - 2012-10-10
Did you look at this? http://www.zenphoto.org/news/zenphoto-as-a-plug-in-using-zenphoto-functions-from-outside-zenphoto can't get checkAccess() to work - ERamseth - 2012-10-10 I did see that documentation page. So yeah I should remove those quotes for the album name. I initially tried with makeImage but I wasn't sure if I was creating a new "image" (not what I want to do) or referencing an existing "image" (which IS what I want to do). For whatever reason in my mind I thought I had todo zp_load_gallery() first or else I was just creating an orphaned image object. Initially, for debugging my script, I had something like
Where $image was a creation of makeImage. No matter what I tweaked, I couldn't get that to seemingly return true. As far as the album name, what I need is the relative path to the album inside of the albums directory right? So if my install is at domain.com/zenphoto and my structure is something like domain.com/zenphoto/albums/person1/album2 and I want to reference the sub-album "album2" I need to pass on "person/album2" right? EDIT: Also, I think that if I try to print a bool I get back 0 or 1? I might be mistaken in that though. can't get checkAccess() to work - sbillard - 2012-10-11 Images do not have access control. Only albums can't get checkAccess() to work - acrylian - 2012-10-11 However, the image class has a method checkAccess(). Which of course checks the rights of its album technically. can't get checkAccess() to work - ERamseth - 2012-10-11 I didn't realize individual images didn't have access control. Please let me know if the below sounds right... If I want to see if a user who is already logged in has access to an image (really a video)--in order to validate if they should be allowed to view and download the video through my script--I should use checkAccess() on the image object created with makeImage() after adding in the zenphoto template functions. And when I call checkAccess() on an image, it is really checking access to the album in which the image resides. (also, thanks for the help so far!) can't get checkAccess() to work - ERamseth - 2012-10-11 So quick thing I realized... in my first post I wrote that I did zp_load_album('$albumName'); (notice the erroneous single quotes). Since checkAccess() depends on the album rights and per the above mistake I would've attempted to define an album incorrectly... could this be the reason I wasn't getting a reply from checkAccess()? Obviously I'm going to fix this when I get the chance and try it again, but I just thought I'd post here in case someone else was having similar issues. can't get checkAccess() to work - acrylian - 2012-10-12 The quotes are wrong indeed. Best you try again as I lack the time to try myself right now. |