PDA

View Full Version : Addon: Private Addon V1.0 beta


austriaka
12-04-2006, 07:36 PM
I wanted to share pictures of my children with friends and grannies, but I didn't want everybody see the photos. So I began with hacking pixelpost up to my needs. After everything running fine I decided to rewrite the whole thing and make a real addon out of it.
Here it comes: admin_private_addon (http://www.uhlig.at/tmp/admin_private_addon_1_0beta.zip)
I didn't upload it to pixelpost developer area yet, because right now it is only beta. Means it is only tested at my own system and only in english so far.

It would be great if you could try it out and tell me if and how it works in different environment.

If you find it useful I would put the user interface thing into some language file.

You can see it working here: Private Test Blog (http://www.uhlig.at/pp_private/).
Login is username & password: friends.

Screenshots of admin area:
PRIVATE in OPTIONS panel
http://www.uhlig.at/tmp/admin_scs1.gif

NEW IMAGE
http://www.uhlig.at/tmp/admin_scs2.gif

IMAGES
http://www.uhlig.at/tmp/admin_scs3.gif

Content of private_readme.txt:PRIVATE ADDON V1.0 beta

DESCRIPTION:
This Addon protects your private photos from being seen by people without
permission.
Private images have an own folder which is protected by .htaccess (username
and password).
Without beeing logged in people should see only the thumbnail of a private
image. Thumbnails are always public.
If unauthorized private_template.html is used for private images instead of
image_template.html.
If authorized image_template.html is used for all photos.

You cannot use 12CropImage for editing thumbnails of private images.
Please install and use FlashCropAddon by Ramin Mehran. A "hacked" version
working correctly with private AND public images is provided in this package.

You can create categories corresponding to private and public. This is not
done automatically.

LIST OF FILES:
-------------------------------------------
admin_private.php - does all the work. Must go into addons folder.
-------------------------------------------
auth.php - the login script. Must go into includes folder.
-------------------------------------------
unauth.php - the logout script. Must go into includes folder.
-------------------------------------------
image_template.html - the template file for public images and authorized
private images (based on simple). Must go into folder templates/simple (or
folder of your template)

# To adjust your favorite image template for use with private addon, just
# replace the path "images/<IMAGE_NAME>" with
# <IMAGE_PATH><IMAGE_NAME>. Place <LOGIN> wherever you want it.
-------------------------------------------
private_template.html - the template file for private images (based on simple).
Must go into folder templates/simple (or folder of your template)

# To adjust any other template for private images, take your favorite
# image_template and replace
# <img src="<IMAGE_PATH><IMAGE_NAME>" alt="<IMAGE_TITLE>" title="<IMAGE_TITLE>" width="<IMAGE_WIDTH>" height="<IMAGE_HEIGHT>" />
# with
# <IMAGE_THUMBNAIL_NO_LINK>

Remove all of the part you don't want to be displayed with private images
(IE <IMAGE_NOTES>, <EXIF_..>data, Permalink, Comments...).
Save it as private_template.html
-------------------------------------------
images_edit.php - two new workspaces generated here. Must go into admin folder.
-------------------------------------------
admin_FlashCropImage.php - added some globals and new workspace. Must go
into addons folder.
-------------------------------------------
imageCrop.swf -
CropImage.php - Both are unchanged files from FlashCropAddon. Located in
folder flash_crop_classes which must go into includes folder.
-------------------------------------------

INSTALL:
Unpack the zip-file.
Copy the files as listed above into your pixelpost directory.

Adjust the private_template.html to your needs.
If you are using Pixelpost Tags from other addons, please look for the
replacement string in the addon.
Copy and paste the tag definition into the list at the beginning of
admin_private.php!
# IE for GeosShowCategory <SC_THUMB_ROW>:
# $tpl = str_replace("<SC_THUMB_ROW>",$sc_thumb_row,$tpl);

Go to pixelpost admin and view OPTIONS new submenu PRIVATE.
First create the folder for your private images (suggest that you leave the
name as it is).
Then create the .htaccess and .htpasswd files with your favorite login data.
Keep the login data in mind or note it somewhere. This is the login data you
are supposed to give to your friends for showing them your private images!

NEW TAGS:
<LOGIN> - a link to the login/logout script.
If not logged in, it is <a href="auth.php">login</a>
If logged in it is <a href="unauth.php">logged in</a>; and the link leads to logout.
<IMAGE_PATH> - the path to the actual image (usually "images/" or "private/").
That is very much needed for telling the template where to find the actual image.
Replace <img src="images/<IMAGE_NAME>"... by <IMAGE_PATH><IMAGE_NAME> in image_template.html

CAUTION:
Only closing the browser will do a real logout.
The addon will work as expected and hide private images when logged out via
the link, but most browsers will keep the authorization and it is still possible to
access directly to the image path via http!

TROUBLESHOOTING:
If the .htaccess thing does not work (the private images are not shown after
logging in or login data is not accepted), you can create .htaccess and
.htpasswd file with any other program and put it into private directory by FTP.

If you choose another name than "private" for your private images, you have
to correct the folder name in auth.php (line 2)

CHANGES MADE IN images_edit.php
## in (original 1.5) line 204 and 205 replace
list($local_width,$local_height,$type,$attr) = getimagesize('../images/'.$image);
$fs = filesize('../images/'.$image);
## with
@list($local_width,$local_height,$type,$attr) = getimagesize('../images/'.$image);
$fs = @filesize('../images/'.$image);
eval_addon_admin_workspace_menu('image_list');

## in (original 1.5) line 300 and 301 replace
list($img_width,$img_height,$type,$attr) = getimagesize('../images/'.$image);
$img_size = filesize('../images/'.$image);
## with
@list($img_width,$img_height,$type,$attr) = getimagesize('../images/'.$image);
$img_size = @filesize('../images/'.$image);
eval_addon_admin_workspace_menu('image_edit_form2' );

## If you do not change images_edit.php, PrivateAddon will work as well, but you will get error messages in IMAGES and IMAGES EDIT because of not found images for filesize function.

CHANGES MADE IN admin_FlashCropImage.php
## in (original 1.0) line 117 REPLACE
global $cfgrow , $txt ,$image, $spacer;
## with
global $cfgrow , $txt ,$image, $spacer, $imagefilename;

in (original 1.0) line 120 FIND
$imagefilename= '../images/'.$image;
## insert after:
eval_addon_admin_workspace_menu('flash_crop');

in (original 1.0) line 151 REPLACE
global $cfgrow ,$filnamn ,$theid,$show_image_after_upload;
## with
global $cfgrow ,$filnamn ,$theid,$show_image_after_upload, $imagefilename;

in (original 1.0) line 156 FIND
$imagefilename= '../images/'.$image;
## insert after:
eval_addon_admin_workspace_menu('flash_crop');