<?php
function helpAbout()
{
?>
<PRE>
///////////////////////////////////////////////////////////////////////////
// GRSlideShow
//
// Author: Yair Bar-On
// Home Page: http://www.grslideshow.com
// Contact: http://www.grslideshow.com/contact
//
// Price: Free. But If you liked this software and want to say thank you,
// you are welcome to send me $19.95 using the Paypal button, on http://www.grslideshow.com
// Thank you very much for your support!
//
// version: 3.3
// Last Update: November 23 2007
//
//
// License: GNU General Public License (GPL)
// Everyone is permitted to copy and distribute this code as described in http://www.opensource.org/licenses/gpl-license.html
//
// What is GRSlideShow? (exmaples can be seen here: http://www.grslideshow.com)
// ====================
//
//
// GRSlideShow is everything you need in order to put your pictures online.
// Put your pictures in different directories, each directory is an album.
// Put the GRSlideShow script in the parent directory of your albums and you're done. Nothing else needed.
// There is much more you can do, you can upload pictures from the web, set descriptions and comments to albums,
// or create new albums, you can add descriptions to pictures, rotate your images or automaticallly resize pictures to reduce bandwith usage.
// You can upload zip files, and have them automatically extracted on the server. The zip flle can be kept in the 'Download'
// section so your friends can download all the pictures for offline browsing and printing.
// You can allow image upload for guests for specific albums, so your friends can upload their stuff as well.
// 'All In One' is the fastest way to see all the pictures on one page, just scroll down, but this is usefull only when your network is fast.
// And of course there is the slideshow where everything started, fade in fade out style slideshow, simple and powerfull.
// The slideshow is quite fast, since the next images are loaded to cache while the current image is displayed.
// You are welcome to contact me for questions and feedback.
//
//
// How to use this class:
// =======================
//
// All the examples below require the following steps:
//
// 1. Put your images in one folder - recommended size is 640X480. This size is configurable.
//
// 2. Make sure that this folder has write permissions, so that thumbnails can be created.
//
// 3. Use one of the examples below...
//
// A demo can be found at http://www.grslideshow.com
// If you are using GRSlideShow, You are more than welcome to send me a link through http://grslideshow.com/contact
// Have Fun !
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//
// Usage Example 1: (Single album)
// ===============================
//
// include ("GRSlideShow.php");
//
// ShowSingleAlbum("/user/pictures/beach_party");
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//
// Usage Example 2: (Multiple albums)
// =====================================================
//
// Use this example when you have multiple slideshows.
// This is the actual code that you should use:
//
// ---------------------------------------------------------
//
// include ("GRSlideShow.php");
//
// AutoGRSlideShow();
//
// ---------------------------------------------------------
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
//
// More examples can be found at http://www.grslideshow.com
// ===============================================================
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Whats new in version 3.3:
// ------------------------
//
// - Added the greatest feature ever - viewers can upload images from your album to myspace,
// Facebook, Blogger, Orkut and many more - uploaded images contain link to your site.
// Upload is made directly from your album. as always, no additional configuration needed.
// - Added an option to print a handout page with thumbnails.
// - Fixed standard issues according to w3c validator.
// - Fixed URLs to be SE compatible.
// - Fied more cosmetic issues, thank you all for your feedback!
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Whats new in version 3.2:
// ------------------------
//
// - Fixed bugs that caused slideshow not to work on some versions of Internet Explorer.
// - Added the 'Fun' button so that users can send images directly to dumpr.net - a great collections of cool image processing toys.
// The dumpr.net toys will be updated from time to time directly on www.grslideshow.com. No upgrade will be needed.
// - added a video section - if slideshow contains video files they are moved to the video section.
// - Fixed a few bugs regarding write permissions on linux.
// - Fixed erros caused by zero sized files.
// - Added an option to run GRSlideShow as part of HTML pages. see the examples page on www.grslideshow.com
// - As always, fixed some cosmetic bugs.
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Whats new in version 3.1:
// ------------------------
//
// - Added the coolest button - print a T shirt with the picture you're watching in just one click!
// - Fixed embedded stylesheet
// - improved admin login page
// - as always fixed many little bugs reported by all of you. Thanks for the input!
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Whats new in version 3.0.3:
// ------------------------
//
// - GRSlideShow Home Page moved to http://www.grslideshow.com - come and see the new examples.
// - Added an option to delete originals.
// - Fixed main menu consmetic bugs
// - Fixed Firefox compatibility issues.
// If you didn't move to firefox yet, It's not too late: http://www.getfirefoxtoday.com
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Whats new in version 3.0.2:
// ------------------------
//
// 1. Added option to sort images by date or by name.
// 2. major bug when working with IE, on some clients - sideshow page could not be opened.
// 3. minor bug in zip extraction.
// 4. minor bug in resize image when image is smaller then recommended.
// 5. bug in default css, no background for image.
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Whats new in version 3.0:
// ------------------------
//
// 1. All the settings can be modified from the web. click on Settings to get the configuration page.
// There is no need to add any definitions manually.
//
// 2. It is possible to divide albums into groups in the main menu.
//
// 3. Many many bug fixes.
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Whats new in version 2.8:
// ------------------------
//
// 1. Slideshow has been improved, images are switched without reloading the page, fade out fade in style.
// While image is viewed, next 3 images are loaded into cache. Speed change done in same page.
//
// 2. Guest Upload per album - if enabled, anyone can upload pictures for this album.
//
// 3. Downlod section was added, original picture can be moved to this section if picture is resized.
//
// 4. Keep Zip - if enabled, zip file are moved to the download section after extraction.
//
// 5. Admin page allows image rename, and move images between albums. album size is shown in admin view
//
// 6. It is possible to configure the order of albums in the main menu.
//
// 7. Error Handling has been impoved, all errors are written to GRSlideshow.log for better debugging.
//
// 8. Added progress indication for http upload.
//
// 9. Added better support for pictures with different ratio (2/3, 3/4).
//
// 10. Improved All In one view - large albums are seperated for 50 pics per page.
//
// 11. some bug fixes....
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Whats new in version 2.7:
// ------------------------
//
// 1. new mode added: View All Pictures. opens all the album picttures in one page.
//
// 2. Added optional tags to the menu template:
// THUMBNAIL - will be replaced with the album representativ thumbnail.
//
// LAST_MODIFIED - Will be replaced with the album last modification date.
//
// NUM_OF_IMAGES - Will be replaced with the album number of images.
//
// 3. "New" albums is limited by MAX_NEW_ALBUMS. By default maximum 3 albums will appear "new".
//
// 4. ENABLE_KEEP_ORIGINAL_IMAGE - The original images can be kept under folder "original".
// clicking on the slideshow image can open the original file in a new window.
//
// 5. Delete picture is possible via web interface.
//
// 6. Number of pictures to upload is configurable - NUM_OF_PICS_ON_UPLOAD.
//
// 7. gif files are supported.
//
// 8. Bug fixes regarding new album, mozilla firefox support, and lots of others.
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Whats new in version 2.6:
// ------------------------
//
// 1. zip files can be automatically extracted if found in slideshow folder.
// In order to automatically use this feature, you will need to have the file Zip.php from
// http://cvs.php.net/pear/Archive_Zip/
//
// 2. Added a basic embedded Stelysheet.
//
// 3. Added a log file.
//
// 4. Default album name is folder name instead of <no-name>
//
// 5. Fixed cosmetic bugs repoted by users.
//
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Whats new in version 2.5:
// ------------------------
//
// 1. Bug Fix: after picture rotate, previous image is still in cache.
// Now rotate image will also change the file name ( 'a' is added to the file name)
//
// 2. Bug fix: Pictures were not sorted. Now pictures are sorted by name.
//
// 3. Bug Fix: Rotate picture in 270 deg was actually 90 deg, and 90 was 270.
//
// 4. Added an option to show back and next buttons on the same side.
//
// 5. Added an option to display file size for every picture.
//
// 6. Limit the number of pictures loaded to cache to 20.
//
// 7. In Admin mode added a 'view' button for each album.
//
// 8. Added an option to disaply a selected tumbnail in the main menu.
//
// 9. Buf Fix - black thumbnail is created if slideshow is running during files upload.
//
// 10. Added an option to a button to the main menu for every album (SHOW_BACK_TO_MAIN_BUTTTON)
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Whats new in version 2.4:
// ------------------------
//
// 1. To reach slideshow admin call your script with paramter ?admin=1.
//
// 2. Security was added to the admin pages. password is configurable.
//
// 3. Rotate Image can be chosen 90,180 or 270 degrees.
//
// 4. Max upload file size is printed on upload form.
//
// 5. bug Fix: upload file was limited to 100K.
//
// 6. Bug Fix: It was not possible to set a picture description with the character '
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Whats new in version 2.3:
// ------------------------
//
// 1. It is possible to manage multiple albums with a single menu. When calling the function AutoGRSlideShow()
// The script will create a slidewhow for every sub folder under current dir.
// Two frames will be created. the left frame contains the menu, and the right frame, contains the slidwshow.
//
// 2. It is posible to create new slideshow through the web interface.
// see usage exmaple 2, and call [your script name]?indexMode=107
//
// 3. It is posisble to add pictures from the web. there is no need in FTP any more.
//
// 4. It is possible to set a description for pictures, and description for albums. (Web Based).
//
// 5. It is possible to rotate images in 90 deg.
//
// 6. It is possible to hide next and previous images by changing the global definitions:
///////////////////////////////////////////////////////////////////////////
// Whats new in version 2.2:
// ------------------------
//
// 1. The slideshow works with a stylesheet. This way it is mych easier to change the
// colors, font, and look of your photo album.
// A default stylesheet is attahced to the project, it is recommended to change it.
// The world will be boring if everybody will use the same stylesheet...
//
// 2. Added option to call a main script with folder name. see Usage Example 5.
//
// 3. Added an option to have the global settings in a seperate file, this makes the updates easier.
//
// 4. Fixed cookie support for slideshow speed.
//
// 5. Added support for images with ratio different then 4:3 (like 800x550 instead of 800x600)
//
// 6. Fixed cosmetic bugs.
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// Whats new in version 2.1:
// ------------------------
//
// 1. The main feature - there is no need to manually create tumbnails any more.
// The slideshow will create the tumbnails on the first time it is running,
// and keep them on the disk for the next times.
// This will only work if writing permissions are available, and the GD library
// is enabled.
//
// 2. A seperate set of thumbnails will be created for the slideshow thumbnails -
// the ones that are shown on the first page, and the slide humbnails - the ones
// that are shown near the "next or "back" bottons in the manual slideshow.
// This was done just to make these tumbnails look a little better...
//
// 3. When creating a slideShow from a whole folder it is now possible to add
// description to the pictures in the folder.
//
// 4. It is possible to change the default pictures or thumbnails folder so that multiple
// slideshows can include the same slidehow script.
//
// 5. It is possible to create a slideshow both from folders and pictures.
//
// 6. There is no need to indicate if a picture is horizontal or vertical,
// the slideshow will identify that automaticaly.
//
// 7. No backward compatinility guarantied. this backward compatibility made
// the code so complicated that I had to clean it a little...
//
// 8. It is possible to create the slidehsow with a single function - CreateSlideShowFromFolderAndGo.
//
// 9. Fixed some more Windows compatibility problems.
//
///////////////////////////////////////////////////////////////////////////
// Whats new in version 2.0:
// ------------------------
//
// 1. Fixed bugs regrading compatibility for web servers running on Windows.
//
// 2. improved performance - when watching an image, the next image is downloaded in the background
// and chached. This way, when moving to the next image it is shown right away.
// This is also done when viewing the page in index mode. after all the thumbnails are loaded,
// the real pictures are downloaded to the cache.
// Images are not cached in slideshow mode, since it ruins the timing of the slidehsow.
//
// 3. fixed some cosmetic bugs.
//
// 4. Interface changed, see usage example. old interface still supported.
//
///////////////////////////////////////////////////////////////////////////
<?php
//echo "<pre>";
//print_r($_SERVER);
//phpInfo();
} // end of helpAbout functiuon.
//////////////////////////////////////////
// //
// Global definitions //
// //
//////////////////////////////////////////
error_reporting(error_reporting()|E_NOTICE);
define('SETTINGS_FILE','GRSlideShowConfig.php');
if (file_exists(SETTINGS_FILE))
{
include SETTINGS_FILE;
}
/*
an external settings file is optional.
This is useful when 2 folders are running a slideshow and include the same slideshow clss,
When using an external settings file, each slideshow can have a different stylesheet, or password or anything else.
This is optional, you son't have to use it.
*/
if (file_exists("GRSlideShowSettings.inc.php"))
{
include "GRSlideShowSettings.inc.php";
}
elseif (file_exists("../GRSlideShowSettings.inc.php"))
{
include "GRSlideShowSettings.inc.php";
}
elseif (file_exists("GRSlideShowSettings.php"))
{
include "GRSlideShowSettings.php";
}
elseif (file_exists("../GRSlideShowSettings.php"))
{
include "GRSlideShowSettings.php";
}
define('DEFAULT_STYLESHEET',
"<style TYPE='text/css'>\n".
"<!--\n".
"a {color: Black;}\n".
".Pictures { BACKGROUND-COLOR: #b6c5f2}\n".
".PicturesM { BACKGROUND-COLOR: #b6c5f2}\n".
".formbttn { BORDER-RIGHT: black 2px solid; BORDER-TOP: white 1px solid; FONT-WEIGHT: bold; FONT-SIZE: 11px; BACKGROUND: #6633CC; BORDER-LEFT: white 1px solid; CURSOR: hand; COLOR: white; BORDER-BOTTOM: black 2px solid; FONT-FAMILY: verdana, arial, helvetica, sans-serif; HEIGHT: 19px; TEXT-DECORATION: none }\n".
".formbttn1 { BORDER-RIGHT: #6666CC 2px solid; BORDER-TOP: white 1px solid; FONT-WEIGHT: bold; FONT-SIZE: 11px; BACKGROUND: #AEAFFF; BORDER-LEFT: white 1px solid; CURSOR: hand; COLOR: black; BORDER-BOTTOM: #6666CC 2px solid; FONT-FAMILY: verdana, arial, helvetica, sans-serif; HEIGHT: 19px; TEXT-DECORATION: none}\n".
".formbttn2 { BORDER-RIGHT: #D9D908 2px solid; BORDER-TOP: white 1px solid; FONT-WEIGHT: bold; FONT-SIZE: 11px; BACKGROUND: #FFFFCA; BORDER-LEFT: white 1px solid; CURSOR: hand; COLOR: black; BORDER-BOTTOM: #D9D908 2px solid; FONT-FAMILY: verdana, arial, helvetica, sans-serif; HEIGHT: 19px; TEXT-DECORATION: none}\n".
".groupbttn { BORDER-RIGHT: #D9D908 2px solid; BORDER-TOP: white 1px solid; FONT-WEIGHT: bold; FONT-SIZE: 11px; BACKGROUND: #FFFFCA; BORDER-LEFT: white 1px solid; CURSOR: hand; COLOR: black; BORDER-BOTTOM: #D9D908 2px solid; FONT-FAMILY: verdana, arial, helvetica, sans-serif; HEIGHT: 19px; TEXT-DECORATION: none}\n".
".newLink { BORDER-RIGHT: #D9D908 2px solid; BORDER-TOP: white 1px solid; FONT-WEIGHT: bold; FONT-SIZE: 11px; BACKGROUND: #FFFFCA; BORDER-LEFT: white 1px solid; CURSOR: hand; COLOR: black; BORDER-BOTTOM: #D9D908 2px solid; FONT-FAMILY: verdana, arial, helvetica, sans-serif; HEIGHT: 19px; TEXT-DECORATION: none}\n".
".title {COLOR: blue}\n".
".text {padding:5px; font:11px verdana, arial, helvetica, sans-serif;}\n".
".text2 {margin:0px 0px 10px 0px; padding:5px; background-color:#AEAFFF; border:1px solid #FFFFFF; font:11px verdana, arial, helvetica, sans-serif;} \n".
".main_menu_header {COLOR: blue FONT-SIZE: 11px;}\n".
"-->\n".
"</style>");
define('TEST_STYLESHEET',
"<style TYPE='text/css'>\n".
"<!--\n".
"a {color: Black;}\n".
".test1 {display:none;visibility:hidden;}\n".
".grslideshow_link {COLOR: blue; FONT-SIZE: 10px;}\n".
"-->\n".
"</style>");
if (file_exists("GRSlideShow.css") && (!defined ("STYLESHEET_FILE_NAME") || 0== strlen(STYLESHEET_FILE_NAME)))
{
define ("STYLESHEET_FILE_NAME","GRSlideShow.css");
}
if (defined ("STYLESHEET_FILE_NAME") && strlen(STYLESHEET_FILE_NAME))
{
define("STYLE_HEADER","<LINK href='".STYLESHEET_FILE_NAME."' rel=stylesheet type=\"text/css\">");
}
else
{
if (!defined("STYLE_HEADER"))
define("STYLE_HEADER",DEFAULT_STYLESHEET);
}
/***************************************************************
HTML misc:
***************************************************************/
if (!defined('CONTENT_TYPE'))
define('CONTENT_TYPE','');
if (!defined('HTML_HEADERS'))
define('HTML_HEADERS','' . CONTENT_TYPE);
if (!defined ('IMAGE_PAGE_ALIGNMENT'))
define ('IMAGE_PAGE_ALIGNMENT',"left");
if (!defined("MAIN_MENU_ALIGNMENT"))
define("MAIN_MENU_ALIGNMENT","left");
if (!defined("INDEX_ALIGNMENT"))
define("INDEX_ALIGNMENT","center");
if (!defined("ALL_IN_ONE_ALIGNMENT"))
define("ALL_IN_ONE_ALIGNMENT","left");
if (!defined("FRAMESET_COLS"))
define("FRAMESET_COLS","12%,*");
if (!defined("HTML_TAG"))
//define("HTML_TAG","<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n<html>");
define("HTML_TAG","<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" \"http://www.w3.org/TR/html4/loose.dtd\">");
if (!defined("NAME_OF_MAIN_FRAME"))
define("NAME_OF_MAIN_FRAME",'main');
if (!defined("FRAME_MENU_POSITION"))
define("FRAME_MENU_POSITION",'left');
/***************************************************************
features:
***************************************************************/
/*
What is MENU_LINK and NEW_MENU_LINK ?
When the main menu is created, every subfolder under the slideshow root folder is considered an album.
The template MENU_LINK is used to configure the appearence of the main menu links.
The most basic menu link looks like that: "<a href='<LINK>'><TITLE></a>"
When creating the menu the string <LINK> will be replaced with the url to the album index,
and the <TITLE> will be replaced with the album name if exists, or the folder name.
Other optional tags are:
<THUMBNAIL> - will be replaced with the selected thumbnail from album
example: define("MENU_LINK","<a href='<LINK>'><img src='<THUMBNAIL>'><TITLE></a>")
<LAST_MODIFIED> - Will be replaced with the last modification date of this album.
example: define("MENU_LINK","<a href='<LINK>'><img src='<THUMBNAIL>'><TITLE> last modified on <THUMBNAIL></a>")
<MAIN_FRAME> - Will be replaced with the name of the main frame as defined in NAME_OF_MAIN_FRAME
example: define("MENU_LINK","<a href='<LINK>' target='<MAIN_FRAME>'><img src='<THUMBNAIL>'><TITLE> last modified on <THUMBNAIL></a>")
<NUM_OF_IMAGES> - Will be replaced with the number of images in album
example: define("MENU_LINK","<a href='<LINK>'><TITLE> (contains <NUM_OF_IMAGES> pictures)</a>")
Why are there MENU_LINK and NEW_MENU_LINK ?
a new album is an album that was maked as "new" and was never visited by this user,
or has changed since the last time the user saw it.
example (adding new.gif ):
define("NEW_MENU_LINK","<a href='<LINK>'><img src='<THUMBNAIL>'><TITLE><img src=new.gif></a>")
*/
if (!defined ("DEMO_MODE"))
define ("DEMO_MODE",0);
// The password for the admin page.
if (!defined ("ADMIN_PASSWORD"))
define ("ADMIN_PASSWORD","1234");
if (!defined('RESIZE_ORIGINAL_PICTURE'))
define('RESIZE_ORIGINAL_PICTURE','0');
if (!defined("CHMOD_UPLOADED_IMAGE"))
define("CHMOD_UPLOADED_IMAGE",0);
if (!defined("MAX_PICTURES_IN_CACHE"))
define("MAX_PICTURES_IN_CACHE",20);
if (!defined("SECURITY_ENABLED"))
define("SECURITY_ENABLED",0);
if (!defined("ENABLE_LOG"))
define("ENABLE_LOG",0);
if (!defined("EXTRACT_ZIP_FILES"))
define("EXTRACT_ZIP_FILES",1);
if (!defined("KEEP_ZIP_FILES"))
define("KEEP_ZIP_FILES",1);
if(!defined('ENABLE_KEEP_ORIGINAL_IMAGE'))
define('ENABLE_KEEP_ORIGINAL_IMAGE',1);
if(!defined('MAX_NEW_ALBUMS'))
define('MAX_NEW_ALBUMS',3);
if(!defined('LAST_MODIFIED_DATE_FORMAT'))
define('LAST_MODIFIED_DATE_FORMAT','%d.%m.%y');
//"%e %b %Y"
if (!defined("CREATE_INDEX_FOR_SUBFOLDER"))
define("CREATE_INDEX_FOR_SUBFOLDER",1);
define ("DOCTYPE","<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\" >");
/***************************************************************
numeric consts:
***************************************************************/
define("MODE_UNKNOWN",999);
define("MODE_SLIDE_SHOW",100);
define("MODE_SINGLE_SLIDE",101);
define("MODE_INDEX",102);
define("MODE_MENU",104);
define("MODE_MAIN_FRAME",105);
define("MODE_BLANK",106);
define("MODE_FOLDER_MNG",107);
define("MODE_EDIT_ALBUM",108);
define("MODE_NEW_ALBUM",109);
define("MODE_UPDATE_ALBUM",110);
define("MODE_UPLOAD_PICTURES",111);
define("MODE_CHOOSE_PICTURES",112);
define("MODE_ROTATE_PICTURE",113);
define("MODE_LOG",114);
define("MODE_ORDER_LIST",115);
define("MODE_ORDER_UPDATE",116);
define("MODE_ABOUT",117);
define("MODE_DELETE_PICTURE",118);
define("MODE_VIEW_ALL",119);
define("MODE_MOVE_PICTURE",120);
define("MODE_REORDER_ALBUMS",121);
define("MODE_UPDATE_ALBUMS_ORDER",122);
define("MODE_GUEST_CHOOSE_PICTURES",123);
define("MODE_GUEST_UPLOAD",124);
define("MODE_DOWNLOAD",125);
define("MODE_SETTINGS",126);
define("MODE_UPDATE_SETTINGS",127);
define("MODE_ORDER_PICTURE",128);
define("MODE_DELETE_ALBUM",129);
define("MODE_UPDATE_ALBUM_BACK_TO_MAIN",130);
define("MODE_UPDATE_SETTINGS_BACK_TO_MAIN",131);
define("MODE_DELETE_ORIGINALS",132);
define("MODE_LOGOUT",133);
define("MODE_VIDEO",134);
define("MODE_HANDOUT",135);
define("MODE_CREDIT",136);
if (!defined("DEFAULT_AUTO_MODE"))
define("DEFAULT_AUTO_MODE",104);
/***************************************************************
string table:
***************************************************************/
define ("COOKIE_NAME_SPEED","slideshowspeed");
define('TAG_MODE','m');
define('OLD_TAG_MODE','indexMode');
define('TAG_IMAGE_NUMBER','n');
define('TAG_IMAGE_NUMBER_SINGLE_SLIDE','n1');
define('TAG_SPEED','s');
define('TAG_FOLDER','folder');
define('TAG_NEW_FOLDER','newfolder');
define('TAG_ALBUM_NAME','album_name');
define('TAG_ALBUM_GROUP','album_group');
define('TAG_ALBUM_DESCRIPTION','album_description');
define('TAG_DISABLED','disabled');
define('TAG_FILE_DESCRIPTION','file_description_');
define('TAG_PICTURE_NAME','picture_name');
define('TAG_NEW_PICTURE_NAME','newpicturename');
define('TAG_PASSWORD','password');
define('TAG_REMEMBER_PASSWORD','rem_password');
define('TAG_SCRIPT_NAME','script');
define('TAG_ADMIN','admin');
define('TAG_ABOUT','about');
define('TAG_LOG','log');
define('TAG_MENU_THUMBNAIL','menu_thumbnail');
define('TAG_NEW','new');
define('TAG_GUEST_UPLOAD','guestupload');
define('TAG_USER','u');
define('TAG_MUSIC_FILE','music_file');
define('ROTATE_ANGEL','rotateangel');
define('ROTATE_NEW','new');
if (!defined('NEW_ALBUM_SIGN'))
define('NEW_ALBUM_SIGN','New!');
if (!defined('THIS_ALBUM'))
define('THIS_ALBUM','Index');
/***************************************************************
page design:
***************************************************************/
if (!defined('IMAGE_OPACITY_ENABLED'))
define('IMAGE_OPACITY_ENABLED',1);
// the default dimensions of a picture.
if (!defined ("PICTURE_V_SIZE"))
define ("PICTURE_V_SIZE", 640);
if (!defined ("PICTURE_H_SIZE"))
define ("PICTURE_H_SIZE", 480);
// the default dimensions of a thumbnails in the index page.
if (!defined ("THUMBNAIL_V_SIZE"))
define ("THUMBNAIL_V_SIZE",75);
if (!defined ("THUMBNAIL_H_SIZE"))
define ("THUMBNAIL_H_SIZE",100);
// the default dimensions of a thumbnails in the slide page.
if (!defined ("SLIDE_THUMBNAIL_V_SIZE"))
define ("SLIDE_THUMBNAIL_V_SIZE",61);
if (!defined ("SLIDE_THUMBNAIL_H_SIZE"))
define ("SLIDE_THUMBNAIL_H_SIZE",81);
// the number of thumbnails in every row in the index page.
if (!defined("NUMBER_OF_TUMBNAILS_IN_INDEX_ROW"))
define("NUMBER_OF_TUMBNAILS_IN_INDEX_ROW",4);
// specifies whether thumbails will be dispalyed near the main picture during automatic slidehsow.
if (!defined('DISPLAY_SIDE_IMAGES_IN_SLIDE_SHOW'))
define('DISPLAY_SIDE_IMAGES_IN_SLIDE_SHOW',1);
// specifies whether thumbails will be dispalyed near the main picture during manual slidehsow.
if (!defined('DISPLAY_SIDE_IMAGES_IN_SINGLE_SLIDE'))
define('DISPLAY_SIDE_IMAGES_IN_SINGLE_SLIDE',1);
// specifies whether next and back buttons will be dispalyed near the main picture during automatic slidehsow.
if (!defined('DISPLAY_NEXT_BACK_IN_SLIDE_SHOW'))
define('DISPLAY_NEXT_BACK_IN_SLIDE_SHOW',1);
// specifies whether next and back buttons will be dispalyed near the main picture during manual slidehsow.
if (!defined('DISPLAY_NEXT_BACK_IN_SINGLE_SLIDE'))
define('DISPLAY_NEXT_BACK_IN_SINGLE_SLIDE',1);
if (!defined('MAX_NUM_OF_IMAGES_IN_ALL_IN_ONE'))
define('MAX_NUM_OF_IMAGES_IN_ALL_IN_ONE',50);
if (!defined('MAX_NUM_OF_IMAGES_IN_INDEX'))
define('MAX_NUM_OF_IMAGES_IN_INDEX',100);
if (!defined("DISPLAY_FILE_SIZE"))
define("DISPLAY_FILE_SIZE",0);
if (!defined("NUMBER_OF_ITEMS_IN_MENU_ROW"))
define("NUMBER_OF_ITEMS_IN_MENU_ROW",1);
if (!defined("SHOW_BACK_TO_MAIN_BUTTTON"))
define("SHOW_BACK_TO_MAIN_BUTTTON",1);
if (!defined("SHOW_EXIT_BUTTTON_IN_INDEX_PAGE"))
define("SHOW_EXIT_BUTTTON_IN_INDEX_PAGE",0);
if (!defined("SHOW_EXIT_BUTTTON_IN_IMAGE_PAGE"))
define("SHOW_EXIT_BUTTTON_IN_IMAGE_PAGE",0);
if (!defined("MAIN_MENU_TITLE"))
define("MAIN_MENU_TITLE","");
if (!defined("INDEX_PAGE_TITLE"))
define("INDEX_PAGE_TITLE","");
if (!defined("BLANK_PAGE_TITLE"))
define("BLANK_PAGE_TITLE","");
/***************************************************************
main menu:
***************************************************************/
if (!defined("ENABLE_ALBUMS_GROUPS"))
define("ENABLE_ALBUMS_GROUPS",0);
if (!defined("AUTO_GROUP_NAME"))
define("AUTO_GROUP_NAME",0);
if (!defined('ALL_GROUPS_VISIBLE'))
define('ALL_GROUPS_VISIBLE',0);
if (!defined('SHOW_GROUP_NAME_AS_BUTTON'))
define('SHOW_GROUP_NAME_AS_BUTTON',1);
if (!defined('MAIN_MENU_ALIGN'))
define('MAIN_MENU_ALIGN','');
if (!defined('SEPERATOR_BELOW_GROUP'))
define('SEPERATOR_BELOW_GROUP',0);
if (!defined("GENERAL_ALINGMENT"))
define("GENERAL_ALINGMENT","left");
if (!defined("ALWAYS_SHOW_FIRST_GROUP"))
define("ALWAYS_SHOW_FIRST_GROUP",1);
if (!defined("OPEN_ALBUM_IN_NEW_WINDOW"))
define("OPEN_ALBUM_IN_NEW_WINDOW",0);
if (!defined("USE_THUMBNAILS_IN_MAIN_MENU"))
define("USE_THUMBNAILS_IN_MAIN_MENU",1);
if (!defined("DISPLAY_ALBUM_NAME_IN_MAIN_MENU"))
define("DISPLAY_ALBUM_NAME_IN_MAIN_MENU",1);
if (!defined("MARK_NEW_ALBUMS"))
define("MARK_NEW_ALBUMS",1);
/***************************************************************
file names:
***************************************************************/
if (!defined('ALBUM_DESCRIPTOR'))
define('ALBUM_DESCRIPTOR','GRSlideShow_description.txt');
if (!defined("LOG_FILE_NAME"))
define("LOG_FILE_NAME","./GRSlideShow.log");
/***************************************************************
others:
***************************************************************/
if (!defined('DEFAULT_SORT'))
define('DEFAULT_SORT','name');
if (!defined('POPUP_SCRIPT'))
define('POPUP_SCRIPT','');
if (!defined('MENU_FOOTER'))
define('MENU_FOOTER',"Click here to see our old pictures");
if (!defined('MENU_FOOTER_HREF'))
define('MENU_FOOTER_HREF',"");
if (!defined('ENABLE_GUEST_UPLOAD'))
define('ENABLE_GUEST_UPLOAD',1);
// the number of pictures to upload in
if (!defined('NUM_OF_PICS_ON_UPLOAD'))
define('NUM_OF_PICS_ON_UPLOAD',18);
//determine whether the main picture should have width and height specification.
// by default the main image will have width and height in the <img> tag.
if (!defined('IGNORE_MAIN_IMAGE_WIDTH_HEIGHT'))
define('IGNORE_MAIN_IMAGE_WIDTH_HEIGHT',0);
if (!defined('GMT_DIFF'))
define('GMT_DIFF',0);
if (!defined('ENABLE_HEBREW_RTL'))
define('ENABLE_HEBREW_RTL',0);
if (!defined('SET_NEW_ALBUM_TO_ENABLE_GUEST_UPLOAD'))
define('SET_NEW_ALBUM_TO_ENABLE_GUEST_UPLOAD',0);
if (!defined('AUTO_NEW_FOLDER_NAME'))
define('AUTO_NEW_FOLDER_NAME',1);
if (!defined('SHOW_IMAGE_RATIO'))
define('SHOW_IMAGE_RATIO',0);
if (!defined('NEXT_THUMBNAIL_POSITION'))
define('NEXT_THUMBNAIL_POSITION','left');
if (!defined('PREV_THUMBNAIL_POSITION'))
define('PREV_THUMBNAIL_POSITION','left');
if (!defined('ENABLE_MUSIC'))
define('ENABLE_MUSIC',0);
function myErrorHandler($errno, $errstr, $errfile, $errline)
{
if (ENABLE_LOG!=1)
return;
echo "<b>ERROR</b>: see ".LOG_FILE_NAME." for details.<br/>";
myLog("ERROR:***********");
myLog("file:=$errfile");
myLog("line:$errline");
myLog("errno: $errno");
myLog("errstr: $errstr");
myLog("***********");
}
if (!defined('LOG_ALL_ERRORS'))
define('LOG_ALL_ERRORS',1);
if (LOG_ALL_ERRORS == 1)
{
set_error_handler("myErrorHandler");
}
/*********************************************************
general settings:
**********************************************************/
define('SETTINGS_CATEGORY_FILE_HANDELING','File Handeling');
define('SETTINGS_CATEGORY_MAIN_MENU','Main Menu Page');
define('SETTINGS_CATEGORY_IMAGE_PAGE','Image Page');
define('SETTINGS_CATEGORY_SECURITY','Security');
define('SETTINGS_CATEGORY_GENERAL','General');
define('SETTINGS_CATEGORY_ALL_IN_ONE','All In One Page');
define('SETTINGS_CATEGORY_INDEX','Index Page');
$settingsParams = array();
$settingsParams[SETTINGS_CATEGORY_SECURITY][] = new SettingParam( 'SECURITY_ENABLED',
'checkbox',
'Enable Security',
"Require password for all administrative pages.");
$zipDescription = 'Zip Files will be extracted if found in album folder.';
if (!file_exists("Zip.php"))
{
$zipDescription = $zipDescription . "<br/>ATTENTION: The file Zip.php does not exist. This file is required for Zip files extraction.<br/>".
"The original file can be found here: <a target='_blank' href='http://cvs.php.net/pear/Archive_Zip/'>http://cvs.php.net/pear/Archive_Zip/</a><br/>".
"A modified version can be found here: <a target='_blank' href='http://www.grslideshow.com'>http://www.grslideshow.com</a><br/>".
"The file should be saved in GRSlideShow root directory.";
}
$settingsParams[SETTINGS_CATEGORY_FILE_HANDELING][] = new SettingParam( 'EXTRACT_ZIP_FILES',
'checkbox',
'Extract Zip Files',
$zipDescription);
$settingsParams[SETTINGS_CATEGORY_FILE_HANDELING][] = new SettingParam( 'KEEP_ZIP_FILES',
'checkbox',
'Keep Zip Files after extraction',
'Zip files will be kept in the download area after extraction.');
$settingsParams[SETTINGS_CATEGORY_MAIN_MENU][] = new SettingParam( 'ENABLE_ALBUMS_GROUPS',
'checkbox',
'Enable Album Groups',
"Every Album belongs to a group. In the main menu, albums are divided to groups. ");
$settingsParams[SETTINGS_CATEGORY_MAIN_MENU][] = new SettingParam( 'NUMBER_OF_ITEMS_IN_MENU_ROW',
'text',
'Number of Albums in a row',
"The number of albums in every row in the main menu. ");
$settingsParams[SETTINGS_CATEGORY_INDEX][] = new SettingParam( 'DEFAULT_SORT',
'select',
"Sort images according to",
"Determins whher images wil be sorted by name of by file date.",
array("name","date")
);
$settingsParams[SETTINGS_CATEGORY_INDEX][] = new SettingParam( 'MAX_NUM_OF_IMAGES_IN_INDEX',
'text',
"Number of thumbnails in index page",
"Index page will be divided to pages contains this amount of thumbnails.<br/>".
"Next and Previous Page buttons will be available."
);
$settingsParams[SETTINGS_CATEGORY_INDEX][] = new SettingParam( 'NUMBER_OF_TUMBNAILS_IN_INDEX_ROW',
'text',
"Number of thumbnails in a row of index page",
"every row in the Index page will have this amount of thumbnails"
);
$settingsParams[SETTINGS_CATEGORY_INDEX][] = new SettingParam( 'MAX_PICTURES_IN_CACHE',
'text',
'Number of images in cache',
"The number of images that will be loaded to cache when the index page is opened. <br/>This will make the slideshow run faster..");
$settingsParams[SETTINGS_CATEGORY_INDEX][] = new SettingParam( 'SHOW_EXIT_BUTTTON_IN_INDEX_PAGE',
'checkbox',
"Show Exit button",
"Show 'Exit' button that closes the active window."
);
$settingsParams[SETTINGS_CATEGORY_IMAGE_PAGE][] = new SettingParam( 'SHOW_BACK_TO_MAIN_BUTTTON',
'checkbox',
"Show main menu button",
"The main menu button will be visible during slideshow and on all index pages.");
$settingsParams[SETTINGS_CATEGORY_FILE_HANDELING][] = new SettingParam( 'RESIZE_ORIGINAL_PICTURE',
'checkbox',
'Resize original image',
"Images larger then " .PICTURE_V_SIZE . "x" . PICTURE_H_SIZE . " will be resized to this size.<br/>This size can be configured in the Image Page section.");
$settingsParams[SETTINGS_CATEGORY_FILE_HANDELING][] = new SettingParam( 'ENABLE_KEEP_ORIGINAL_IMAGE',
'checkbox',
'Keep original image',
"In case image is resized, the original copy will be kept in the download area.");
$settingsParams[SETTINGS_CATEGORY_SECURITY][] = new SettingParam( 'ADMIN_PASSWORD',
'text',
'Administrator Password',
"The password for all the administration pages.");
$settingsParams[SETTINGS_CATEGORY_ALL_IN_ONE][] = new SettingParam( 'MAX_NUM_OF_IMAGES_IN_ALL_IN_ONE',
'text',
"Number of Images in 'All In One' Page"
);
$settingsParams[SETTINGS_CATEGORY_IMAGE_PAGE][] = new SettingParam( 'DISPLAY_FILE_SIZE',
'checkbox',
"Display File Size",
"Display File size of viewed image during slide show."
);
$settingsParams[SETTINGS_CATEGORY_SECURITY][] = new SettingParam( 'ENABLE_GUEST_UPLOAD',
'checkbox',
"Enable Guest Upload",
"Anyone can add pictures to albums that are guest upload enabled."
);
$settingsParams[SETTINGS_CATEGORY_GENERAL][] = new SettingParam( 'GMT_DIFF',
'text',
"Time Difference",
"This value sets the offset in seconds between GMT time and local time.<br/>".
"GMT time is ".gmstrftime("%H:%M:%S",time()).";<br/>".
"With Time Difference ".GMT_DIFF.", ".
"current local time is ".gmstrftime("%H:%M:%S",getLocalTime())."."
);
$settingsParams[SETTINGS_CATEGORY_IMAGE_PAGE][] = new SettingParam( 'PICTURE_V_SIZE',
'text',
"Main Image width"
);
$settingsParams[SETTINGS_CATEGORY_IMAGE_PAGE][] = new SettingParam( 'PICTURE_H_SIZE',
'text',
"Main Image height"
);
$settingsParams[SETTINGS_CATEGORY_IMAGE_PAGE][] = new SettingParam( 'IGNORE_MAIN_IMAGE_WIDTH_HEIGHT',
'checkbox',
"Display Main Image 'As Is'",
"Images are dispalyed in their actual size, ignoring Main Image width and height settings.");
$settingsParams[SETTINGS_CATEGORY_IMAGE_PAGE][] = new SettingParam( 'SLIDE_THUMBNAIL_V_SIZE',
'text',
"Side Thumbnail height",
"The height of the next and previous thumbnails displayed near the main image"
);
$settingsParams[SETTINGS_CATEGORY_IMAGE_PAGE][] = new SettingParam( 'SLIDE_THUMBNAIL_H_SIZE',
'text',
"Side Thumbnail width",
"The width of the next and previous thumbnails displayed near the main image"
);
$settingsParams[SETTINGS_CATEGORY_IMAGE_PAGE][] = new SettingParam( 'DISPLAY_SIDE_IMAGES_IN_SLIDE_SHOW',
'checkbox',
"Display thumbnails during slideshow",
"Display the thumbnail of next and previous images when slideshow is running."
);
$settingsParams[SETTINGS_CATEGORY_IMAGE_PAGE][] = new SettingParam( 'DISPLAY_SIDE_IMAGES_IN_SINGLE_SLIDE',
'checkbox',
"Display thumbnails when slideshow is off",
"Display the thumbnail of next and previous images when slideshow is not running."
);
$settingsParams[SETTINGS_CATEGORY_IMAGE_PAGE][] = new SettingParam( 'DISPLAY_NEXT_BACK_IN_SLIDE_SHOW',
'checkbox',
"Display next and back buttons during slideshow",
"Display the next and back buttons when slideshow is not running."
);
$settingsParams[SETTINGS_CATEGORY_IMAGE_PAGE][] = new SettingParam( 'DISPLAY_NEXT_BACK_IN_SINGLE_SLIDE',
'checkbox',
"Display next and back buttons when slideshow is off",
"Display the next and back buttons when slideshow is not running."
);
$settingsParams[SETTINGS_CATEGORY_IMAGE_PAGE][] = new SettingParam( 'NEXT_THUMBNAIL_POSITION',
'select',
"Next Thumbnail Position",
"The position of the next thumbnail.",
array("left","right")
);
$settingsParams[SETTINGS_CATEGORY_IMAGE_PAGE][] = new SettingParam( 'PREV_THUMBNAIL_POSITION',
'select',
"Previous Thumbnail Position",
"The position of the previous thumbnail.",
array("left","right")
);
$settingsParams[SETTINGS_CATEGORY_IMAGE_PAGE][] = new SettingParam( 'IMAGE_PAGE_ALIGNMENT',
'select',
"Alignment",
"The alignment of the image Page.",
array("left","center","right")
);
$settingsParams[SETTINGS_CATEGORY_IMAGE_PAGE][] = new SettingParam( 'SHOW_EXIT_BUTTTON_IN_IMAGE_PAGE',
'checkbox',
"Show Exit button",
"Show 'Exit' button that closes the active window."
);
$settingsParams[SETTINGS_CATEGORY_MAIN_MENU][] = new SettingParam( 'MAIN_MENU_ALIGNMENT',
'select',
"Alignment",
"The alignment of the main menu.",
array("left","center","right")
);
$settingsParams[SETTINGS_CATEGORY_MAIN_MENU][] = new SettingParam( 'AUTO_GROUP_NAME',
'checkbox',
"Auto Group Name",
"In case group name is empty, the first 4 charcters of directory name will be used as group name."
);
/* if (!defined("MENU_LINK"))
$settingsParams[SETTINGS_CATEGORY_MAIN_MENU][] = new SettingParam( 'OPEN_ALBUM_IN_NEW_WINDOW',
'checkbox',
"Open Album in New Window",
"Albums will be opened in a new window, in full screen mode.".
"<br/> If this option is chosen, it is recommended to turn on the exit button options, so that users will be able to easily close the album window"
);
*/
if (!defined("MENU_LINK"))
$settingsParams[SETTINGS_CATEGORY_MAIN_MENU][] = new SettingParam( 'USE_THUMBNAILS_IN_MAIN_MENU',
'checkbox',
"Use Thumbnails in Main Menu",
"Turn this on in order to have a thumbnail for every Album in the main menu. "
);
if (!defined("MENU_LINK"))
$settingsParams[SETTINGS_CATEGORY_MAIN_MENU][] = new SettingParam( 'DISPLAY_ALBUM_NAME_IN_MAIN_MENU',
'checkbox',
"Display Album Name in Main Menu",
"Turn this on in order to have the album name for every Album in the main menu. "
);
$settingsParams[SETTINGS_CATEGORY_MAIN_MENU][] = new SettingParam( 'MARK_NEW_ALBUMS',
'checkbox',
"Mark Unviewed Albums",
"Albums that were never opened, or have changed from the last time they were opened can be displayed with a different style, <br/>".
"and also a 'new' icon next to the album name. A 'Last Modified indication will be added to the album name as well.<br/>".
"This can be configured per album, whether this feature is active or not."
);
if (!defined("MENU_LINK"))
$settingsParams[SETTINGS_CATEGORY_MAIN_MENU][] = new SettingParam( 'NEW_ALBUM_SIGN',
'text',
"New Album Sign",
"This will be added to the album name, in case the album was changed from the last time it was opened. ".
"<br/>It is possible to put html tags or images such as <img src='new.gif'> or <b>New!!!</b>",
null,
50
);
$settingsParams[SETTINGS_CATEGORY_INDEX][] = new SettingParam( 'INDEX_ALIGNMENT',
'select',
"Alignment",
"The alignment of the index page.",
array("left","center","right")
);
$settingsParams[SETTINGS_CATEGORY_INDEX][] = new SettingParam( 'THUMBNAIL_H_SIZE',
'text',
"Thumbnail width",
"The width of thumbnail in the index page.");
$settingsParams[SETTINGS_CATEGORY_INDEX][] = new SettingParam( 'THUMBNAIL_V_SIZE',
'text',
"Thumbnail height",
"The height of thumbnail in the index page.");
$settingsParams[SETTINGS_CATEGORY_ALL_IN_ONE][] = new SettingParam( 'ALL_IN_ONE_ALIGNMENT',
'select',
"Alignment",
"The alignment of 'All In One' page.",
array("left","center","right")
);
$settingsParams[SETTINGS_CATEGORY_GENERAL][] = new SettingParam( 'STYLESHEET_FILE_NAME',
'text',
'Stylesheet file Name',
"The stylesheet that will be used by GRSlideShow. Leave this field empty to use the default stylesheet.");
$settingsParams[SETTINGS_CATEGORY_GENERAL][] = new SettingParam( 'CONTENT_TYPE',
'text',
'Additional HTML Headers',
"",
null,
100);
$settingsParams[SETTINGS_CATEGORY_GENERAL][] = new SettingParam( 'ENABLE_LOG',
'checkbox',
'Enable Log',
"All actions will be saved in log file.");
$settingsParams[SETTINGS_CATEGORY_GENERAL][] = new SettingParam( 'LOG_FILE_NAME',
'text',
'Log File Name'
);
$settingsParams[SETTINGS_CATEGORY_GENERAL][] = new SettingParam( 'LOG_ALL_ERRORS',
'checkbox',
'Log Runtime errors',
"All runtime errors will be written to the log file. This is very usefull for debugging.");
// $settingsParams[SETTINGS_CATEGORY_MAIN_MENU][] = new SettingParam( 'ALL_GROUPS_VISIBLE',
// 'checkbox',
// "Expand All Groups",
// "In case albums are divided to groups, all groups will be expanded and visible when the main menu is opened.<br/>".
// "If this option is not chosen, album group will be expanded when the mani menu is opened, only if the ."
// );
//////////////////////////////////////////
// //
// Global functions //
// //
//////////////////////////////////////////
function abortIfDemo()
{
if (DEMO_MODE==1)
{
echo "GRSlideShow is running in DEMO mode. Modification operation are not permitted.";
createPOSTButton("Back to Main Menu",MODE_FOLDER_MNG,ADMIN_PASSWORD,"");
myLog("abortIfDemo");
die;
}
}
function verifyWritePermissions($dir)
{
$fileName = "$dir/" . rand() ;
if (file_exists($fileName))
{
return false;
}
$f = @fopen($fileName, "w");
if (!$f)
{
return false;
}
fclose($f);
unlink($fileName);
if (file_exists($fileName))
{
return false;
}
return true;
}
function showCreditLink()
{
echo "<span class='grslideshow_link' style=\"font-size: 9px;\">powered by <a target='_blank' title='GRSlideshow - Online Photo Album Software' href='http://www.grslideshow.com'>GRSlideShow</a></span>";
}
function getCurrentPath()
{
$tokens = split('/',$_SERVER['SCRIPT_NAME']);
$path = "";
for($i=0;$i<sizeof($tokens)-1;$i++)
{
$path = "$path".$tokens[$i]."/";
}
return $path;
}
function isThumbnailsMenuEnabled()
{
if (defined("MENU_LINK"))
{
if ( strstr( MENU_LINK, "<THUMBNAIL>"))
return true;
else
return false;
}
if (USE_THUMBNAILS_IN_MAIN_MENU==1)
return true;
else
return false;
}
function createPOSTButton($label,$mode,$password,$folder ,$class="formbttn", $title="", $params=null,$autoSubmit=false)
{
echo "\n\t<form method=post ";
if ($autoSubmit)
echo "id='postform'";
echo " action='".$_SERVER['SCRIPT_NAME']."'>\n";
echo "\t<input type='hidden' name='".TAG_MODE."' value='$mode'>\n";
echo "\t<input type=hidden name='".TAG_PASSWORD."' value='$password'>";
echo "\t<input type='hidden' name='".TAG_FOLDER."' value='$folder'>\n";
if ($params)
{
foreach ($params as $key=>$value)
{
echo "\t<input type='hidden' name='$key' value='$value'>\n";
}
}
if (!$autoSubmit)
echo "\t<input type=submit title='$title' class='$class' value='$label' >\n";
echo "\t</form>\n";
if ($autoSubmit)
{
echo "<script type=\"text/javascript\">\n";
echo "f = document.getElementById('postform');\n";
echo "f.submit();\n";
echo "</script>\n";
}
}
function getFormattedDirSize($dirName)
{
$size = dirsize($dirName );
if ($size>100000)
{
$size = $size / 1024;
$size = $size / 1024;
return number_format($size, 1, '.', '') . " MB";
}
else if ($size>1000)
{
$size = $size / 1024;
return number_format($size, 2, '.', '') . " kb";
}
else if ($size>0)
{
return "$size byte";
}
}
function dirsize($dirName )
{
$dir = dir($dirName);
$size = 0;
if ($dir)
while($file = $dir->read())
{
if ($file != '.' && $file != '..')
{
if (is_dir($dirName . "/" . $file))
{
$size += dirsize($dirName . '/' . $file);
}
else
{
$size += filesize($dirName . '/' . $file);
}
}
}
if ($dir)
$dir->close();
return $size;
}
function zgetdirSize($folder)
{
$handle = opendir("$this->_folderName/original");
$filesFound = false;
if ($handle )
{
while (false !== ($file = readdir($handle)))
{
if ($file !="." && $file !="..")
{
$filesFound = true;
echo "<tr><td align=center><a href='$this->_folderName/original/$file'>$file</a></td></tr>";
}
}
closedir($handle);
}
}
function myLog($data="")
{
if (ENABLE_LOG!=1)
return;
$fileName = LOG_FILE_NAME;
$f = @fopen($fileName, "a");
if (!$f)
{
echo "<b>ERROR</b>: GRSlideShow can not write log to file '$fileName'.<br/>".
"Please make sure proper permissions are granted to parent directory.<br/>";
echo "Error descritopn: $data<br/>";
die;
}
if (array_key_exists(TAG_USER,$_COOKIE))
{
$data = $data . " " . $_COOKIE[TAG_USER];
}
elseif (array_key_exists(TAG_USER,$_GET))
{
$data = $data . " " . $_GET[TAG_USER];
}
fwrite($f, time() . " " . ip2long($_SERVER['REMOTE_ADDR']) . " $data\r\n");
fclose($f);
}
function getTextDirection($str)
{
//if (ENABLE_HEBREW_RTL!=1)
return "LTR";
$regexp = "/[א-ת]+/";
$regexp2 = "/[488-514]+/";
if(preg_match($regexp, $str) || preg_match($regexp2, $str))
{
//content contains hebrew
return "rtl";
}
else
{
// no hebrew
return "ltr";
}
}
function TRACE($msg)
{
return;
echo "DEBUG: $msg<p>";
}
function getLocalTime()
{
return time() + GMT_DIFF;
}
function showLogHeader()
{
echo "<br/><span class='title'>" . gmstrftime("%A %d.%m.%y %H:%M:%S",getLocalTime() ) ;
echo "<br/> IP: " . $_SERVER['REMOTE_ADDR'] . "</span><br/>";
showAdminToolbar(MODE_LOG);
}
function updateAlbumsOrder()
{
$f = fopen("album_order.txt", "w");
fwrite($f,$_POST["result"] );
fclose($f);
displaySettingsPage();
}
function displayLoginForm($mode)
{
echo "<center>GRSlideShow Login<br/>";
echo "<form method='post' action='".$_SERVER['SCRIPT_NAME']."'>";
echo "<input type=hidden name='".TAG_MODE."' value='$mode'>";
echo "<table cellpadding=0 cellspacing=1 border=0>";
echo "<tr class='title'><td>password: <input type=password name='". TAG_PASSWORD."'><br/>";
echo "<input type=checkbox name='". TAG_REMEMBER_PASSWORD."'> remember me</td></tr>";
echo "<tr align=center><td><input type='submit' value='Login' class='formbttn' >";
echo "</td></tr></table></form>";
}
function updateSettings()
{
global $settingsParams;
if (!validatePassword())
{
displayLoginForm(MODE_SETTINGS);
return;
}
$f = @fopen(SETTINGS_FILE, "w");
if (!$f)
{
MyLog("ERROR opening file " .SETTINGS_FILE);
return;
}
fwrite($f, "<"."?php\n");
fwrite($f, "\n//DO NOT EDIT!!! This file is automaticlaly generated by GRSlideshow Album Manager. DO NOT EDIT!!!\n\n");
foreach($settingsParams as $category=>$params)
{
foreach ($params as $param)
{
$key = $param->name;
$value = "";
if (array_key_exists($key,$_POST))
{
$value = $_POST[$key];
}
$value = str_replace("\\", "",$value);
if ($value=="on")
{
fwrite($f,"define ('$key',1);\n");
}
else
{
fwrite($f,"define ('$key',\"$value\");\n");
}
}
}
fwrite($f, "\n//DO NOT EDIT!!! This file is automaticlaly generated by GRSlideshow Album Manager. DO NOT EDIT!!!\n\n");
fwrite($f, "?".">\n");
fclose($f);
}
class SettingParam
{
var $name;
var $title;
var $value;
var $type;
var $description;
var $options;
var $size;
function SettingParam($name,$type,$title,$description="", $options=null,$size=null)
{
$default = '';
$userVars = get_defined_constants();
if (array_key_exists($name,$userVars))
{
$default = $userVars[$name];
}
$this->name = $name;
$this->type = $type;
$this->title = $title;
$this->description = $description;
if (isset($name))
$this->value = $default;
$this->options = $options;
$this->size = $size;
}
function getChecked()
{
if ($this->value == "1")
{
return " checked ";
}
else
{
return " unchecked ";
}
}
}
function displaySettingsToolbar()
{
echo "<table id=toolbar border=0>\n";
echo "<tr valign='top'>\n";
echo "<td><input class='formbttn' type=submit value='Apply'></td>\n";
echo "<td><input class='formbttn' type=button value='OK' onclick=\"OK()\"></td>\n";
echo "<td><input class='formbttn' type=button value='Cancel' onclick=\"Cancel()\"></td>\n";
echo "<td><input class='formbttn' type=button value='Main Menu Order' onclick=\"ReorderAlbums()\"></td>\n";
echo "</tr></table>\n";
}
function displaySettingsPage()
{
if (!validatePassword())
{
displayLoginForm(MODE_SETTINGS);
return;
}
global $settingsParams;
echo DOCTYPE."<html>";
echo "<head>". STYLE_HEADER . HTML_HEADERS ."\n";
?>
<script type="text/javascript">
function submitPage(mode)
{
<?php
if (preg_match("/msie/i",$_SERVER['HTTP_USER_AGENT']))
{
echo "document.mainform.". TAG_MODE .".value=mode;\n";
echo "document.mainform.submit();\n";
}
else
{
?>
frm = document.getElementById('mainform');
if (!frm) alert("error! (mainform)");
m1 = document.getElementById('<?php echo TAG_MODE ?>');
if (!m1) alert("Error! (m1)");
m1.value = mode;
frm.submit();
<?php
}
?>
}
function OK()
{
submitPage('<?php echo MODE_UPDATE_SETTINGS_BACK_TO_MAIN ?>');
}
function Cancel()
{
submitPage('<?php echo MODE_FOLDER_MNG ?>');
}
function ReorderAlbums()
{
submitPage('<?php echo MODE_REORDER_ALBUMS ?>');
}
</script>
</head>
<body class='Pictures'>
<?php
$hasPermissions = verifyWritePermissions(".");
if (!$hasPermissions)
{
echo "<b><font color=red>ERROR: GRSlideShow must have write permissions to current dir in order to save settings files</font></b> ";
}
?>
<form method=post id='mainform' name='mainform' action='<?php echo $_SERVER['SCRIPT_NAME'] ?>'>
<table>
<tr>
<td>
<?php
displaySettingsToolbar();
?>
</td>
</tr>
<?php
echo "<input type=hidden name='".TAG_MODE."' id='".TAG_MODE."' value='".MODE_UPDATE_SETTINGS."'>";
echo "<input type=hidden name='".TAG_PASSWORD."' value='".ADMIN_PASSWORD."'>";
foreach($settingsParams as $category=>$params)
{
echo "<tr><td><table border='1' width='100%'><tr><td><table>";
echo "<tr><td><b><u>$category:</u></b></td></tr>";
foreach ($params as $param)
{
echo "<tr><td><hr>";
switch ($param->type)
{
case "checkbox":
echo "<table><tr><td valign='top'><input type=$param->type ";
echo $param->getChecked();
echo " name='$param->name'></td><td><b>$param->title:</b><br/>$param->description</td><tr></table>"; break;
break;
case "select":
echo "<table><tr><td ><b>$param->title:</b></td>\n";
echo "<td valign='top'>";
echo "<select name='$param->name'>\n";
foreach($param->options as $option)
{
echo "<option value='$option' ";
if ($option == $param->value)
echo "selected";
echo ">$option</option>\n";
}
echo "</td><td>$param->description</td><tr></table>"; break;
break;
case "text":
echo "<table border=0><tr><td ><b>$param->title:</b>\n";
echo "<input type=$param->type value=\"$param->value\" ";
if ($param->size)
{
echo " size='$param->size' ";
}
echo " name='$param->name'></td></tr><tr><td colspan=99>$param->description</td><tr></table>";
break;
default:
echo "error, $param->name unknow param type $param->type";
die;
}
echo "</td></tr>";
}
echo "<tr><td><hr><input class='formbttn' type=submit value='Apply'></td></tr>";
echo "</table></td></tr></table></td></tr>";
}
?>
<tr>
<td>
<?php
displaySettingsToolbar();
?>
</td>
</tr>
</table>
</form>
</body>
</html>
<?php
}
function reorderAlbums()
{
if (!validatePassword())
{
displayLoginForm(MODE_REORDER_ALBUMS);
return;
}
echo DOCTYPE."<html>";
echo "<head>". STYLE_HEADER . HTML_HEADERS ."</head>\n" ;
?>
<script type="text/javascript">
function getSelected()
{
albums = document.getElementById('albums');
for (j=0; j< albums.options.length ;j++)
{
if ( albums.options[j].selected)
{
return j;
}
}
}
function swapAlbums(a,b)
{
albums = document.getElementById('albums');
tmpValue = albums.options[a].value;
tmpInnerText = albums.options[a].text
albums.options[a].value = albums.options[b].value;
albums.options[a].text = albums.options[b].text;
albums.options[b].value = tmpValue;
albums.options[b].text = tmpInnerText;
albums.options[a].selected=false;
albums.options[b].selected=true;
}
function clickedUp()
{
albums = document.getElementById('albums');
i = getSelected();
if (i==0)
{
//do nothing
return;
}
swapAlbums(i,i-1);
}
function clickedDown()
{
albums = document.getElementById('albums');
i = getSelected();
if (i==albums.options.length-1)
{
//do nothing
return;
}
swapAlbums(i,i+1);
setResult();
}
function setResult()
{
albums = document.getElementById('albums');
result = document.getElementById("result");
result.value = '';
for (i=0; i<albums.options.length ;i++)
{
if (albums.options[i].value.length>0)
{
result.value = result.value + albums.options[i].value + ",";
}
}
}
function submitPage(mode)
{
<?php
if (preg_match("/msie/i",$_SERVER['HTTP_USER_AGENT']))
{
echo "document.mainform.". TAG_MODE .".value=mode;\n";
echo "document.mainform.submit();\n";
}
else
{
echo "frm = document.getElementById('mainform');\n";
echo "m1 = document.getElementById('". TAG_MODE ."');\n";
echo "m1.value = mode;\n";
echo "frm.submit();\n";
}
?>
}
function Cancel()
{
//if (hasMadeChanges)
//{
// var rc= confirm ("Are you sure you want to exit without saving your changes?")
// if (rc == false)
// {
// return;
// }
//}
submitPage('<?php echo MODE_SETTINGS ?>');
}
function OK()
{
setResult();
submitPage('<?php echo MODE_UPDATE_ALBUMS_ORDER ?>');
}
</script>
</head>
<body class='Pictures'>
<span class='title'>
The list below shows the order of the albums in the main menu.<br/>
It is possible to move albums up and down in the list.<br/>
</span>
<table width='100%' border='0'>
<tr>
<td align='left'>
<table border='0'>
<tr>
<td colspan='2' align='left'>
<table><tr valign='top'>
<td><input type='button' class=formbttn value='OK' onclick='OK()'></td>
<td><input type='button' class=formbttn value='Cancel' onclick='Cancel()'></td>
</tr></table>
</td>
</tr>
<form method=post action='<?php echo $_SERVER['SCRIPT_NAME'] ?>' name='mainform' id='mainform'>
<tr>
<td align=right>
<?php
$albums = getAlbums();
$size = sizeof($albums);
if ($size>20)
$size=20;
echo "<select id='albums' size='$size' class='text'>";
$tmp = true;
foreach($albums as $album)
{
echo "\t\t<option value='".$album->folder."' ";
if ($tmp)
{
echo "selected";
$tmp = false;
}
echo " >".$album->name."</option>\n";
}
?>
</select>
</td>
<td valign='middle' align='left'>
<table>
<tr>
<td align='left'>
<input type=button value='up' class='formbttn' onclick="clickedUp()">
</td>
</tr>
<tr>
<td align='left'>
<input type=button class='formbttn' value='down' onclick="clickedDown()">
</td>
</tr>
</table>
</td>
</tr>
<tr><td align='center'>
<input type='hidden' name='result' id='result' value="">
<?php
echo "<input type=hidden name='".TAG_MODE."' id='".TAG_MODE."' value='".MODE_UPDATE_ALBUMS_ORDER."'>";
echo "<input type=hidden name='".TAG_PASSWORD."' value='".ADMIN_PASSWORD."'>";
?>
</form>
<td></td>
</td></tr>
<tr>
<td>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
<?php
}
function displayPageLog()
{
if (!validatePassword())
{
displayLoginForm(MODE_LOG);
return;
}
echo DOCTYPE."<html>";
echo "<head>". STYLE_HEADER . HTML_HEADERS ."</head>\n" ;
echo "<body class='Pictures'>";
showLogHeader();
$filename = LOG_FILE_NAME;
if (array_key_exists("file",$_POST))
{
$filename = $_POST["file"];
}
if (!file_exists($filename))
{
echo "<span class='title'>The file $filename does not exist</span>";
return;
}
echo "<table cellpadding=0 cellspacing=1 border=1>";
echo "<tr class='title'>";
echo "<td>Time</td>";
echo "<td>IP</td>";
echo "<td>Album Name</td>";
echo "</tr>";
$handle = fopen($filename, "r");
while (!feof($handle))
{
$buffer = fgets($handle, 4096);
if (!strlen($buffer))
break;
preg_match ("/^(\S+) (\S+) (.*)/", $buffer, $regs);
$longTime = $regs[1] + GMT_DIFF;
$time = gmstrftime("%A %d.%m.%y %H:%M:%S",$longTime );
$ip = long2ip($regs[2]);
$folder = $regs[3];
echo "<tr class='title'>";
echo "<td>$time</td>";
echo "<td>$ip</td>";
echo "<td>$folder</td>";
echo "</tr>";
}
fclose($handle);
echo "</table><br/>";
$dir = dir(".");
while($file = $dir->read())
{
if ($filename !=$file && $filename != "./".$file)
{
$regexp = "/^(.*)GRSlideShow\.log(.*)/";
if (preg_match ($regexp, $file, $regs))
{
$params = array();
$params["file"]=$file;
createPOSTButton($file,MODE_LOG,ADMIN_PASSWORD,"","formbttn","",$params);
}
}
}
$dir->close();
showLogHeader();
$params = array();
$params["file"]=$filename;
createPOSTButton('Refresh',MODE_LOG,ADMIN_PASSWORD,"","formbttn","",$params);
echo "</body></html>";
}
function validateFileType($filename,$ext)
{
if (0==strcmp(".$ext",strtolower(substr($filename,-1 * strlen(".$ext")))))
return 1;
return 0;
}
function isJPG($fileName)
{
if (validateFileType($fileName,"jpg"))
return 1;
if (validateFileType($fileName,"jpeg"))
return 1;
return 0;
}
function isValidImage($fileName)
{
if (isJPG($fileName))
return 1;
if (validateFileType($fileName,"gif"))
return 1;
return 0;
}
function piccmpByName($a,$b)
{
return strcmp($a->Name(),$b->Name());
}
function piccmpBydate($a,$b)
{
$path1 = $a->_getPicturePath();
$path2 = $b->_getPicturePath();
$time1 = filemtime($path1);
$time2 = filemtime($path2);
if ($time1>$time2)
return 1;
if ($time1<$time2)
return -1;
return 0;
}
function embeddedSlideShow($dirName)
{
$slideshow = new GRSlideShow();
$rc = $slideshow->InsertFolder( $dirName);
if ($rc)
{
$slideshow->StandAloneImageSlideShow();
}
}
function ShowSingleAlbum($folderName)
{
$slideshow = new GRSlideShow();
$rc = $slideshow->InsertFolder( $folderName);
if ($rc)
{
$slideshow->Go();
}
}
function CreateSlideShowFromFolderAndGo($folderName)
{
$mode = getMode(MODE_INDEX);
if ($mode == MODE_FOLDER_MNG)
{
EditAlbum($folderName);
return;
}
AutoGRSlideShow($mode,$folderName);
}
function validatePassword()
{
if (SECURITY_ENABLED !=1)
return true;
$wrongPassword = false;
$foundPassword = "";
if (array_key_exists(TAG_PASSWORD,$_GET))
{
$foundPassword = $_GET[TAG_PASSWORD];
}
else
if (array_key_exists(TAG_PASSWORD,$_POST))
{
$foundPassword = $_POST[TAG_PASSWORD];
}
else
if (array_key_exists(TAG_PASSWORD,$_COOKIE))
{
$foundPassword = $_COOKIE[TAG_PASSWORD];
}
if ($foundPassword==ADMIN_PASSWORD)
{
$remeberPassword = false;
if (array_key_exists(TAG_REMEMBER_PASSWORD,$_POST) && $_POST[TAG_REMEMBER_PASSWORD]=="on")
{
$remeberPassword = true;
}
if (array_key_exists(TAG_REMEMBER_PASSWORD,$_GET) && $_GET[TAG_REMEMBER_PASSWORD]=="on")
{
$remeberPassword = true;
}
if ($remeberPassword)
{
SetCookie(TAG_PASSWORD,ADMIN_PASSWORD ,time()+31536000,"/");
}
return true;
}
else
{
$wrongPassword = true;
}
if ($wrongPassword && strlen($foundPassword))
{
echo "<span class='title'>Wrong Password!</span><br/>";
}
return false;
}
function getAlbumsByGroups()
{
$groups = array();
$albums = getAlbums(false);
foreach($albums as $album)
{
$group = $album->group;
if (ENABLE_ALBUMS_GROUPS==1)
{
$groups[$group][] = $album;
}
else
{
$groups[''][] = $album;
}
}
return $groups;
}
function getAlbums($includeHiddenAlbums = true)
{
$folders = array();
$shouldSort = true;
if (file_exists("album_order.txt"))
{
$f = @fopen("album_order.txt", "r");
if ($f)
{
$shouldSort = false;
$tmp = "";
while ($f && !feof($f))
{
$tmp = $tmp . fgets($f, 4096);
}
$folders = split(",",$tmp);
fclose($f);
}
}
$handle = opendir(".");
if ($handle )
{
while (false !== ($folder = readdir($handle)))
{
if (
is_dir($folder) &&
$folder !="." &&
$folder !=".svn" &&
$folder !=".." &&
$folder !="cgi-bin" &&
!strstr($folder,".deleted"))
{
if (!in_array($folder,$folders))
{
array_unshift($folders, $folder);
}
}
}
closedir($handle);
}
if ($shouldSort)
{
arsort($folders);
}
$result = array();
foreach($folders as $folder)
{
if (is_array($folder))
$folder = $folder[0]; // this is a workaround for a very very strange bug, that happened only on one server...
if (strlen($folder) && is_dir($folder))
{
$album = new AlbumInfo($folder, ! $includeHiddenAlbums);
if ($includeHiddenAlbums || !$album->isDisabled)
{
$result[] = $album;
}
}
}
return $result;
}
function showAdminToolbar($mode)
{
echo "<table border=0><tr valign='top'>";
if ($mode !=MODE_FOLDER_MNG)
{
echo "<td>";
createPOSTButton("Main Menu",MODE_FOLDER_MNG,ADMIN_PASSWORD,"");
echo "</td>";
}
if ($mode ==MODE_FOLDER_MNG)
{
echo "<td>";
echo "<input type=button class='formbttn' value='New Album' ";
if (AUTO_NEW_FOLDER_NAME)
{
echo "onclick=\"document.all.newalbumform.submit();\"";
}
else
{
echo "onclick=\"document.all.div_new_album.style.display='';document.all.div_new_album.style.visibility='visible'\"";
}
echo "></td>";
}
if ($mode !=MODE_LOG && ENABLE_LOG==1)
{
echo "<td>";
createPOSTButton("Log",MODE_LOG,ADMIN_PASSWORD,"");
echo "</td>";
}
if ($mode !=MODE_SETTINGS && $mode !=MODE_LOG)
{
echo "<td>";
createPOSTButton("Settings",MODE_SETTINGS,ADMIN_PASSWORD,"");
echo "</td>";
}
echo "<td>";
createPOSTButton("Logout",MODE_LOGOUT,"","");
echo "</td>";
echo "</tr></table>";
echo "<div id='div_new_album' style=\"display:none;visibility :hidden \">\n";
echo "\t<form name='newalbumform' method=post action='".$_SERVER['SCRIPT_NAME']."' onsubmit=\"if (this.new_folder.value.length<1) return -1;\">\n";
echo "<table border=1>";
echo "<tr><td class=\"title\" align=center>Create New Album</td><tr>";
echo "<tr><td>";
echo "<input type='hidden' name='".TAG_MODE."' value='".MODE_NEW_ALBUM."'>\n";
echo "<input type=hidden name='".TAG_PASSWORD."' value='".ADMIN_PASSWORD."'>";
$date = gmstrftime("%Y.%m.%d",time()+ GMT_DIFF);
$newAlbumName = $date;
$i=1;
while (is_dir($newAlbumName) && $i<20)
{
$newAlbumName = $date . ".$i";
$i++;
}
if (is_dir($newAlbumName))
{
MyLog("The directory $newAlbumName already exists. Failed to create a new dir.");
die;
}
echo "<span class=\"title\">Folder Name:</span> <input type=text name='new_folder' value='$newAlbumName'></td><tr>";
echo "<tr><td align=center><input type='submit' value='Create' class='formbttn' >";
echo "</td></tr></table>\n\t</form>\n</div>\n";
}
function displayPageAdminMainMenu()
{
if (!validatePassword())
{
displayLoginForm(MODE_FOLDER_MNG);
return;
}
MyLog("admin");
echo DOCTYPE."<html><head>";
echo STYLE_HEADER .HTML_HEADERS ."\n" ;
?>
<script type="text/javascript">
function submitForm(form_id,mode)
{
frm = document.getElementById(form_id);
if (frm==null)
{
alert("error: cant find "+form_id);
}
if (mode == '<?php echo MODE_DELETE_ALBUM ?>')
{
var rc= confirm ("Are you sure you want to delete the album '"+frm.<?php echo TAG_FOLDER ?>.value+"'? ");
if (rc == false)
{
return;
}
}
if (mode == '<?php echo MODE_DELETE_ORIGINALS ?>')
{
var rc= confirm ("Are you sure you want to delete the original images of album '"+frm.<?php echo TAG_FOLDER ?>.value+"'? ");
if (rc == false)
{
return;
}
}
frm.<?php echo TAG_MODE ?>.value = mode;
frm.submit();
}
</script>
<?php
echo "</head>";
echo "<body class=\"Pictures\">";
$hasPermissions = verifyWritePermissions(".");
if (!$hasPermissions)
{
echo "<b><font color=red>ERROR: GRSlideShow must have write permissions to current dir in order to save settings files</font></b> ";
}
$folderName = ".";
echo "<table border=0>";
echo "<tr><td class=\"title\" colspan=3>Your IP: " . $_SERVER['REMOTE_ADDR'] . "</td></tr>";
echo "<tr valign=top>";
echo "<td>";
showAdminToolbar(MODE_FOLDER_MNG);
echo "</td>";
echo "</tr>";
echo "</table>";
echo "<table cellpadding=0 cellspacing=1 border=1>";
echo "<tr class=\"title\"><td> </td>";
echo "<td>Folder Name</td>";
echo "<td>Album Name</td>";
if (ENABLE_ALBUMS_GROUPS==1)
echo "<td>group</td>";
echo "<td>Pictures</td>";
echo "<td>Last Update</td>";
echo "<td>Size</td>";
echo "<td >Status</td>";
echo "<td colspan=9 align=center>actions</td>";
echo "</tr>";
$albums = getAlbums();
$i=0;
$totalImages = 0;
foreach ($albums as $album)
{
$i++;
echo "<tr class=\"title\">\n";
echo "<form name='frm$i' id='frm$i' method=post action='".$_SERVER['SCRIPT_NAME']."'>";
echo "<input type=hidden name='".TAG_MODE."' value='".MODE_EDIT_ALBUM."'>";
echo "<input type=hidden name='".TAG_FOLDER."' value='$album->folder'>";
echo "<input type=hidden name='".TAG_PASSWORD."' value='".ADMIN_PASSWORD."'>";
echo "<td>$i</td>\n";
echo "<td>$album->folder</td>\n";
echo "<td>$album->name</td>\n";
if (ENABLE_ALBUMS_GROUPS==1)
echo "<td>$album->group</td>\n";
echo "<td>$album->numOfImages</td>\n";
echo "<td>$album->lastUpdate</td>\n";
echo "<td>$album->size</td>\n";
echo "<td align=center>";
if ($album->isDisabled)
echo "Hidden ";
if ($album->isNew)
echo NEW_ALBUM_SIGN;
echo "</td>";
echo "<td><input type='button' value='view' class='formbttn' onclick=\"window.open('". $_SERVER['SCRIPT_NAME'] . "?".TAG_MODE."=" .MODE_INDEX."&".TAG_FOLDER."=$album->folder');\"></td>\n";
echo "<td><input type='submit' value='edit' class='formbttn' ></td>\n";
echo "<td><input type='button' value='Upload' class='formbttn' onclick=\"submitForm('frm$i','".MODE_CHOOSE_PICTURES."')\"></td>\n";
echo "<td><input type='button' value='Delete' class='formbttn' onclick=\"submitForm('frm$i','".MODE_DELETE_ALBUM."')\"></td>\n";
if (is_dir("$album->folder/original"))
{
echo "<td><input type='button' value='Delete Originals' class='formbttn' onclick=\"submitForm('frm$i','".MODE_DELETE_ORIGINALS."')\"></td>\n";
}
echo "</form>";
echo "</tr>\n";
$totalImages += $album->numOfImages;
}
echo "</table>\n";
echo "<br/><span class=\"title\">Total: $totalImages images in ". sizeof($albums) ." albums.</span>";
echo "</body></html>";
}
function createMenuLink($baseMenuLink,$album,$isNew)
{
$link = $album->scriptName;
if (0 ==strlen($link))
{
$link = $_SERVER['SCRIPT_NAME'] . "?".TAG_MODE."=" .MODE_INDEX."&".TAG_FOLDER."=".$album->folder;
}
$replacements = array();
$patterns = array();
$replacements[] = $link;
$patterns[] = "/<LINK>/";
$replacements[] = $album->name;
$patterns[] = "/<TITLE>/";
if (strstr( $baseMenuLink, "<MAIN>"))
// this line is here for backward compatibility
{
$patterns[] = "/<MAIN>/";
$replacements[] = NAME_OF_MAIN_FRAME;
}else
if (strstr( $baseMenuLink, "<MAIN_FRAME>"))
{
$patterns[] = "/<MAIN_FRAME>/";
$replacements[] = NAME_OF_MAIN_FRAME;
}
if (strstr( $baseMenuLink, "<THUMBNAIL>"))
{
$patterns[] = "/<THUMBNAIL>/";
$replacements[] = $album->getAlbumThumbnailFullPath();
}
if ($isNew && strstr( $baseMenuLink, "<LAST_MODIFIED>"))
{
$patterns[] = "/<LAST_MODIFIED>/";
$replacements[] = $album->lastUpdate;
}
if (strstr( $baseMenuLink, "<NUM_OF_IMAGES>"))
{
$patterns[] = "/<NUM_OF_IMAGES>/";
$replacements[] = $album->numOfImages;
}
ksort($patterns);
ksort($replacements);
$menuLink = preg_replace($patterns, $replacements, $baseMenuLink);
return $menuLink;
}
function getAlbumLinkTemplate($isNew = false)
{
//$link = "<a href='javascript:openAlbum()' title='<NUM_OF_IMAGES> pictures' >\n";
$link="";
$link = $link."<table align='".MAIN_MENU_ALIGNMENT."' title='<NUM_OF_IMAGES> pictures' ";
if ($isNew && MARK_NEW_ALBUMS==1)
{
$link = $link."class='newLink' ";
}
else
{
$link = $link."class='formbttn' ";
}
$link = $link." border=0 width='100%' ";
if (OPEN_ALBUM_IN_NEW_WINDOW==1)
{
$link = $link ."onclick=\"window.open('<LINK>','GRSlideShow','fullscreen=yes')\">\n";
}
else
{
$link = $link ."onclick=\"window.location='<LINK>'\">\n";
}
$link = $link ."<tr align='".MAIN_MENU_ALIGNMENT."'>";
if (USE_THUMBNAILS_IN_MAIN_MENU==1)
{
$link = $link ."<td width='".THUMBNAIL_H_SIZE."'><a href='<LINK>' ><img alt='' src='<THUMBNAIL>' title='<NUM_OF_IMAGES> pictures' border='0'></a></td>";
}
$link = $link ."<td align='".MAIN_MENU_ALIGNMENT."'>";
if (DISPLAY_ALBUM_NAME_IN_MAIN_MENU==1)
{
$link = $link ."<a href='<LINK>' ><TITLE>";
if ($isNew && MARK_NEW_ALBUMS==1)
{
$link = $link ."<br/>".NEW_ALBUM_SIGN." <span class='date'>(new pictures added on <LAST_MODIFIED>)</span>";
}
$link = $link ."</a>";
}
$link = $link ."</td>";
$link = $link ."</tr></table>";
//echo "</a>";
return $link;
}
function CreateMenu($folderName)
{
echo HTML_TAG ."<head>";
echo STYLE_HEADER .HTML_HEADERS ."\n";
echo TEST_STYLESHEET;
?>
<script type="text/javascript">
function toggleDiv(div_id)
{
div = document.getElementById(div_id);
if (div.style.display!='')
{
div.style.display='';
div.style.visibility='visible';
}
else
{
div.style.display='none';
div.style.visibility='hidden';
}
}
function openAlbum()
{
}
function opengroup()
{
}
</script>
<?php
echo "</head>\n";
echo "<body class=\"PicturesM\" style=\"text-align : ".MAIN_MENU_ALIGNMENT."\" >\n";
echo POPUP_SCRIPT;
if (strlen(MAIN_MENU_TITLE))
{
echo "<br/><span class='main_menu_header'>".MAIN_MENU_TITLE."</span><br/>\n";
}
echo "<div align='".MAIN_MENU_ALIGNMENT."'>";
echo "<!-- beginining of all groups -->\n";
echo "<table width='70%' border='0'>\n";
$groups = getAlbumsByGroups();
if (sizeof($groups)==0)
{
echo "There are no albums to show.<br/>\n";
echo "If this is the first time you are running GRSlideshow, <br/>\n".
"go to the <a href='".$_SERVER['SCRIPT_NAME'] . "?admin=1'>admin</a> section.\n";
}
$numOfNewAlbums = 0;
$groupNum = 0;
$numOfAlbums=0;
$numOfPics = 0;
foreach($groups as $group=>$albums)
{
$groupNum++;
$i=0;
echo "\t<!-- beginining of group_$group table -->\n";
echo "\t<tr align='".MAIN_MENU_ALIGNMENT."'>\n";
echo "\t<td align='".MAIN_MENU_ALIGNMENT."'>\n";
if ( SEPERATOR_BELOW_GROUP==0)
{
echo "\t<hr>\n";
}
$groupName = $group;
if (!strlen($groupName)&& ENABLE_ALBUMS_GROUPS==1)
$groupName = "all";
if (strlen($groupName))
{
if (SHOW_GROUP_NAME_AS_BUTTON)
{
echo "\t<input type='button' class='groupbttn' value='$groupName' onclick=\"toggleDiv('div_group_$groupNum')\" >\n\t<br/>\n";
}
else
{
echo "\t<span class='group_name' >$groupName</span>\n\t<br/>\n";
}
}
echo "\t<div id='div_group_$groupNum' ";
$hidden = true;
$numOfNew = 0;
if (sizeof($groups)==1 || ALL_GROUPS_VISIBLE==1)
{
$hidden = false;
}
else
if ($groupNum==1 )
{
if (ALWAYS_SHOW_FIRST_GROUP==1)
{
$hidden = false;
}
else
foreach($albums as $album)
{
if ($album->isNew)
{
$numOfNew++;
if (!$album->visited)
{
if ($numOfNew<=MAX_NEW_ALBUMS)
$hidden = false;
}
}
}
}
if ($hidden)
echo "style='display:none;visibility:hidden' ";
else
echo "style=\"display:'';visibility:visibile\" ";
echo ">\n";
echo "\t<table ";
if (NUMBER_OF_ITEMS_IN_MENU_ROW >1)
{
echo "width=100%";
}
echo " cellpadding=0 cellspacing=1 border=0 align='".MAIN_MENU_ALIGNMENT."'>\n";
foreach($albums as $album)
{
if ($album->isDisabled )
{
continue;
}
$numOfAlbums++;
$numOfPics += $album->numOfImages;
if (NUMBER_OF_ITEMS_IN_MENU_ROW ==1)
{
echo "\t\t<tr>\n";
}
else
{
if ($i%NUMBER_OF_ITEMS_IN_MENU_ROW ==0)
{
echo "\t\t<tr>\n\t\t\t<td><table width='100%' border=0><tr>\n";
}
}
$baseMenuLink ="";
if ($album->isNew)
{
$numOfNewAlbums++;
}
$albumLinkTemplate = "";
if (defined("MENU_LINK"))
{
$albumLinkTemplate = MENU_LINK;
}
else
{
$albumLinkTemplate = getAlbumLinkTemplate();
}
$newalbumLinkTemplate = "";
if (defined("NEW_MENU_LINK"))
{
$newalbumLinkTemplate = NEW_MENU_LINK;
}
else
{
$newalbumLinkTemplate = getAlbumLinkTemplate(true);
}
$isNew = false;
if ($album->isNew &&
!$album->visited &&
$numOfNewAlbums<=MAX_NEW_ALBUMS)
{
$baseMenuLink = $newalbumLinkTemplate;
$isNew = true;
}
else
{
$baseMenuLink = $albumLinkTemplate;
}
$percentage = 100 / NUMBER_OF_ITEMS_IN_MENU_ROW ;
$menuLink = createMenuLink($baseMenuLink,$album,$isNew);
echo "\t\t\t\t<td width='".$percentage."%' align='center'>" . $menuLink . "</td>\n";
$i++;
if (NUMBER_OF_ITEMS_IN_MENU_ROW ==1)
{
echo "\t\t</tr>\n";
}
else
{
if ($i == sizeof($albums)) // this is the last album in group
{
if ($i%NUMBER_OF_ITEMS_IN_MENU_ROW) // if row is not full
{
$cellsLeftInRow = NUMBER_OF_ITEMS_IN_MENU_ROW - ($i%NUMBER_OF_ITEMS_IN_MENU_ROW);
for ($j=0 ; $j < $cellsLeftInRow ; $j++)
{
$i++;
echo "\t\t\t\t<td width='".$percentage."%'> </td>\n";
}
}
}
if ($i%NUMBER_OF_ITEMS_IN_MENU_ROW ==0 )
{
echo "\t\t\t</tr></table></td>\n\t\t</tr>\n";
}
}
} //foreach albums
echo "\t</table>\n";
echo "\t</div>\n";
if ((sizeof($groups)>1 && SEPERATOR_BELOW_GROUP==1)|| $groupNum==sizeof($groups))
{
echo "\t<hr>\n";
}
echo "\t</td></tr>\n";
echo "\t<!-- end of table 'group_$group' -->\n";
}//foreach groups
echo "<tr><td align='".MAIN_MENU_ALIGNMENT."'>Total $numOfPics pictures in $numOfAlbums albums</td></tr>\n";
//$link = $_SERVER['SCRIPT_NAME'] . "?" .TAG_MODE. "=". MODE_CREDIT ;
echo "<tr><td align='".MAIN_MENU_ALIGNMENT."'>";
showCreditLink();
echo "</td></tr>";
echo "</table>\n<!-- end of groups table -->\n";
echo "</div>";
if (strlen(MENU_FOOTER_HREF ))
{
echo "<br/><br/><input type='button' class='formbttn' value='".MENU_FOOTER."' onclick=\"window.location='".MENU_FOOTER_HREF."'\">";
}
echo "</body>\n</html>";
}
function getAlbumParam($folder,$param)
{
$fileName = $folder ."/".ALBUM_DESCRIPTOR;
if (file_exists($fileName))
{
$f = @fopen($fileName, "r");
while ($f && !feof($f))
{
$line = fgets($f, 4096);
$regexp = "/^\"".$param."\"=\"(.*)\"/";
if (preg_match ($regexp, $line, $regs))
{
fclose($f);
return $regs[1];
}
}
if ($f)
fclose($f);
}
return "";
}
function createMainFrame($folder)
{
echo DOCTYPE."<html>";
if (FRAME_MENU_POSITION == "left")
{
?>
<frameset cols="<?php echo FRAMESET_COLS; ?>" border=1>
<frame name="menu" src="<?php echo $_SERVER['SCRIPT_NAME'] . "?".TAG_MODE."=" .MODE_MENU."&".TAG_FOLDER."=$folder" ?>" scrolling="auto" >
<frame name="<?php echo NAME_OF_MAIN_FRAME ?>" src="<?php echo $_SERVER['SCRIPT_NAME'] . "?".TAG_MODE."=" .MODE_BLANK ?>" scrolling="auto">
</frameset>
</html>
<?php
}
else
{
?>
<frameset cols="*,8%" border=0>
<frame name="<?php echo NAME_OF_MAIN_FRAME ?>" src="<?php echo $_SERVER['SCRIPT_NAME'] . "?".TAG_MODE."=" .MODE_BLANK ?>" scrolling="auto">
<frame name="menu" src="<?php echo $_SERVER['SCRIPT_NAME'] . "?".TAG_MODE."=" .MODE_MENU."&".TAG_FOLDER."=$folder" ?>" scrolling="auto">
</frameset>
</html>
<?php
}
}
function EditAlbum($folder)
{
$slideshow = new GRSlideShow();
$slideshow->InsertFolder($folder);
$slideshow->EditAlbum();
}
function ChoosePicturesToUpload($mode)
{
echo DOCTYPE."<html><head>";
echo STYLE_HEADER .HTML_HEADERS ."\n";
?>
<script type="text/javascript">
function blinkDiv()
{
div = document.getElementById('div_upload_started');
if (div.style.display!='')
{
div.style.display='';
div.style.visibility='visible';
}
else
{
div.style.display='none';
div.style.visibility='hidden';
}
setTimeout("blinkDiv()",750 );
}
function beforeSubmitForm()
{
setTimeout("blinkDiv()",750 );
return 1;
}
</script>
<?php
echo "</head>\n<body class=\"Pictures\">";
if (ENABLE_GUEST_UPLOAD==1 && $mode == MODE_GUEST_CHOOSE_PICTURES)
{
$uploadEnabled = getAlbumParam($_POST[TAG_FOLDER],TAG_GUEST_UPLOAD);
if (strcmp("on",$uploadEnabled)!=0)
{
echo "Guest upload is not permitted for this album (choose pictures)";
return;
}
}
else
if (!validatePassword())
{
echo "You are not authorized to access this page";
return;
}
$nextMode = MODE_UPLOAD_PICTURES;
if ($mode == MODE_GUEST_CHOOSE_PICTURES)
$nextMode = MODE_GUEST_UPLOAD;
echo "\n<form name='myform' method='post' action='".$_SERVER['SCRIPT_NAME']."' enctype='multipart/form-data' onsubmit='beforeSubmitForm()'>\n";
echo "<input type='hidden' name='".TAG_MODE."' value='$nextMode'>\n";
echo "<input type='hidden' name='".TAG_FOLDER."' value='".$_POST[TAG_FOLDER]."'>\n";
echo "<input type='hidden' name='".TAG_PASSWORD."' value='".ADMIN_PASSWORD."'>";
echo "<div>\n<table border=1 cellspacing=0 cellpadding=0 >\n";
echo "<tr class=title><td >Folder Name: " . $_POST[TAG_FOLDER] . "</td></tr>\n";
echo "<tr class=title><td>";
echo "Upload <b>jpg</b> files or <b>zip</b> files that contain <b>jpg</b> files.";
echo "</td></tr>\n";
for ($i=0;$i<NUM_OF_PICS_ON_UPLOAD;$i++)
{
echo "<tr><td><input name=\"file_$i\" id=\"file_$i\" size=50 type=\"file\"></td></tr>\n";
}
echo "<tr><td align=center>";
echo "<tr class=title><td>Max File size for upload is " . ini_get ('upload_max_filesize') ;
echo "<br/>Total upload can not exceed " . ini_get ('post_max_size') ;
echo "</td></tr>";
echo "<tr><td align=center><input type=\"submit\" class=formbttn value='Upload Files' ></td></tr>";
echo "</table>";
echo "<div id='div_upload_started' style=\"display:none;visibility:hidden\">";
echo "<span class=title>Upload started. Please wait....</span>";
echo "</div>";
}
function UploadPictures($mode)
{
if (ENABLE_GUEST_UPLOAD==1 && $mode == MODE_GUEST_UPLOAD)
{
$uploadEnabled = getAlbumParam($_POST[TAG_FOLDER],TAG_GUEST_UPLOAD);
if (strcmp("on",$uploadEnabled)!=0)
{
echo "Guest upload is not permitted for this album (choose pictures)";
return;
}
}
else
{
if (!validatePassword())
{
echo "You are not authorized to access this page";
return;
}
}
if (array_key_exists(TAG_FOLDER,$_POST))
$folder = $_POST[TAG_FOLDER];
else
$folder = $_GET[TAG_FOLDER];
//echo "<PRE>";
//print_r($_FILES);
//die;
foreach ($_FILES as $fileID => $file)
{
$fileName = $file['name'];
if ($file['error']==0)
{
$i=1;
while (file_exists("$folder/$fileName") && $i<20)
{
$regexp = "/^(.*).(.{3})/";
if (preg_match ($regexp, $file['name'], $regs))
{
$fileName = $regs[1].".$i." . $regs[2];
}
$i++;
}
if (file_exists("$folder/$fileName"))
{
MyLog("ERROR: the file $folder/$fileName already exists. Failed to rename");
//die;
}
if (move_uploaded_file($file['tmp_name'], "$folder/$fileName"))
{
if (CHMOD_UPLOADED_IMAGE==1)
{
chmod("$folder/$fileName", 0744);
}
// echo "moved the file to $folder/$fileName";
}
else
{
echo "ERROR. can't move uploaded file to $folder/$fileName";
echo "<PRE>";
print_r($file);
print_r($_FILES);
}
}
}
if ($mode == MODE_GUEST_UPLOAD)
{
$slideshow = new GRSlideShow();
$slideshow->InsertFolder( $folder);
$slideshow->Go(MODE_INDEX);
}
else
{
EditAlbum($folder);
}
}
function RotatePicture($folder)
{
if (!validatePassword())
{
echo "You are not authorized to access this page";
return;
}
$slideshow = new GRSlideShow();
$slideshow->InsertFolder($folder);
$pic = $_POST[TAG_PICTURE_NAME];
$slideshow->RotatePicture($pic);
$slideshow->EditAlbum();
}
function deleteAlbum($folder)
{
if (is_dir($folder))
{
rename($folder,$folder.".deleted");
}
}
function deleteOriginals($folder)
{
$originalsDirName = "$folder/original";
if (is_dir("$folder/original"))
{
$dir = dir($originalsDirName);
while($file = $dir->read())
{
if($file != "." && $file != "..")
{
unlink("$originalsDirName/$file");
}
}
$dir->close();
rmdir("$folder/original");
}
}
function DeletePicture($folder)
{
if (!validatePassword())
{
echo "You are not authorized to access this page";
return;
}
$pic = $_POST[TAG_PICTURE_NAME];
rename("$folder/$pic","$folder/$pic.deleted");
$slideshow = new GRSlideShow();
$slideshow->InsertFolder($folder);
$slideshow->EditAlbum();
}
function MovePicture($folder)
{
if (!validatePassword())
{
echo "You are not authorized to access this page";
return;
}
$pic = $_POST[TAG_PICTURE_NAME];
$newPic = $_POST[TAG_NEW_PICTURE_NAME];
$newFolder = $_POST[TAG_NEW_FOLDER];
rename("$folder/$pic","$newFolder/$newPic");
if (file_exists("$folder/original/$pic"))
{
if (!is_dir("./$newFolder/original"))
{
mkdir("./$newFolder/original",0777);
}
rename("$folder/original/$pic","$newFolder/original/$newPic");
}
$slideshow = new GRSlideShow();
$slideshow->InsertFolder($folder);
$slideshow->EditAlbum();
}
function UpdateAlbum($folder)
{
$slideshow = new GRSlideShow();
$slideshow->InsertFolder($folder);
$slideshow->UpdateAlbum();
}
function NewAlbum()
{
if (!validatePassword())
{
echo "You are not authorized to access this page";
return;
}
$root = ".";
$folder = $root . "/".$_POST["new_folder"];
if (file_exists($folder))
{
echo "The folder $folder already exists";
return;
}
else
{
$rc = @mkdir($folder,0777);
if (FALSE == $rc)
{
echo "Error!! failed to mkdir $folder. Verify permissions!";
die;
}
$slideshow = new GRSlideShow();
$slideshow->InsertFolder($folder);
$params = array();
$params["new"] = "on";
if (SET_NEW_ALBUM_TO_ENABLE_GUEST_UPLOAD==1)
{
$params[TAG_GUEST_UPLOAD] = "on";
}
$slideshow->UpdateAlbum($params);
$slideshow->EditAlbum();
return;
}
echo DOCTYPE."<html><body><form name='myform' id='myform' method=post action='".$_SERVER['SCRIPT_NAME']."' >\n";
echo "<input type='hidden' name='".TAG_MODE."' value='".MODE_FOLDER_MNG."'>\n";
//echo "<input type='hidden' name='".TAG_FOLDER."' value='$folder'>\n";
echo "<input type=hidden name='".TAG_PASSWORD."' value='".ADMIN_PASSWORD."'>";
echo "</form>";
echo "<script type='text/javascript'>f = document.getElementById('myform'); f.submit();</script>";
//header("Location: " . $_SERVER['SCRIPT_NAME']."?".TAG_MODE."=".MODE_FOLDER_MNG );
}
function CreateBlank()
{
echo DOCTYPE."<html><head>";
echo STYLE_HEADER .HTML_HEADERS ."\n";
echo "</head>";
echo "<body class=\"Pictures\"><input type=hidden name=blankpage>";
if (strlen(BLANK_PAGE_TITLE))
{
echo "<br/><span class='main_menu_header'>".BLANK_PAGE_TITLE."</span><br/>";
}
echo "</body></html>";
}
function getMode($default)
{
if (array_key_exists(TAG_IMAGE_NUMBER_SINGLE_SLIDE,$_GET))
{
return MODE_SINGLE_SLIDE;
}
if (array_key_exists(TAG_MODE,$_GET))
{
return $_GET[TAG_MODE];
}
if (array_key_exists(TAG_MODE,$_POST))
{
return $_POST[TAG_MODE];
}
if (array_key_exists(OLD_TAG_MODE,$_GET))
{
return $_GET[OLD_TAG_MODE];
}
if (array_key_exists(OLD_TAG_MODE,$_POST))
{
return $_POST[OLD_TAG_MODE];
}
return $default;
}
function AutoGRSlideShow($mode = DEFAULT_AUTO_MODE, $folder = ".")
{
global $settings;
$mode = getMode($mode);
if (array_key_exists(TAG_ADMIN,$_GET))
{
if($_GET[TAG_ADMIN]==1)
$mode = MODE_FOLDER_MNG;
}
if (array_key_exists(TAG_ABOUT,$_GET))
{
if($_GET[TAG_ABOUT]==1)
$mode = MODE_ABOUT;
}
if (array_key_exists(TAG_LOG,$_GET))
{
if($_GET[TAG_LOG]==1)
$mode = MODE_LOG;
}
if (array_key_exists(TAG_FOLDER,$_GET))
{
$folder = $_GET[TAG_FOLDER];
}
elseif (array_key_exists(TAG_FOLDER,$_POST))
{
$folder = $_POST[TAG_FOLDER];
}
switch ($mode)
{
case MODE_MAIN_FRAME:
createMainFrame($folder);
break;
case MODE_MENU:
CreateMenu($folder);
break;
case MODE_BLANK:
CreateBlank();
break;
case MODE_FOLDER_MNG:
displayPageAdminMainMenu();
break;
case MODE_LOG:
abortIfDemo();
displayPageLog();
break;
case MODE_REORDER_ALBUMS:
reorderAlbums();
break;
case MODE_UPDATE_ALBUMS_ORDER:
abortIfDemo();
updateAlbumsOrder();
break;
case MODE_EDIT_ALBUM:
EditAlbum($folder);
break;
case MODE_SETTINGS:
displaySettingsPage();
break;
case MODE_UPDATE_SETTINGS_BACK_TO_MAIN:
abortIfDemo();
updateSettings();
echo DOCTYPE."<html><body>";
createPOSTButton("OK",MODE_FOLDER_MNG,$_POST['ADMIN_PASSWORD'],"","","",null,true);
echo "</body></html>";
break;
case MODE_UPDATE_SETTINGS:
abortIfDemo();
updateSettings();
echo DOCTYPE."<html><body>";
createPOSTButton("OK",MODE_SETTINGS,$_POST['ADMIN_PASSWORD'],"","","",null,true);
echo "</body></html>";
break;
case MODE_UPDATE_ALBUM_BACK_TO_MAIN:
abortIfDemo();
UpdateAlbum($folder);
displayPageAdminMainMenu();
break;
case MODE_UPDATE_ALBUM:
abortIfDemo();
UpdateAlbum($folder);
EditAlbum($folder);
break;
case MODE_CHOOSE_PICTURES:
case MODE_GUEST_CHOOSE_PICTURES:
ChoosePicturesToUpload($mode);
break;
case MODE_DELETE_ALBUM:
abortIfDemo();
deleteAlbum($folder);
displayPageAdminMainMenu();
break;
case MODE_DELETE_ORIGINALS:
abortIfDemo();
deleteOriginals($folder);
displayPageAdminMainMenu();
break;
case MODE_ROTATE_PICTURE:
abortIfDemo();
RotatePicture($folder);
break;
case MODE_DELETE_PICTURE:
abortIfDemo();
DeletePicture($folder);
break;
case MODE_MOVE_PICTURE:
abortIfDemo();
MovePicture($folder);
break;
case MODE_UPLOAD_PICTURES:
case MODE_GUEST_UPLOAD:
abortIfDemo();
UploadPictures($mode);
break;
case MODE_NEW_ALBUM:
abortIfDemo();
NewAlbum();
break;
case MODE_LOGOUT:
SetCookie(TAG_PASSWORD,"" ,0,"/");
CreateMenu($folder);
break;
case MODE_ABOUT:
echo DOCTYPE."<html><head>";
echo STYLE_HEADER .HTML_HEADERS ."\n";
echo "</head>";
echo "<body class=\"Pictures\">";
helpAbout();
break;
default:
$slideshow = new GRSlideShow();
$rc = $slideshow->InsertFolder( $folder);
if ($rc)
{
$slideshow->Go();
}
break;
}
}
class AlbumInfo
{
var $name;
var $folder;
var $group;
var $description;
var $scriptName;
var $menuThumbnail;
var $isDisabled;
var $isNew;
var $isGuestUploadEnabled;
var $numOfImages;
var $lastUpdate;
var $size;
var $visited;
var $albumFirstImage;
var $params;
var $musicFile;
function AlbumInfo($f, $ignoreHiddenAlbums = false)
{
$this->folder = $f;
$this->getAlbumParams();
$this->isDisabled = $this->getBooleanParam(TAG_DISABLED);
if ($this->isDisabled && $ignoreHiddenAlbums)
{
return;
}
$this->name = $this->getParam(TAG_ALBUM_NAME);
if (!$this->name || strlen($this->name)==0)
{
if (substr($this->folder, 0, 2)=="./")
{
$this->name = substr($this->folder,2);
}
else
{
$this->name = $this->folder;
}
}
$this->group = $this->getParam(TAG_ALBUM_GROUP);
if (AUTO_GROUP_NAME==1)
{
if (!strlen($this->group))
{
if (substr($this->folder, 0, 2)=="./")
{
$this->group = substr($this->folder,2,4);
}
else
{
$this->group = substr($this->folder,0,4);
}
}
}
$this->description = $this->getParam(TAG_ALBUM_DESCRIPTION);
if (strlen($this->description)==0)
{
$this->description = $this->name;
}
$this->scriptName = $this->getParam(TAG_SCRIPT_NAME);
$this->menuThumbnail = $this->getParam(TAG_MENU_THUMBNAIL);
if (strlen($this->menuThumbnail)==0)
{
$this->menuThumbnail = $this->albumFirstImage;
}
$this->isNew = $this->getBooleanParam(TAG_NEW);
$this->isGuestUploadEnabled = $this->getBooleanParam(TAG_GUEST_UPLOAD);
$this->musicFile = $this->getParam(TAG_MUSIC_FILE);
$this->size = getFormattedDirSize($this->folder);
$cookie = "";
$cookieName = str_replace(".", "",$this->folder);
$cookieName = str_replace(" ", "",$cookieName);
if (array_key_exists($cookieName,$_COOKIE))
{
$cookie = $_COOKIE[$cookieName];
}
$this->visited = true;
if ($this->isNew && $cookie != $this->numOfImages)
{
$this->visited = false;
}
}
function getParam($paramName)
{
if (array_key_exists($paramName,$this->params))
{
return $this->params[$paramName];
}
return "";
}
function getBooleanParam($paramName)
{
if (array_key_exists($paramName,$this->params))
{
if ($this->params[$paramName]=="on")
{
return true;
}
}
return false;
}
function getAlbumThumbnailFullPath()
{
$encoded_name = urlencode($this->menuThumbnail);
$encoded_name = str_replace('+' , '%20' , $encoded_name);
return $this->folder ."/thumbnails/".$encoded_name;
}
function getAlbumParams()
{
$this->numOfImages = 0;
$lastUpdate=0;
$handle = opendir($this->folder );
$this->params = array();
if ($handle )
{
while (false !== ($filename = readdir($handle)))
{
if (isValidImage($filename))
{
$this->albumFirstImage = $filename;
$this->numOfImages++;
$filemtime=filemtime("$this->folder/$filename");
if ($filemtime>$lastUpdate)
{
$lastUpdate = $filemtime;
}
}
}
}
closedir($handle );
if ($lastUpdate!=0)
{
//$this->lastUpdate = strftime(LAST_MODIFIED_DATE_FORMAT,$lastUpdate);
$this->lastUpdate = gmstrftime(LAST_MODIFIED_DATE_FORMAT,$lastUpdate);
}
$fileName = $this->folder ."/".ALBUM_DESCRIPTOR;
if (file_exists($fileName))
{
$f = @fopen($fileName, "r");
while ($f && !feof($f))
{
$line = fgets($f, 4096);
$regexp = "/^\"(.*)\"=\"(.*)\"/";
if (preg_match ($regexp, $line, $regs))
{
$this->params[$regs[1]] = $regs[2];
}
}
if ($f)
fclose($f);
}
}
}
function writePostToFile($params, $fieName)
{
$f = @fopen($fieName, "w");
if (!$f)
return;
foreach($params as $key=>$value)
{
$value = str_replace("\\", "",$value);
if (strstr($key,ROTATE_ANGEL))
continue;
if (strstr($key,TAG_PASSWORD))
continue;
if (!strlen($value))
continue;
fwrite($f,"\"$key\"=\"$value\"\n");
}
fclose($f);
}
/**********************************************
***********************************************
***********************************************
*** ***
*** Class Picture ***
*** ***
***********************************************
***********************************************
**********************************************/
Class Picture
{
var $_name;
var $_description;
var $_number;
var $_picturesFolder;
var $_thumbnailsFolder;
var $_picWidth;
var $_picHight;
var $thumbWidth;
var $thumbHight;
var $_parent;
var $_ratio;
var $_fileSize;
var $_baseicBuildUrl;
/*****************************************
** **
** Class Picture - Public functions **
** **
*****************************************/
///////////////////////////////////////////////////////////////
// constructor - initialize global class variables. //
///////////////////////////////////////////////////////////////
function Picture($name, $description, $dummy, $imgaenumber, $folderName="", $parent)
{
if (!isValidImage($name))
return;
$this->_ratio = 0;
$this->_parent = $parent;
$this->_name = $name;
$this->_description = $description;
//$this->_number = $imgaenumber;
$this->_setFolderNames($folderName);
if (!file_exists($this->_getPicturePath()))
{
echo "DEBUG: ERROR: the picture " . $this->_getPicturePath() . " does not exist<br/>";
return;
}
$this->_fileSize = filesize( $this->_getPicturePath() );
//if (!isJPG($filename))
// return ;
if (!$this->_fileSize)
return;
$picInfos = getimagesize( $this->_getPicturePath() );
if (!$picInfos)
{
myLog("Error: failed to get images size: " .$this->_getPicturePath());
return;
}
$this->_picWidth = $picInfos[0];
$this->_picHight = $picInfos[1];
$this->_ratio = $this->_picHight / $this->_picWidth;
}
function setUrl($url)
{
$this->_baseicBuildUrl = $url;
}
function _buildURL($mode, $imageNumber)
{
if ($mode == TAG_IMAGE_NUMBER_SINGLE_SLIDE)
{
$url = $this->_baseicBuildUrl."&".TAG_IMAGE_NUMBER_SINGLE_SLIDE."=" . $imageNumber;
}
else
{
$url = $this->_baseicBuildUrl. "&".TAG_MODE."=" .$mode ."&".TAG_IMAGE_NUMBER."=" . $imageNumber;
}
return $url;
}
function GetFormattedFileSize()
{
$KBSize = $this->_fileSize / 1024;
return number_format($KBSize, 2, '.', '') . " KB";
}
///////////////////////////////////////////////////////////////
// This function returns the file name. //
///////////////////////////////////////////////////////////////
function Name()
{
return $this->_name;
}
///////////////////////////////////////////////////////////////
// This function returns the file description //
///////////////////////////////////////////////////////////////
function Description()
{
return $this->_description;
}
function hasDescription()
{
return strlen($this->_description);
}
function SetDescription($desc)
{
$this->_description = $desc;
}
function getMode()
{
return $this->_parent->_mode;
}
function DisplayIndexThumnail($id="")
{
$this->_createIndexThumbnail();
echo "\n<a href=\"" . $this->_buildURL(TAG_IMAGE_NUMBER_SINGLE_SLIDE,$this->_number) ."\">";
echo "\n<img alt='' border='1' vspace='5' hspace='5' src=\"" . $this->_getThumbnailPath() ."\"" ;
//echo " width=" . $this->_getThumbnailWidth() . " height=" . $this->_getThumbnailHight();
if (strlen($id))
{
echo " id='$id' ";
}
echo " title=\"" . $this->Name() ;
if (strcmp($this->_description,"")) echo ": " .$this->_description ;
echo "\" align=\"bottom\" /></a>\n";
}
function LoadToCache($id = 'imgcache')
{
echo "\n<img id='$id' align='middle' border='0' src=\"" . $this->_getPicturePath() . "\" width=0 height=0 alt=''/>\n";
}
function renamePicture()
{
$regexp = "/^(.*).(.{3})/";
if (preg_match ($regexp, $this->_name, $regs))
{
$newName = $regs[1]."a." . $regs[2];
if (!file_exists($this->_picturesFolder. "/" . $newName))
{
$this->_name = $newName;
}
}
else
{
$this->_name = $this->_name . "_1.jpg";
}
}
function Rotate()
{
if (!isJPG($this->_getPicturePath()))
return ;
$degrees = $_POST[ROTATE_ANGEL];
$orig = imagecreatefromjpeg( $this->_getPicturePath() );
$orig = imagerotate($orig, $degrees, 0);
unlink($this->_getPicturePath());
$orig2 = null;
if (file_exists($this->_getOriginalPicturePath()))
{
$orig2 = imagecreatefromjpeg( $this->_getOriginalPicturePath() );
$orig2 = imagerotate($orig2, $degrees, 0);
unlink($this->_getOriginalPicturePath());
}
$this->renamePicture();
ImageJPEG($orig, $this->_getPicturePath() );
if ($orig2)
{
ImageJPEG($orig2, $this->_getOriginalPicturePath(),100 );
}
$picInfos = getimagesize( $this->_getPicturePath() );
$this->_picWidth = $picInfos[0];
$this->_picHight = $picInfos[1];
$this->_ratio = $this->_picHight / $this->_picWidth;
}
function needResize()
{
if (RESIZE_ORIGINAL_PICTURE != '1' && RESIZE_ORIGINAL_PICTURE != 1)
{
return false;;
}
if (!isJPG($this->_getPicturePath()))
{
return false;
}
if (!$this->_ratio)
return false;
$newwidth = 0;
$newheight = 0;
if ($this->_picWidth > $this->_picHight)
{
$newwidth = PICTURE_V_SIZE;
$newheight = $newwidth * $this->_ratio;
}
else
{
$newheight = PICTURE_H_SIZE;
$newwidth = $newheight / $this->_ratio;
}
if ($newwidth >= $this->_picWidth && $newheight >= $this->_picHight)
{
return false;
}
return true;
}
function createResizedImage($origImagePath, $origWidth, $origHeight, $newImagePath, $newWidth, $newHeight )
{
$width = 0;
$height = 0;
if ($this->_picWidth > $this->_picHight) // landscape
{
$width = $newWidth;
$height = $width * $this->_ratio;
}
else // portrate
{
$height = $newHeight;
$width = $height / $this->_ratio;
}
$orig = imagecreatefromjpeg ($origImagePath );
$new = imagecreatetruecolor ($width ,$height);
imagecopyresampled($new, $orig, 0, 0, 0, 0, $width, $height, $origWidth, $origHeight);
imagejpeg( $new, $newImagePath );
}
function ResizePicture()
{
if (!$this->needResize())
return;
$newwidth = 0;
$newheight = 0;
if ($this->_picWidth > $this->_picHight)
{
$newwidth = PICTURE_V_SIZE;
$newheight = $newwidth * $this->_ratio;
}
else
{
$newheight = PICTURE_H_SIZE;
$newwidth = $newheight / $this->_ratio;
}
$this->backupOriginal();
// $this->createResizedImage($this->_getPicturePath(), $this->_picWidth, $this->_picHight, $this->_getPicturePath(), PICTURE_V_SIZE, $newHeight );
$orig = @imagecreatefromjpeg( $this->_getPicturePath() );
if (!$orig)
{
return;
}
$new = imagecreatetruecolor ($newwidth ,$newheight);
if (!$new)
{
return;
}
imagecopyresampled($new, $orig, 0, 0, 0, 0, $newwidth, $newheight, $this->_picWidth, $this->_picHight);
imagejpeg( $new, $this->_getPicturePath() );
}
function backupOriginal()
{
if (ENABLE_KEEP_ORIGINAL_IMAGE !=1)
return;
$path = $this->_getOriginalPicturePath();
if (file_exists($path))
return;
$folder = $this->_picturesFolder . "/original";
if (!is_dir($folder))
{
$rc = @mkdir($folder,0777);
if (FALSE == $rc)
{
echo "Error: failed to mkdir $folder.<br/>".
"GRSlideShow must have permissions to create subdirecotries in directory $this->_picturesFolder";
die;
}
}
copy($this->_getPicturePath(),$path);
}
function DisplayPicture($linkable = true)
{
$this->ResizePicture();
$width = 0;
$height = 0;
if (!$this->_ratio)
{
return;
}
if ($this->_picWidth > $this->_picHight)
{
$width = PICTURE_V_SIZE;
$height = $width * $this->_ratio;
}
else
{
$height = PICTURE_H_SIZE;
$width = $height / $this->_ratio;
}
echo "\n";
$originalPath = $this->_getOriginalPicturePath();
//if (file_exists($originalPath))
if ($linkable && ENABLE_KEEP_ORIGINAL_IMAGE ==1)
echo "<a href=\"javascript:openOriginalImg()\">";
echo "<img alt='".$this->Description()."' onload=\"imageLoaded()\" id='imgmain' style=\"filter:alpha(opacity=100);-moz-opacity:1;opacity:1;\" align='middle' border=1 src=\"" .
$this->_picturesFolder . "/" . $this->_getEncodedName() . "\" ";
//$this->_getPicturePath() . "\" ";
//return $this->_picturesFolder . "/original/" . $this->_getEncodedName();
//return $this->_picturesFolder . "/" . $this->_name;
if (isJPG($this->_name) && IGNORE_MAIN_IMAGE_WIDTH_HEIGHT != 1 && $this->_picWidth > $width)
{
echo "width=$width height=$height ";
}
echo " />";
//if (file_exists($originalPath))
if ($linkable && ENABLE_KEEP_ORIGINAL_IMAGE ==1)
echo "</a>";
echo "\n";
}
/*****************************************
** **
** Class Picture - Private functions **
** **
*****************************************/
function _displayPrevNextImageThumbnail($id,$direction)
{
if (DISPLAY_SIDE_IMAGES_IN_SLIDE_SHOW == 0 && $this->getMode()== MODE_SLIDE_SHOW )
return;
if (DISPLAY_SIDE_IMAGES_IN_SINGLE_SLIDE == 0 && $this->getMode()== MODE_SINGLE_SLIDE )
return;
$this->_createSlideThumbnail();
echo "\n<a href=\"javascript:switchImage($direction,false)\">";
echo "\n<img id='$id' border=\"1\" src=\"" . $this->_getSlideThumbnailPath() ."\"";
//echo " width=" . $this->_getSlideThumbnailWidth() . " height=" . $this->_getSlideThumbnailHight() ;
echo "></a>\n";
}
function _isPortrait()
{
if ($this->_picWidth > $this->_picHight )
return 0;
else
return 1;
}
function _getPicturePath()
{
return $this->_picturesFolder . "/" . $this->_name;
}
function doesOriginalExist()
{
$path = $this->_getOriginalPicturePath();
if (file_exists($path))
return 'true';
else
return 'false';
}
function isReady()
{
if ($this->needResize())
return 'false';
if (!$this->doThumbnailsExists())
{
return 'false';
}
return 'true';
}
function doThumbnailsExists()
{
$file1 = $this->_picturesFolder . "/thumbnails/" . $this->_name;
$file2 = $this->_picturesFolder . "/thumbnails2/" . $this->_name;
if (file_exists($file1) && file_exists($file2))
{
return true;
}
else
{
return false;
}
}
function _getOriginalPicturePath()
{
return $this->_picturesFolder . "/original/" . $this->_getEncodedName();
}
function _getThumbnailPath()
{
return $this->_thumbnailsFolder . "/" . $this->_getEncodedName() ;
}
function _getEncodedName()
{
$encoded_name = urlencode($this->_name);
$encoded_name = str_replace('+' , '%20' , $encoded_name);
return $encoded_name;
}
function _getSlideThumbnailPath()
{
return $this->_slideThumbnailsFolder . "/" . $this->_getEncodedName();
}
function _setFolderNames($folderName)
{
if (strcmp("",$folderName))
{
if (is_dir($folderName ))
{
$this->_picturesFolder = $folderName ;
}
else
{
echo "Error! the picture folder $folderName does not exist";
return;
}
$this->_thumbnailsFolder = $folderName . "/" . "thumbnails";
$this->_slideThumbnailsFolder = $folderName . "/thumbnails2";
}
else
{
$this->_picturesFolder = "pictures";
$this->_thumbnailsFolder = "thumbnails";
$this->_slideThumbnailsFolder = "thumbnails";
}
}
function _getThumbnailWidth()
{
if ($this->_isPortrait() && $this->_ratio)
{
return THUMBNAIL_V_SIZE / $this->_ratio;
}
else
return THUMBNAIL_H_SIZE;
}
function _getThumbnailHight()
{
return THUMBNAIL_V_SIZE;
}
function _getSlideThumbnailWidth()
{
if ($this->_isPortrait())
return SLIDE_THUMBNAIL_V_SIZE;
else
return SLIDE_THUMBNAIL_H_SIZE;
}
function _getSlideThumbnailHight()
{
if ($this->_isPortrait())
return SLIDE_THUMBNAIL_H_SIZE;
else
return SLIDE_THUMBNAIL_V_SIZE;
}
function _deleteThumnails()
{
@unlink($this->_thumbnailsFolder . "/" . $this->_name);
@unlink($this->_slideThumbnailsFolder . "/" . $this->_name);
}
function createThumbnails()
{
$this->_createIndexThumbnail();
$this->_createSlideThumbnail();
}
function _createIndexThumbnail()
{
$this->_createThumbnail($this->_getThumbnailWidth(),$this->_getThumbnailHight(),$this->_thumbnailsFolder);
}
function _createSlideThumbnail()
{
$this->_createThumbnail($this->_getSlideThumbnailWidth(),$this->_getSlideThumbnailHight(), $this->_slideThumbnailsFolder);
}
function _isBlackThumbnail($orig)
{
// check the color in 100 pixels. if all is black, then this image is black.
for ($i=0;$i<200;$i++)
{
$x = rand(0,$this->_picWidth -1);
$y = rand(0, $this->_picHight -1);
$color = imagecolorat($orig,$x, $y);
if ($color!=0)
{
return false;
}
}
return true;
}
function _createThumbnail($width, $hight, $folder)
{
$thumbnail = $folder . "/" . $this->_name;
if (file_exists($thumbnail))
{
return;
}
if (strstr( $thumbnail, "http://"))
return;
if (!isJPG($this->_name))
{
copy($this->_getPicturePath(),$thumbnail);
return;
}
if (!function_exists("imagecreatefromjpeg"))
{
echo "Error: can not create image. Make sure GD library is installed.";
return;
}
$picInfos = getimagesize( $this->_getPicturePath() );
if (!$picInfos)
{
return; //error
}
$orig = @imagecreatefromjpeg( $this->_getPicturePath() );
if (!$orig || $orig=="")
{
return; //error!!!
}
$this->_picWidth = $picInfos[0];
$this->_picHight = $picInfos[1];
if ($this->_isBlackThumbnail($orig))
{
myLog("The image " .$this->_name . " is currupted. Thumbnail can not be created.");
return;
}
$newwidth = 0;
$newheight = 0;
if ($this->_picWidth > $this->_picHight)
{
$newwidth = $width;
$newheight = $newwidth * $this->_ratio;
}
else
{
$newheight = $hight;
$newwidth = $newheight / $this->_ratio;
}
$new = imagecreatetruecolor ($newwidth,$newheight);
$retval = imagecopyresampled($new, $orig, 0, 0, 0, 0, $newwidth, $newheight, $this->_picWidth, $this->_picHight);
if (!$retval)
{
//error
return;
}
if (!is_dir($folder))
{
$rc = mkdir($folder,0777);
if (FALSE == $rc)
{
echo "Error: failed to mkdir $folder.<br/>".
"GRSlideShow must have permissions to create subdirecotries in directory $this->_picturesFolder";
die;
}
chmod($folder,0777);
}
$b = imagejpeg( $new, $thumbnail );
//myLog($this->_name . "finished _createThumbnail " . $b);
}
function showPrintButton($hidden=false)
{
$currentPath = getCurrentPath();
$printrPicturePath = $this->_getPicturePath();
if (file_exists($this->_getOriginalPicturePath()))
{
$printrPicturePath = $this->_getOriginalPicturePath() ;
}
$printrThumbnailPath = $this->_getThumbnailPath();
echo "<form ";
if ($hidden)
echo " id='printr' ";
echo " action='http://www.grslideshow.com/tools.php' method='post' target='_blank'>";
echo "<input type='hidden' name='url' value='$printrPicturePath'>";
echo "<input type='hidden' name='thumb' value='$printrThumbnailPath'>";
echo "<input type='hidden' name='host' value='".$_SERVER['HTTP_HOST']."'>";
echo "<input type='hidden' name='path' value='".getCurrentPath()."'>";
//if (!$hidden)
//{
// echo "<input class='formbttn' type='submit' value='Print T-Shirt'>";
//}
echo "</form>";
}
} // end of class Picture
/**********************************************
***********************************************
***********************************************
*** ***
*** Class GRSlideShow ***
*** ***
***********************************************
***********************************************
**********************************************/
class GRSlideShow
{
var $_pictures;
var $_numOfPictures;
var $_indexPageTitle;
var $_imageNumber;
var $_mode;
var $_picturesFolder;
var $_thumbnailsFolder;
var $_folderName;
var $albumInfo;
var $orderList;
/*********************************************
** **
** class GRSlideShow - public functions **
** **
*********************************************/
///////////////////////////////////////////////////////////////
// constructor - initialize global class variables. //
///////////////////////////////////////////////////////////////
function GRSlideShow()
{
$this->_numOfPictures=0;
$this->_picturesFolder = "pictures";
$this->_thumbnailsFolder = "thumbnails";
$this->_mode = getMode(MODE_INDEX);
$this->updateCookies();
if (array_key_exists(TAG_IMAGE_NUMBER,$_GET))
{
$this->_imageNumber = intval($_GET[TAG_IMAGE_NUMBER]);
if ($this->_imageNumber<0)
{
$this->_imageNumber =0;
}
}
elseif (array_key_exists(TAG_IMAGE_NUMBER_SINGLE_SLIDE,$_GET))
{
$this->_imageNumber = intval($_GET[TAG_IMAGE_NUMBER_SINGLE_SLIDE]);
if ($this->_imageNumber<0)
{
$this->_imageNumber =0;
}
}
else
{
$this->_imageNumber = 0;
}
}
function getSpeed()
{
if (array_key_exists(COOKIE_NAME_SPEED,$_GET))
{
return $_GET[COOKIE_NAME_SPEED];
}
elseif (array_key_exists(TAG_SPEED,$_GET))
{
return $_GET[TAG_SPEED];
}
elseif (array_key_exists(COOKIE_NAME_SPEED,$_COOKIE))
{
return $_COOKIE[COOKIE_NAME_SPEED];
}
return 3;
}
function SetMode($mode)
{
$this->_mode = $mode;
}
///////////////////////////////////////////////////////////////
// This function adds a picture to the slideshow. //
///////////////////////////////////////////////////////////////
function InsertPicture($fileName, $fileDescription="", $folderName="")
{
if (!isValidImage($fileName))
return;
$pic = new Picture( $fileName,
$fileDescription,
"",
$this->_numOfPictures,
$folderName,
$this);
if ($pic->_fileSize)
{
$this->_pictures[$this->_numOfPictures] = $pic;
$this->_numOfPictures++;
}
}
///////////////////////////////////////////////////////////////
// This function adds all the files in a folder into the //
// slideshow. The description of this file is empty. In case //
// descriptionis needed, use SetPictureDescription //
///////////////////////////////////////////////////////////////
function InsertFolder($folderName)
{
TRACE ("InsertFolder was called with the folder $folderName");
if (is_dir($folderName ))
{
//do nothing
}
elseif (is_dir( "./" .$folderName ))
{
TRACE ("InsertFolder: ./$folderName exists");
$folderName = "./" .$folderName;
}
else
{
echo DOCTYPE."<html><head>";
echo STYLE_HEADER .HTML_HEADERS ."\n";
echo "</head>";
echo "<body class=\"Pictures\">";
echo "<table><tr><td align=center>The folder $folderName does not exist</td></tr>";
echo "<tr><td align=center>";
$this->_displayMainMenuButton("Main Menu");
echo "</td></tr></table>";
return false;
}
$this->_folderName = $folderName;
$this->moveVideoFiles();
$this->extractZipFiles();
$handle = opendir($folderName );
$filesAdded = 0;
if ($handle )
{
while (false !== ($file = readdir($handle)))
{
$this->InsertPicture($file,"",$folderName);
$filesAdded++;
}
closedir($handle);
if (0==$filesAdded)
{
echo ("Error: the folder $folderName does not contain any images");
return;
}
}
else
{
echo "Error! the picture folder $folderName does not exist";
return false;
}
$fileDescriptions = $this->GetFileDescriptions();
for ($i=0; $i< $this->_numOfPictures; $i++)
{
$name = str_replace(" ", "_",$this->_pictures[$i]->Name());
$name = str_replace(".", "_",$name);
if (array_key_exists($name,$fileDescriptions))
{
$this->_pictures[$i]->SetDescription($fileDescriptions[$name]);
}
}
$this->albumInfo = new AlbumInfo($this->_folderName);
$albumdescription = $this->albumInfo->description;
$this->SetIndexPageTitle($albumdescription);
if (sizeof($this->_pictures))
{
if (DEFAULT_SORT == "name")
{
usort($this->_pictures,"piccmpByName");
}
if (DEFAULT_SORT == "date")
{
usort($this->_pictures,"piccmpBydate");
}
}
for ($i=0;$i<sizeof($this->_pictures);$i++)
{
$this->_pictures[$i]->_number=$i;
$this->_pictures[$i]->setUrl($this->_buildURL(null, null));
//$this->_pictures[$i]->ResizePicture();
//$this->_pictures[$i]->createThumbnails();
}
$this->orderList = $this->getOrderList();
return true;
}
function moveVideoFiles()
{
$handle = opendir($this->_folderName);
if ($handle )
{
while (false !== ($file = readdir($handle)))
{
$regexp = "/^(.*)\.(avi|AVI|MOV|WMV|mov|wmv|MPG|mpg)/";
if (preg_match ($regexp, $file, $regs))
{
if (!is_dir($this->_folderName . "/video"))
{
mkdir($this->_folderName . "/video",0777);
}
$newFile = $this->_folderName . "/video/" .$file ;
rename($this->_folderName . "/" . $file,$newFile);
}
}
}
}
function extractZipFiles()
{
if (EXTRACT_ZIP_FILES != 1)
return;
if (!file_exists("Zip.php"))
return;
include_once("Zip.php");
$handle = opendir($this->_folderName);
if ($handle )
{
while (false !== ($file = readdir($handle)))
{
if (0==strcmp(".zip",strtolower(substr($file,-4))))
{
$rc = $this->extractZipFile($file);
if ($rc)
{
if (KEEP_ZIP_FILES != 1)
{
unlink("$this->_folderName/$file");
}
else
{
if (!is_dir("$this->_folderName/original"))
{
@mkdir("$this->_folderName/original",0777);
}
$fileName = $file;
$i=1;
while (file_exists("$this->_folderName/original/$fileName") && $i<20)
{
$regexp = "/^(.*).(.{3})/";
if (preg_match ($regexp, $file, $regs))
{
$fileName = $regs[1].".$i." . $regs[2];
}
$i++;
}
if (file_exists("$this->_folderName/original/$fileName"))
{
MyLog("ERROR: the files $this->_folderName/original/$fileName alreday exists. can not rename");
die;
}
rename("$this->_folderName/$file","$this->_folderName/original/$fileName");
}
}
else
{
MyLog("failed to extract $this->_folderName/$file");
}
}
}
}
closedir($handle);
}
function extractZipFile($file)
{
$zip = new Archive_Zip("$this->_folderName/$file");
$params=array();
$tempDir = $this->_folderName ."/" . time();
$params['add_path']=$tempDir;
$params['remove_all_path']=true;
$rc = $zip->extract($params);
if ($rc==0)
{
MyLog("failed to extract $this->_folderName/$file");
if (is_dir($tempDir))
{
rmdir($tempDir);
}
return false; //error
}
else
{
MyLog("extracted $this->_folderName/$file to $tempDir");
$dir = dir($tempDir);
while($file = $dir->read())
{
$regexp = "/^(.*)\.(avi|AVI|MOV|WMV|mov|wmv|MPG|mpg)/";
if (preg_match ($regexp, $file, $regs))
{
if (!is_dir($this->_folderName . "/video"))
{
mkdir($this->_folderName . "/video",0777);
}
$newFile = $this->_folderName . "/video/" .$file ;
rename($tempDir . "/" . $file,$newFile);
}
else
if ($file != '.' && $file != '..')
{
$shouldMove = true;
$i=1;
$newFile = $this->_folderName . "/" .$file ;
while (file_exists($newFile) && $i<20)
{
$i++;
$regexp = "/^(.*)\.(...)/";
if (preg_match ($regexp, $file, $regs))
{
$newFile = $this->_folderName . "/" . $regs[1] .".$i." . $regs[2];
}
else
{
$shouldMove = false;
continue;
//MyLog("ERROR: preg_match failed => $file");
}
}
if (!$shouldMove)
{
MyLog("ERROR: The file $file will not be moved");
}
if ($shouldMove && file_exists($newFile))
{
echo "ERROR: The file $newFile already exists. Failed to extract and rename $file. FATAL ERROR";
MyLog("FATAL ERROR: The file $newFile already exists. Failed to rename");
die;
}
else
{
rename($tempDir . "/" . $file,$newFile);
}
}
}
$dir->close();
rmdir($tempDir);
MyLog("deleted tempdir $tempDir");
return true;
}
}
function RotatePicture($pic)
{
for ($i=0; $i< $this->_numOfPictures; $i++)
{
if ($pic == $this->_pictures[$i]->Name())
{
$this->_pictures[$i]->_deleteThumnails();
$this->_pictures[$i]->Rotate();
return;
}
}
}
function updateCookies()
{
if (array_key_exists(TAG_SPEED,$_GET))
{
if (is_numeric($_GET[TAG_SPEED]))
SetCookie(COOKIE_NAME_SPEED,$_GET[TAG_SPEED] ,time()+31536000,"/");
}
if (array_key_exists(TAG_USER,$_GET))
{
if (!array_key_exists(TAG_USER,$_COOKIE))
{
SetCookie(TAG_USER,$_GET[TAG_USER] ,time()+31536000,"/");
}
}
}
///////////////////////////////////////////////////////////////
// This function sets a title to the index page //
///////////////////////////////////////////////////////////////
function SetIndexPageTitle($str)
{
$this->_indexPageTitle = $str;
}
function _displayPrevImageThumbnail($currentImage)
{
$this->_pictures[$this->_getPrevImageNumber($currentImage)]->_displayPrevNextImageThumbnail('imgback','-1');
}
function _displayNextImageThumbnail($currentImage)
{
$this->_pictures[$this->_getNextImageNumber($currentImage)]->_displayPrevNextImageThumbnail('imgnext','1');
}
function _getNextImageNumber($num)
{
return ($num+1) % $this->_numOfPictures ;
}
function _getPrevImageNumber($num)
{
return ($num -1 + $this->_numOfPictures) % $this->_numOfPictures ;
}
function _buildURL($mode, $imageNumber)
{
$url = $_SERVER['SCRIPT_NAME'] . "?".TAG_FOLDER."=" . $this->_folderName ;
if ($mode == TAG_IMAGE_NUMBER_SINGLE_SLIDE)
{
$url = $url ."&".TAG_IMAGE_NUMBER_SINGLE_SLIDE."=" . $imageNumber;
}
else
{
if ($mode !=null )
$url = $url. "&".TAG_MODE."=" .$mode ;
if ($imageNumber != null)
$url = $url ."&".TAG_IMAGE_NUMBER."=" . $imageNumber;
}
return $url;
}
function UpdateAlbum($params = null)
{
if ($params == null)
$params = $_POST;
if (!validatePassword())
{
echo "You are not authorized to access this page";
return;
}
if (CREATE_INDEX_FOR_SUBFOLDER ==1)
{
$f = @fopen($this->_folderName ."/index.php", "w");
$str = DOCTYPE."<html><body><script type='text/javascript'>\nwindow.location='".$this->_buildURL(MODE_INDEX, 0) ."';\n</script></body></html>";
fwrite($f,$str );
fclose($f);
}
writePostToFile($params,$this->_folderName ."/".ALBUM_DESCRIPTOR);
$this->albumInfo = new AlbumInfo($this->_folderName);
}
function GetFileDescriptions()
{
$fileDescriptions = array();
$fileName = $this->_folderName ."/".ALBUM_DESCRIPTOR;
if (file_exists($fileName))
{
$f = fopen($fileName, "r");
while ($f && !feof($f))
{
$line = fgets($f,4096);
$regexp = "/^\"".TAG_FILE_DESCRIPTION."(.*)\"=\"(.*)\"/";
if (preg_match ($regexp, $line, $regs))
{
$fileDescriptions[$regs[1]] = $regs[2];
}
}
}
return $fileDescriptions;
}
function showEditAlubmToolbar()
{
echo "<table><tr valign=top>";
echo "<td><input type='button' class=formbttn value='Apply' onclick='Apply()'></td>";
echo "<td><input type='button' class=formbttn value='OK' onclick='OK()'></td>";
echo "<td><input type='button' class=formbttn value='Cancel' onclick='Cancel()'></td>";
echo "<td> </td>";
echo "<td><input type='button' class=formbttn value='Upload' onclick='Upload()'></td>";
echo "</tr></table>";
}
function EditAlbum()
{
MyLog("edit " . $this->_folderName);
$fileDescriptions = $this->GetFileDescriptions();
$albums = getAlbums();
echo DOCTYPE."<html><head>";
echo STYLE_HEADER .HTML_HEADERS ."\n";
?>
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="Expires" CONTENT="Tue, 4 Nov 1995 21:23:00 GMT">
<META HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<script type='text/javascript'>
var hasMadeChanges = false;
function rotateImage(fileName, radio)
{
if (hasMadeChanges)
{
var rc= confirm ("The changes made have not been saved yet. \nIf you continue, all changes will be lost. \nDo you want to continue? ");
if (rc == false)
{
return;
}
}
document.all.rotateform.<?php echo TAG_PICTURE_NAME?>.value=fileName;
for (i=0; i < radio.length; i++)
{
if (radio[i].checked)
{
document.all.rotateform.<?php echo ROTATE_ANGEL?>.value = radio[i].value;
continue;
}
}
document.all.rotateform.submit();
}
function deleteImage(fileName)
{
if (hasMadeChanges)
{
var rc= confirm ("The changes made have not been saved yet. \nDeleting an image now will loose all the changes you have made. \nDo you want to continue? ");
if (rc == false)
{
return;
}
}
var msg= 'Click OK to delete ' + fileName ;
var rc = confirm(msg);
if (rc==true)
{
document.all.deleteform.<?php echo TAG_PICTURE_NAME?>.value=fileName;
document.all.deleteform.submit();
}
}
function showMoveDiv(div_id, but)
{
if (hasMadeChanges)
{
var rc= confirm ("The changes made have not been saved yet. \nIf you continue, all changes will be lost. \nDo you want to continue? ");
if (rc == false)
{
return;
}
}
div = document.getElementById(div_id);
div.style.display='';
div.style.visibility='visible';
but.style.display='none';
but.style.visibility='hidden';
}
function moveImage(fileName, selector)
{
albumFolder = selector.value;
if (albumFolder=='')
{
alert('Select destination album.');
return;
}
var msg= "The file '" + fileName + "' will be moved to the folder '" + albumFolder + "'";
var rc = confirm(msg);
if (rc==true)
{
document.all.moveform.<?php echo TAG_PICTURE_NAME?>.value=fileName;
document.all.moveform.<?php echo TAG_NEW_PICTURE_NAME?>.value=fileName;
document.all.moveform.<?php echo TAG_NEW_FOLDER?>.value=albumFolder;
document.all.moveform.submit();
}
}
function renameImage(fileName, newFileName)
{
var msg= "The file '" + fileName + "' will be renamed to '" + newFileName + "'";
var rc = confirm(msg);
if (rc==true)
{
document.all.moveform.<?php echo TAG_PICTURE_NAME?>.value=fileName;
document.all.moveform.<?php echo TAG_NEW_PICTURE_NAME?>.value=newFileName;
document.all.moveform.submit();
}
}
var nameAndDescriptionAreTheSame = true;
function AlbumNameKeyUp()
{
if (!nameAndDescriptionAreTheSame)
{
return;
}
var albumName = document.getElementById('<?php echo TAG_ALBUM_NAME ?>');
var albumDescription = document.getElementById('<?php echo TAG_ALBUM_DESCRIPTION ?>');
albumDescription.value = albumName.value ;
}
function AlbumNameKeyDown()
{
var albumName = document.getElementById('<?php echo TAG_ALBUM_NAME ?>');
var albumDescription = document.getElementById('<?php echo TAG_ALBUM_DESCRIPTION ?>');
if (albumName.value == albumDescription.value)
{
nameAndDescriptionAreTheSame = true;
}
else
{
nameAndDescriptionAreTheSame = false;
}
}
function updateThumbnail()
{
sel = document.getElementById('<?php echo TAG_MENU_THUMBNAIL ?>');
thumbnail = document.getElementById('menuthumbnail');
if (sel && thumbnail)
{
hasMadeChanges=true;
thumbnail.src = "<?php echo $this->_folderName ?>/thumbnails/" + sel.value;
}
}
function submitPage(mode)
{
<?php
if (preg_match("/msie/i",$_SERVER['HTTP_USER_AGENT']))
{
echo "document.mainform.". TAG_MODE .".value=mode;\n";
echo "document.mainform.submit();\n";
}
else
{
echo "frm = document.getElementById('mainform');\n";
echo "m1 = document.getElementById('". TAG_MODE ."');\n";
echo "m1.value = mode;\n";
echo "frm.submit();\n";
}
?>
}
function Upload()
{
if (hasMadeChanges)
{
var rc= confirm ("Are you sure you want to exit without saving your changes?")
if (rc == false)
{
return;
}
}
submitPage('<?php echo MODE_CHOOSE_PICTURES ?>');
}
function Cancel()
{
if (hasMadeChanges)
{
var rc= confirm ("Are you sure you want to exit without saving your changes?")
if (rc == false)
{
return;
}
}
submitPage('<?php echo MODE_FOLDER_MNG ?>');
}
function OK()
{
submitPage('<?php echo MODE_UPDATE_ALBUM_BACK_TO_MAIN ?>');
}
function Apply()
{
submitPage('<?php echo MODE_UPDATE_ALBUM ?>');
}
</script>
<?php
echo "</head>";
echo "<body class=\"Pictures\">";
if (!validatePassword())
{
echo "You are not authorized to access this page";
return;
}
$this->showEditAlubmToolbar();
echo "\n\n<form name='rotateform' method=post action='".$_SERVER['SCRIPT_NAME']."'>\n";
echo "<input type='hidden' name='".TAG_MODE."' value='".MODE_ROTATE_PICTURE."'>\n";
echo "<input type=hidden name='".TAG_PASSWORD."' value='".ADMIN_PASSWORD."'>";
echo "<input type='hidden' name='".TAG_FOLDER."' value='".$this->_folderName."'>\n";
echo "<input type='hidden' name='".TAG_PICTURE_NAME."' value=''>\n";
echo "<input type='hidden' name='".ROTATE_ANGEL."' value='45'>\n";
echo "</form>";
echo "\n\n<form name='deleteform' method=post action='".$_SERVER['SCRIPT_NAME']."'>\n";
echo "<input type='hidden' name='".TAG_MODE."' value='".MODE_DELETE_PICTURE."'>\n";
echo "<input type=hidden name='".TAG_PASSWORD."' value='".ADMIN_PASSWORD."'>";
echo "<input type='hidden' name='".TAG_FOLDER."' value='".$this->_folderName."'>\n";
echo "<input type='hidden' name='".TAG_PICTURE_NAME."' value=''>\n";
echo "</form>\n";
echo "\n<form name='moveform' method=post action='".$_SERVER['SCRIPT_NAME']."'>\n";
echo "<input type='hidden' name='".TAG_MODE."' value='".MODE_MOVE_PICTURE."'>\n";
echo "<input type=hidden name='".TAG_PASSWORD."' value='".ADMIN_PASSWORD."'>";
echo "<input type='hidden' name='".TAG_FOLDER."' value='".$this->_folderName."'>\n";
echo "<input type='hidden' name='".TAG_PICTURE_NAME."' value=''>\n";
echo "<input type='hidden' name='".TAG_NEW_FOLDER."' value='".$this->_folderName."'>\n";
echo "<input type='hidden' name='".TAG_NEW_PICTURE_NAME."' value=''>\n";
echo "</form>\n";
echo "</td>\n";
echo "\n<form name='mainform' id='mainform' method=post action='".$_SERVER['SCRIPT_NAME']."'>\n";
echo "<input type=hidden name='".TAG_PASSWORD."' value='".ADMIN_PASSWORD."'>";
echo "<input type='hidden' name='".TAG_MODE."' id='".TAG_MODE."' value='abcd'>\n";
echo "<input type='hidden' name='".TAG_FOLDER."' value='".$this->_folderName."'>\n";
echo "<div>\n";
echo "<table border=1 cellspacing=0 cellpadding=0 >\n";
echo "<tr class=title><td >Folder Name:</td><td colspan=9 align=left>" . $this->_folderName . "</td></tr>\n";
echo "<tr class=title>\n";
echo "<td valign='middle' colspan=9><input onchange=\"hasMadeChanges=true\" type=checkbox name='".TAG_DISABLED."' ";
$disabled = getAlbumParam($this->_folderName,TAG_DISABLED);
if ($disabled=="on")
echo "checked ";
echo "> Do not show a link to this album in the main menu. </td>\n";
echo "</tr>";
echo "<tr class=title>";
echo "<td valign='middle' colspan=9><input onchange=\"hasMadeChanges=true\" type=checkbox name='".TAG_NEW."' ";
if ($this->albumInfo->isNew)
echo "checked ";
echo "> Mark this album as 'new' if album was changed since the last time it was viewed.</td>\n";
echo "</tr>";
if (ENABLE_GUEST_UPLOAD==1)
{
echo "<tr class=title>";
echo "<td valign='middle' colspan=9><input onchange=\"hasMadeChanges=true\" type=checkbox name='".TAG_GUEST_UPLOAD."' ";
if ($this->albumInfo->isGuestUploadEnabled)
echo "checked ";
echo "> Allow guests to add pictures to this album.</td>\n";
echo "</tr>";
}
echo "<tr class=title><td >Album Name:</td>\n";
echo "<td valign='middle' colspan=9><input onchange=\"hasMadeChanges=true\" onkeyup=\"AlbumNameKeyUp()\" type=text name='".TAG_ALBUM_NAME."' id='".TAG_ALBUM_NAME."' value='".$this->albumInfo->name."' size=50>(Appears in the main menu)</td>\n";
echo "</tr>";
echo "<tr class=title><td>Album Description:</td>\n";
$desc = "";
if (strcmp($this->albumInfo->description,$this->albumInfo->name))
{
$desc = $this->albumInfo->description;
}
echo "<td colspan=9 valign='middle'><input onchange=\"hasMadeChanges=true\" onkeydown=\"nameAndDescriptionAreTheSame = false;\" type=text name='".TAG_ALBUM_DESCRIPTION."' id='".TAG_ALBUM_DESCRIPTION."' value='$desc' size=50>(Appears on top of the index page)</td>\n";
echo "</tr>";
if (strlen($this->albumInfo->description))
{
echo "<script type='text/javascript'>nameAndDescriptionAreTheSame = false;</script>";
}
echo "<tr class=title>";
echo "<td >Alternate URL:</td>";
echo "<td colspan=9 valign='middle'><input type=text onchange=\"hasMadeChanges=true\" name=\"".TAG_SCRIPT_NAME ."\" value='".$this->albumInfo->scriptName."' size=50>";
echo "(URL to open instead of this album)</td>";
echo "</tr>";
if (ENABLE_MUSIC==1)
{
echo "<tr class=title>";
echo "<td >Midi File:</td>";
echo "<td colspan=9 valign='middle'><input type=text onchange=\"hasMadeChanges=true\" name=\"".TAG_MUSIC_FILE ."\" value='".$this->albumInfo->musicFile."' size=50>";
echo "(midi file to play when album loads)</td>";
echo "</tr>";
}
if (ENABLE_ALBUMS_GROUPS==1)
{
echo "<tr class=title><td >Album Group:</td>\n";
echo "<td valign='middle' colspan=9><input onchange=\"hasMadeChanges=true\" type=text name='".TAG_ALBUM_GROUP."' id='".TAG_ALBUM_GROUP."' value='".$this->albumInfo->group."' size=50></td>\n";
echo "</tr>";
}
if (isThumbnailsMenuEnabled())
{
echo "<tr class=title><td>Menu Thumbnail:</td>\n";
echo "<td valign='middle' colspan=2><select onchange=\"updateThumbnail()\" name='".TAG_MENU_THUMBNAIL."' id='".TAG_MENU_THUMBNAIL."' >\n";
$menuThumbnailNumber=0;
if ($this->_numOfPictures)
for ($i=0; $i< $this->_numOfPictures; $i++)
{
echo "<option value='".$this->_pictures[$i]->Name() ."'";
if ($this->_pictures[$i]->Name() ==$this->albumInfo->menuThumbnail)
{
$menuThumbnailNumber = $i;
echo " selected ";
}
echo " >".$this->_pictures[$i]->Name()."</option>";
}
echo "</select>\n";
echo "</td><td colspan=9>\n";
if ($this->_numOfPictures)
$this->_pictures[$menuThumbnailNumber]->DisplayIndexThumnail('menuthumbnail');
echo "</td>\n";
echo "</tr>";
}
for ($i=0; $i< $this->_numOfPictures; $i++)
{
$this->_pictures[$i]->ResizePicture();
$this->_pictures[$i]->createThumbnails();
echo "<tr>";
echo "<td class=title><b>".intval($i+1).".</b> ". $this->_pictures[$i]->Name() . "</td>";
echo "<td align=\"center\" valign=\"top\" nowrap='nowrap' />";
$this->_pictures[$i]->DisplayIndexThumnail();
echo "</td>";
$fileDescKeyName = str_replace(" ", "_",$this->_pictures[$i]->Name());
$fileDescKeyName = str_replace(".", "_",$fileDescKeyName);
$fileDesc = "";
if (array_key_exists($fileDescKeyName,$fileDescriptions))
{
$fileDesc = $fileDescriptions[$fileDescKeyName];
}
echo "<td valign='middle' class=title>";
echo "<input type=button class=formbttn value='rotate' onclick=\"rotateImage('".$this->_pictures[$i]->Name()."', document.all.".ROTATE_ANGEL."$i)\">";
echo "<br/><input name='".ROTATE_ANGEL."$i' type='radio' value='270' checked>90°";
echo "<br/><input name='".ROTATE_ANGEL."$i' type='radio' value='180'>180°";
echo "<br/><input name='".ROTATE_ANGEL."$i' type='radio' value='90'>270°";
echo "</td>";
echo "<td valign='middle' class='title'>Subtitle:<br/><input type=text name=\"".TAG_FILE_DESCRIPTION ."$fileDescKeyName\" value=\"$fileDesc\" size=30 onchange=\"hasMadeChanges=true\">";
echo "</td>\n";
echo "<td class=title>" . $this->_pictures[$i]->GetFormattedFileSize() . "</td>\n";
if (SHOW_IMAGE_RATIO==1)
{
echo "<td class=title>" . $this->_pictures[$i]->_ratio . "</td>\n";
}
echo "<td class=title>";
echo "<table>";
echo "<tr><td align=center>";
echo "<input type=button class=formbttn value='rename' onclick=\"showMoveDiv('div_rename_$i', this)\">";
echo "</td></tr>";
echo "<tr><td align=center>";
echo "<input type=button class=formbttn value='delete' onclick=\"deleteImage('".$this->_pictures[$i]->Name()."')\">\n";
echo "</td></tr>";
echo "<tr><td align=center>";
echo "<input type=button class=formbttn value='move' onclick=\"showMoveDiv('div_move_$i', this)\">";
echo "</td></tr>";
echo "</table>";
echo "</td>\n";
echo "<td>\n";
echo "<div id='div_move_$i' style=\"display:none;visibility :hidden \">";
echo "<table>";
echo "<tr><td class=title>";
echo "Choose Destination:";
echo "</td></tr>";
echo "<tr><td>";
echo "<select name='move$i'>\n";
echo "\t\t<option value=''>Select Album</option>\n";
foreach($albums as $album)
{
echo "\t\t<option value='".$album->folder."'>".$album->name."</option>\n";
}
echo "</select>";
echo "</td></tr>";
echo "<tr><td align=center>";
echo "<input type=button class=formbttn value='Move' onclick=\"moveImage('".$this->_pictures[$i]->Name()."',document.all.move$i)\">";
echo "</td></tr>";
echo "</table>";
echo "</div>";
echo "<div id='div_rename_$i' style=\"display:none;visibility :hidden \">";
echo "<table>";
echo "<tr><td class=title>";
echo "New File Name:";
echo "</td></tr>";
echo "<tr><td>";
echo "<input type=text name='rename$i' value='".$this->_pictures[$i]->Name()."'>\n";
echo "</td></tr>";
echo "<tr><td align=center>";
echo "<input type=button class=formbttn value='Rename' onclick=\"renameImage('".$this->_pictures[$i]->Name()."',document.all.rename$i.value)\">";
echo "</td></tr>";
echo "</table>";
echo "</div>";
echo "</td>";
echo "</tr>\n";
}
echo "</table>\n";
echo "</div>";
echo "</form>";
$this->showEditAlubmToolbar();
echo "</body></html>";
}
function _isNewRow($i)
{
if ( $i%NUMBER_OF_TUMBNAILS_IN_INDEX_ROW == 0)
return true;
else
return false;
}
function _log($comment="")
{
if (ENABLE_LOG!=1)
return;
$str = $this->albumInfo->name ;
if (strlen($str)==0)
$str = $this->_folderName ;
if (strlen( $comment ))
$str = $str . " " . $comment;
myLog($str);
}
function updateOrderList()
{
$fileName = $this->getOrderListFileName();
$f = @fopen($fileName, "w");
if (!$f)
return;
foreach($_POST as $key=>$value)
{
$regexp = "/^(.*)_(...)/";
if (preg_match ($regexp, $key, $regs))
{
$key = $regs[1] . "." . $regs[2];
}
if (intval($value)>0)
{
fwrite($f,"\"$key\"=\"$value\"\n");
}
}
fclose($f);
}
function dispalyPageOrderList()
{
echo HTML_TAG ."<head>";
echo STYLE_HEADER .HTML_HEADERS ."\n";
echo "</head>";
echo "<body class=\"Pictures\">";
$this->_displayToolbar();
echo "<form method=post action='".$_SERVER['SCRIPT_NAME']."'>\n";
echo "<input type='hidden' name='".TAG_MODE."' value='".MODE_ORDER_UPDATE."'>\n";
echo "<input type='hidden' name='".TAG_FOLDER."' value='$this->_folderName'>\n";
echo "<table border=1>";
echo "<tr><td>Picture</td><td>File Name</td><td>Amount</td></tr>";
foreach ($this->_pictures as $picture)
{
if (array_key_exists($picture->Name(),$this->orderList))
{
echo "<tr>";
echo "<td>";
$picture->DisplayIndexThumnail();
$name = str_replace(" ", "_",$picture->Name());
$name = str_replace(".", "_",$name);
echo "</td>";
echo "<td>".$picture->Name()."</td>";
echo "<td><input size=2 name='$name' type=text value='".$this->orderList[$picture->Name()]."'></td>\n";
echo "</tr>";
}
}
echo "</table>";
echo "<input type=submit class='formbttn2' value='Update List'></form>";
echo "</body>";
echo "</html>";
}
function _displayHandOutPage()
{
echo "<table width='100%' border=1>";
$i=0;
for( $i=0 ; $i<sizeof($this->_pictures) ; $i++)
{
if ($i % 4 == 0)
echo "<tr>";
echo "\t<td>\n\t\t";
echo "<table border=0 width='100%'>";
echo "<tr><td>";
$this->_pictures[$i]->DisplayIndexThumnail();
echo "</td><td>";
echo $this->_pictures[$i]->Name();
echo "<br/>__________<br/>__________";
echo "</td></tr></table>";
echo "\n\t</td>\n";
if (($i+1)%4 == 0)
echo "</tr>\n";
}
if (($i+2)%3 != 0)
echo "</tr>";
echo "</table>";
}
function _displayVideoPage()
{
$this->_displayDownloadPage('video');
}
function _displayCreditPage()
{
echo HTML_TAG ."<head>";
echo STYLE_HEADER .HTML_HEADERS ."\n";
echo "</head>";
echo "<body class=\"Pictures\">";
echo "</body>";
echo
"<a href='http://www.grslideshow.com'>GRSlideShow<a/> is a free, open source, online photo album script for lazy webmasters, developed on 2000 by Yair Bar-On.<br/>".
"Among my other projects I sell <a href='http://www.gemalaya.com'>high quality gemstones</a> on the net and develop web sites for living.<br/>".
"The gemstones I sell are 100% natural untreated gemstones.";
echo "</html>";
}
function _displayDownloadPage($downloaddir = 'original')
{
$this->_log("download");
echo HTML_TAG ."<head>";
echo STYLE_HEADER .HTML_HEADERS ."\n";
echo "</head>";
echo "<body class=\"Pictures\">";
echo "<table border=0><tr><td align=center>";
$this->_displayToolbar() ;
echo "</td></tr>";
$handle = opendir("$this->_folderName/$downloaddir");
$filesFound = false;
if ($handle )
{
while (false !== ($file = readdir($handle)))
{
if ($file !="." && $file !="..")
{
$filesFound = true;
$encoded_name = urlencode($file);
$encoded_name = str_replace('+' , '%20' , $encoded_name);
echo "<tr><td align=center><a href='$this->_folderName/$downloaddir/$encoded_name'>$file</a></td></tr>";
}
}
closedir($handle);
}
if (!$filesFound)
{
echo "<tr><td align=center>No files available for download</td></tr>";
}
echo "</table>";
}
function displayAllInOneToolbar($imageNumber,$maxNumOfImages,$mode)
{
$from = $imageNumber + 1;
$to = $maxNumOfImages + $imageNumber ;
if ($to > sizeof($this->_pictures ))
{
$to = sizeof($this->_pictures );
}
$numOfPages = sizeof($this->_pictures ) / $maxNumOfImages ;
$currentPage = intval($from / $maxNumOfImages)+1;
echo "Page $currentPage: Images $from - $to<br/>";
echo "<table><tr>";
echo "<td>Page ";
for ($i=1; $i<$numOfPages + 1;$i++)
{
if ($currentPage !=$i)
{
$startImg = ($i-1)*$maxNumOfImages;
echo "<a href='".$this->_buildURL($mode,$startImg)."'>$i</a> ";
}
else
{
echo "<b>$i</b> ";
}
}
echo "</td>";
if ($currentPage>1)
{
$startImg = $imageNumber - $maxNumOfImages;
echo "<td> <input type=button title='Click to view next $maxNumOfImages images' class='formbttn2' onclick=\"window.location='".$this->_buildURL($mode,$startImg)."'\" value='Previous'></td>";
}
if ($currentPage<$numOfPages)
{
$startImg = $imageNumber + $maxNumOfImages;
echo "<td> <input type=button title='Click to view next $maxNumOfImages images' class='formbttn2' onclick=\"window.location='".$this->_buildURL($mode,$startImg)."'\" value='Next'></td>";
}
echo "</tr></table>";
}
function _displayPageViewAll()
{
$this->_log("AllInOne");
echo HTML_TAG ."<head>";
$imageNumber = 0;
if (array_key_exists(TAG_IMAGE_NUMBER,$_GET))
{
$imageNumber = $_GET[TAG_IMAGE_NUMBER];
}
if (array_key_exists(TAG_IMAGE_NUMBER,$_POST))
{
$imageNumber = $_POST[TAG_IMAGE_NUMBER];
}
echo STYLE_HEADER .HTML_HEADERS ."\n";
echo "<script type='text/javascript'>";
echo "function imageLoaded(){}\n";
echo "function openOriginalImg(){}\n";
echo "</script>";
echo "</head>";
echo "<body class=\"Pictures\">";
if (0==sizeof($this->_pictures ))
{
echo "<span class='title'>Album is empty.</span>";
return;
}
echo "<div align='".ALL_IN_ONE_ALIGNMENT."'>\n";
echo "<table border=0><tr><td align=center>";
$this->_displayToolbar() ;
echo "</td></tr>";
if ( sizeof($this->_pictures) > MAX_NUM_OF_IMAGES_IN_ALL_IN_ONE )
{
echo "<tr><td align=center>";
$this->displayAllInOneToolbar($imageNumber,MAX_NUM_OF_IMAGES_IN_ALL_IN_ONE,MODE_VIEW_ALL);
echo "</td></tr>";
}
for( $i=$imageNumber ; $i<sizeof($this->_pictures) && $i< $imageNumber + MAX_NUM_OF_IMAGES_IN_ALL_IN_ONE; $i++)
{
$num = $i+1;
$picture = $this->_pictures[$i];
echo "<tr><td><hr><p>$num. " . $picture->Name() ;
if ($picture->hasDescription())
echo " : " . $picture->Description();
echo "<p>";
$picture->DisplayPicture(false);
echo "<br/>";
$picture->showPrintButton();
echo "</td>";
echo "<td>";
$picture->showPrintButton();
echo "</td>";
echo "</tr>";
}
if ( sizeof($this->_pictures) > MAX_NUM_OF_IMAGES_IN_ALL_IN_ONE )
{
echo "<tr><td align=center>";
$this->displayAllInOneToolbar($imageNumber,MAX_NUM_OF_IMAGES_IN_ALL_IN_ONE,MODE_VIEW_ALL);
echo "</td></tr>";
}
echo "<tr><td align=center>";
$this->_displayToolbar() ;
echo "</td></tr>";
echo "</table>";
echo "</div>";
echo "</body>";
echo "</html>";
}
function _displayToolbar()
{
echo "<table><tr valign=top>";
if (SHOW_EXIT_BUTTTON_IN_INDEX_PAGE == 1)
{
echo "<td><input type=button class='formbttn2' value='Exit' onclick='window.close()'></td>\n";
}
if (SHOW_BACK_TO_MAIN_BUTTTON == 1)
{
echo "<td>";
$this->_displayMainMenuButton("Main Menu");
echo "</td>";
}
if ($this->_mode !=MODE_VIEW_ALL && sizeof($this->_pictures ))
{
echo "<td><input type=button class='formbttn2' title='Click to see all pictures in one page' value='All In One' onclick=\"window.location='". $this->_buildURL(MODE_VIEW_ALL,0) . "'\"></td>\n";
}
if ($this->_mode !=MODE_INDEX && sizeof($this->_pictures ))
{
echo "<td><input type=button class=formbttn2 value='". THIS_ALBUM ."' onclick=\"window.location='" .$this->_buildURL(MODE_INDEX, 0) ."'\"></td>\n";
}
if ( sizeof($this->_pictures ))
{
echo "<td><input type=button class=formbttn2 title='Click to start slideshow' value='Play' onclick=\"window.location='". $this->_buildURL(MODE_SLIDE_SHOW,0) . "'\"></td>\n";
}
if ($this->_mode !=MODE_DOWNLOAD && is_dir("$this->_folderName/original"))
{
echo "<td><input type=button title='Click to download original files' class=formbttn2 value='Download' onclick=\"window.location='". $this->_buildURL(MODE_DOWNLOAD,0) . "'\"></td>\n";
}
if ($this->_mode !=MODE_VIDEO && is_dir("$this->_folderName/video"))
{
echo "<td><input type=button title='Click to download video files' class=formbttn2 value='Video' onclick=\"window.location='". $this->_buildURL(MODE_VIDEO,0) . "'\"></td>\n";
}
echo "<td><input type=button title='Click to open handout page' class=formbttn2 value='HandOut' onclick=\"window.open('". $this->_buildURL(MODE_HANDOUT,0) . "')\"></td>\n";
if (ENABLE_GUEST_UPLOAD==1)
{
$uploadEnabled = getAlbumParam($this->_folderName,TAG_GUEST_UPLOAD);
if (strcmp("on",$uploadEnabled)==0)
{
echo "<td >";
createPOSTButton('Upload',MODE_GUEST_CHOOSE_PICTURES,'',$this->_folderName,"formbttn2","Click to add files");
echo "</td>";
}
}
echo "</tr></table>";
}
function _displayPageIndex()
{
$cookieName = str_replace(".", "",$this->_folderName);
$cookieName = str_replace(" ", "",$cookieName);
SetCookie($cookieName,sizeof($this->_pictures),time() + 31536000,"/");
echo HTML_TAG ."<head>\n";
echo CONTENT_TYPE;
echo "<title>GRSlideShow: ".$this->albumInfo->description ."</title>";
echo STYLE_HEADER .HTML_HEADERS ."\n";
echo TEST_STYLESHEET;
echo "</head>";
echo "<body class=\"Pictures\">";
$this->_log();
echo "<div align='".INDEX_ALIGNMENT."'>\n";
?>
<table border='0' cellspacing='0' cellpadding='0' >
<tr align=center>
<td vAlign='top' nowrap='nowrap' align='center' class="indexPageTitle">
<?php echo ($this->_indexPageTitle);?>
</td>
</tr>
<?php
if (strlen(INDEX_PAGE_TITLE))
{
echo "<tr><td><span class='main_menu_header'>".INDEX_PAGE_TITLE."</span></td></tr>";
}
?>
<tr><td> </td></tr>
<tr><td align=center>
<?php
$this->_displayToolbar();
$imageNumber = 0;
if (array_key_exists(TAG_IMAGE_NUMBER,$_GET))
{
$imageNumber = $_GET[TAG_IMAGE_NUMBER];
}
if (array_key_exists(TAG_IMAGE_NUMBER,$_POST))
{
$imageNumber = $_POST[TAG_IMAGE_NUMBER];
}
if (0==sizeof($this->_pictures ))
{
if (is_dir($this->_folderName . "/video"))
{
echo "<span class='title'>Album contains only video Files.</span>";
return;
}
else
{
echo "<span class='title'>Album is empty.</span>";
return;
}
}
echo "</td></tr>";
if ( sizeof($this->_pictures) > MAX_NUM_OF_IMAGES_IN_INDEX )
{
echo "<tr><td align=center><br/><br/>";
$this->displayAllInOneToolbar($imageNumber,MAX_NUM_OF_IMAGES_IN_INDEX,MODE_INDEX);
echo "</td></tr>";
}
echo "<tr><td> </td></tr>";
$i=0;
for( $i=$imageNumber ; $i<sizeof($this->_pictures) && $i< $imageNumber + MAX_NUM_OF_IMAGES_IN_INDEX; $i++)
{
if ($this->_isNewRow($i - $imageNumber ))
echo "<tr align=center><td><table border='0' width='100%' class='photomenu'><tr>";
$picPercentage = 100 / NUMBER_OF_TUMBNAILS_IN_INDEX_ROW ;
echo "<td width='$picPercentage%' align='center' valign='top' nowrap='nowrap' >";
$this->_pictures[$i]->DisplayIndexThumnail();
if ($this->_isNewRow($i - $imageNumber + 1))
echo "</tr></table></td></tr>";
}
echo "</table></td></tr>";
echo "<tr><td>\n";
/* here 20 more large pictures are loaded in hidden mode, just to have these pictures in cache,
for a faster slideshow. */
for ($i=$imageNumber; $i< sizeof($this->_pictures) && $i< $imageNumber + MAX_PICTURES_IN_CACHE; $i++)
{
$this->_pictures[$i]->LoadToCache("image$i") ;
}
if ( sizeof($this->_pictures) > MAX_NUM_OF_IMAGES_IN_INDEX )
{
echo "<tr><td align=center><br/><br/>";
$this->displayAllInOneToolbar($imageNumber,MAX_NUM_OF_IMAGES_IN_INDEX,MODE_INDEX);
echo "</td></tr>";
}
echo "<tr><td align='".INDEX_ALIGNMENT."'>";
echo "<br/>";
showCreditLink();
echo "</td></tr>\n";
echo "</table>";
echo "</div>";
}
function _showBackButton()
{
if (($this->_mode == MODE_SLIDE_SHOW && DISPLAY_NEXT_BACK_IN_SLIDE_SHOW == '1') ||
($this->_mode== MODE_SINGLE_SLIDE && DISPLAY_NEXT_BACK_IN_SINGLE_SLIDE == '1'))
{
?>
<input type=button class=formbttn1 value='Back' onclick="switchImage(-1,false)">
<?php
}
}
function _showNextButton()
{
if (($this->_mode == MODE_SLIDE_SHOW && DISPLAY_NEXT_BACK_IN_SLIDE_SHOW == '1') ||
($this->_mode== MODE_SINGLE_SLIDE && DISPLAY_NEXT_BACK_IN_SINGLE_SLIDE == '1'))
{
?>
<input type=button class=formbttn1 value="Next" onclick="switchImage(1,false)">
<?php
}
}
function _displayMainMenuButton($title)
{
if (SHOW_BACK_TO_MAIN_BUTTTON != 1)
return;
$hidden = getAlbumParam($this->_folderName,TAG_DISABLED);
if (strcmp("on",$hidden)==0)
return;
$url = $_SERVER['SCRIPT_NAME'] . "?".TAG_MODE."=" .MODE_MENU;
echo "<input type=button class='formbttn2' value='$title' onclick=\"window.location='$url'\">\n";
}
function getUser()
{
if (array_key_exists(TAG_USER,$_COOKIE))
{
return $_COOKIE[TAG_USER];
}
elseif (array_key_exists(TAG_USER,$_GET))
{
return $_GET[TAG_USER];
}
return "";
}
function getOrderListFileName()
{
return $this->_folderName ."/image_order.".$this->getUser().".txt";
}
function getOrderList()
{
$list = array();
$fileName = $this->getOrderListFileName();
if (!file_exists($fileName))
{
return $list;
}
$f = fopen($this->getOrderListFileName(), "r");
while ($f && !feof($f))
{
$line = fgets($f, 4096);
$regexp = "/^\"(.*)\"=\"(.*)\"/";
if (preg_match ($regexp, $line, $regs))
{
$list[$regs[1]] = $regs[2];
}
}
if ($f)
{
fclose($f);
}
return $list;
}
function orderImage()
{
$f = fopen($this->getOrderListFileName(), "a");
$imageNumber = $_GET[TAG_IMAGE_NUMBER];
$name = $this->_pictures[$imageNumber]->Name();
fwrite($f,"\"$name\"=\"1\"\n" );
fclose($f);
}
function _displaySlideShowPage()
{
echo HTML_TAG ."<head>";
echo CONTENT_TYPE;
echo "<title>GRSlideShow: ".$this->albumInfo->description ."; picture no. ".($this->_imageNumber+1).
" : ". $this->_pictures[$this->_imageNumber]->Description() ."</title>";
//<title>GRSlideShow</title>' . CONTENT_TYPE
echo STYLE_HEADER .HTML_HEADERS ."\n";
echo "<script type='text/javascript'>\n";
echo "var numOfImages= ".sizeof($this->_pictures).";\n";
echo "var images= new Array(".sizeof($this->_pictures).");\n";
echo "var descriptions= new Array(".sizeof($this->_pictures).");\n";
echo "var sizes= new Array(".sizeof($this->_pictures).");\n";
echo "var doesOriginalExist= new Array(".sizeof($this->_pictures).");\n";
echo "var isReady= new Array(".sizeof($this->_pictures).");\n";
echo "var isOrderd= new Array(".sizeof($this->_pictures).");\n";
echo "var ratio= new Array(".sizeof($this->_pictures).");\n";
echo "var thumbnailPath= new Array(".sizeof($this->_pictures).");\n";
for($i=0;$i<sizeof($this->_pictures);$i++)
{
echo "images[$i]='".$this->_pictures[$i]->Name()."';\n";
echo "descriptions[$i]=\"".$this->_pictures[$i]->Description()."\";\n";
echo "sizes[$i]='".$this->_pictures[$i]->GetFormattedFileSize()."';\n";
echo "doesOriginalExist[$i]=".$this->_pictures[$i]->doesOriginalExist().";\n";
echo "isReady[$i]=".$this->_pictures[$i]->isReady().";\n";
echo "ratio[$i]=".$this->_pictures[$i]->_ratio.";\n";
echo "thumbnailPath[$i]='".$this->_pictures[$i]->_getThumbnailPath()."';\n";
if (array_key_exists($this->_pictures[$i]->Name(),$this->orderList))
{
echo "isOrderd[$i]=true;\n";
}
else
{
echo "isOrderd[$i]=false;\n";
}
}
if (preg_match("/msie/i",$_SERVER['HTTP_USER_AGENT']))
{
echo "var isIE = true;\n";
echo "var isMozilla = false;\n";
}
else
{
echo "var isIE = false;\n";
if (preg_match("/mozilla/i",$_SERVER['HTTP_USER_AGENT']))
{
echo "var isMozilla = true;\n";
}
else
{
echo "var isMozilla = false;\n";
}
}
?>
var imageNumber = <?php echo $this->_imageNumber; ?>;
var forevertimer ;
var folderName = '<?php echo $this->_folderName;?>';
var fadeInDegree = 0;
var speed = <?php echo $this->getSpeed(); ?>;
var foreverFlag = false;
function setOpacity(img,opacity)
{
opacity = (opacity == 100)?99.999:opacity;
// IE/Win
img.style.filter = "alpha(opacity:"+opacity+")";
// Safari<1.2, Konqueror
img.style.KHTMLOpacity = opacity/100;
// Older Mozilla and Firefox
img.style.MozOpacity = opacity/100;
// Safari 1.2, newer Firefox and Mozilla, CSS3
img.style.opacity = opacity/100;
}
function oldsetOpacity(img,degree)
{
if (isMozilla)
{
img.style.MozOpacity=degree/100
}
else if (isIE)
{
img.filters.Alpha.opacity=degree
}
}
function fadeIn()
{
img = document.getElementById('imgmain');
if (fadeInDegree>=100)
{
setOpacity(img,100);
return;
}
setOpacity(img,fadeInDegree);
fadeInDegree = fadeInDegree+20;
setTimeout("fadeIn()",30);
}
function switchMainImage()
{
img = document.getElementById('imgmain');
img.src= folderName + "/"+images[imageNumber];
}
function fadeOut()
{
//return;
img = document.getElementById('imgmain');
if (fadeInDegree<=0)
{
switchMainImage();
fadeInDegree = 0;
fadeIn();
return;
}
setOpacity(img,fadeInDegree);
fadeInDegree = fadeInDegree-20;
setTimeout("fadeOut()",50);
}
function flickrUpload()
{
frm = document.getElementById('printr');
if (doesOriginalExist[imageNumber])
{
frm.url.value = folderName + "/original/" + images[imageNumber];
}
else
{
frm.url.value = folderName + "/" + images[imageNumber]
}
frm.thumb.value = thumbnailPath[imageNumber];
frm.submit();
}
function openOriginalImg()
{
if (doesOriginalExist[imageNumber])
{
window.open(folderName + "/original/" + images[imageNumber]);
//window.open(folderName + "/original/" + fileName);
}
else
{
//alert("da");
}
}
function redirect(mode,imageNumber)
{
newlocation = '<?php echo $_SERVER['SCRIPT_NAME'] . "?".TAG_FOLDER."=" . $this->_folderName ."&".TAG_MODE."=" ?>'
+ mode + '<?php echo "&".TAG_IMAGE_NUMBER?>=' + imageNumber + '&<?php echo TAG_SPEED ; ?>=' + speed;
document.location = newlocation;
}
function imageLoaded()
{
if (foreverFlag)
{
setButtonsVisibility(true)
forevertimer = setTimeout("switchImage(1,true)",speed* 1000 );
}
}
function switchImage(direction,forever)
{
foreverFlag = forever;
s = document.getElementById('speedselect');
if (s.value != speed)
{
//check if speed in select is different then the speed known. if yes, refresh page to write cookie.
speed = s.value;
redirect(<?php echo MODE_SLIDE_SHOW ?>,imageNumber);
return;
}
if (!forever )
{
StopSlideshow();
}
currentImageNumber = imageNumber
imageNumber = (imageNumber + direction + numOfImages) % images.length;
if (!isReady[imageNumber] || ratio[imageNumber] != ratio [currentImageNumber])
{
mode = <?php echo MODE_SINGLE_SLIDE ?>;
if (forever)
{
mode = <?php echo MODE_SLIDE_SHOW ?>;
}
redirect(mode,imageNumber);
return;
}
img = document.getElementById('imgback');
backindex = (imageNumber - 1 + numOfImages) % images.length;
if (img)
img.src= folderName + "/thumbnails2/"+ images[backindex];
img = document.getElementById('imgnext');
nextindex = (imageNumber + 1) % images.length;
if (img)
img.src= folderName + "/thumbnails2/"+ images[nextindex];
setOrderVisibility(isOrderd[imageNumber]);
for(i=0;i<3;i++)
{
var imageName = "imgcache" + i;
nextImageNumber = (imageNumber + 1 + i) % images.length;
img = document.getElementById(imageName);
if (img)
{
img.src= folderName + "/"+images[nextImageNumber];
}
}
s= document.getElementById('spanpicturenumber');
tmp = imageNumber +1;
if (s)
s.innerHTML = "Picture " + tmp + " of " + numOfImages
s= document.getElementById('spanimagename');
if (s)
s.innerHTML = images[imageNumber];
s =document.getElementById('spandescription');
if (s)
s.innerHTML = descriptions[imageNumber] ;
s =document.getElementById('spanfilesize');
if (s)
s.innerHTML = sizes[imageNumber];
s =document.getElementById('gigya_text_area');
if (s)
s.innerHTML = "<img alt='" + descriptions[imageNumber] +
"' src='http://<? echo $_SERVER['HTTP_HOST'] . getCurrentPath() ?>" + folderName +
"/" + images[imageNumber] +
"' />" + "<br/>"+
"<a href='<?
echo "http://". $_SERVER['HTTP_HOST'] .
$_SERVER['SCRIPT_NAME'] . "?" . TAG_FOLDER."=" .
$this->_folderName ."&".TAG_MODE."=".MODE_SINGLE_SLIDE .
"&".TAG_IMAGE_NUMBER ."="; ?>" + imageNumber +"'>original</a>"+
" uploaded with <a href='http://www.grslideshow.com'>grslideshow</a>";
<?php
if (IMAGE_OPACITY_ENABLED == 1)
{
echo "var imageOpacityEnabled = true;\n";
}
else
{
echo "var imageOpacityEnabled = false;\n";
}
?>
if (forever && imageOpacityEnabled && speed > 2)
{
fadeInDegree = 90;
fadeOut();
}
else
{
switchMainImage();
}
}
function setOrderVisibility(b)
{
if (!b)
{
setVisibility('orderedspan',false);
setVisibility('orderbutton',true);
}
else
{
setVisibility('orderedspan',true);
setVisibility('orderbutton',false);
}
}
function setButtonsVisibility(b)
{
setVisibility('startbutton',!b);
setVisibility('stopbutton',b);
setVisibility('speedbutton',b);
setVisibility('speedselect',false);
}
function setVisibility(id,b)
{
element = document.getElementById(id);
if (!element)
{
//alert("ERROR: no element " + id);
return;
}
if (b)
{
element.style.display='';
element.style.visibility='visible';
}
else
{
element.style.display='none';
element.style.visibility='hidden';
}
}
function StopSlideshow()
{
clearInterval(forevertimer);
setVisibility('startbutton',true);
setVisibility('stopbutton',false);
setVisibility('speedbutton',false);
}
function changeSpeed()
{
StopSlideshow();
setVisibility('speedselect',true);
}
function orderImage()
{
StopSlideshow();
redirect(<?php echo MODE_ORDER_PICTURE ?>,imageNumber)
}
</script>
</head>
<body class='Pictures'>
<?php
if (strlen($this->albumInfo->musicFile))
{
echo "<embed src='".$this->albumInfo->folder . "/". $this->albumInfo->musicFile."' autostart='true' loop='true' width='2' height='0'></embed>\n";
echo "<noembed><bgsound src='".$this->albumInfo->folder . "/".$this->albumInfo->musicFile."' loop='infinite'></noembed>\n";
}
echo "<div align='".IMAGE_PAGE_ALIGNMENT."'>\n";
echo "<table align='".IMAGE_PAGE_ALIGNMENT."' border=0 >\n";
echo "<tr>";
echo "<td> ";
echo "<table align='".IMAGE_PAGE_ALIGNMENT."' border='0' width='100%' height='100%'>";
?>
<tr>
<td id='left_image' width='12%' class="photomenu">
<table border='0' width='100%' height='100%'>
<tr height='33%'>
<td align='center'>
<table width='100%' height='100%' border='0'>
<tr>
<td align='center' valign='middle'>
<table border='0' height='100%'>
<?php
if (SHOW_EXIT_BUTTTON_IN_IMAGE_PAGE == 1)
{
?>
<tr>
<td align=center>
<input type=button class='formbttn2' value='Exit' onclick='window.close()'>
</td>
</tr>
<?php
}
if (SHOW_BACK_TO_MAIN_BUTTTON == 1)
{
echo "<tr><td align=center>";
$this->_displayMainMenuButton("Main Menu");
echo "</td></tr>";
}
?>
<tr>
<td align='center' valign='middle'>
<input type='button' class='formbttn' value='<?php echo THIS_ALBUM ?>' onclick="window.location='<?php echo $this->_buildURL(MODE_INDEX, 0) ?>'">
</td>
</tr>
<tr>
<td align='center' valign='middle'>
<input type=button id='stopbutton' class=formbttn value='Pause' style="display:none;visibility :hidden " onclick="StopSlideshow()">
<?php
if (sizeof($this->_pictures)>1)
{
?>
<input type=button id='startbutton' class=formbttn value='Play' onclick="switchImage(1,true)">
<?php
}
?>
</td>
</tr>
<tr>
<td align=center valign='middle'>
<input type=button id='speedbutton' style='display:none;visibility:hidden' class='formbttn' value='Speed' onclick="changeSpeed()">
<select id='speedselect' style='display:none;visibility:hidden' class='text' onchange="switchImage(1,true)">
<?php
$speeds = array("","","Fastest","Fast","Normal","Slow","Slowest");
for ($i= sizeof($speeds)-1; $i>1;$i--)
{
echo "<option value='$i' ";
if ($this->getSpeed() == $i)
echo " selected ";
echo ">".$speeds[$i]."</option>\n";
}
?>
</select>
</td>
</tr>
<tr>
<td align=center valign='middle'>
<textarea id='gigya_text_area' style="display:none"><?
$mypath = split("/",$_SERVER['SCRIPT_NAME']);
$path="";
for($i=0;$i<sizeof($mypath)-1;$i++)
{
$path = "/".$mypath[$i];
}
echo "<img alt='".$this->_pictures[$this->_imageNumber]->Description()."' ".
" src='http://". $_SERVER['HTTP_HOST']."$path/". $this->_pictures[$this->_imageNumber]->_picturesFolder . "/" . $this->_pictures[$this->_imageNumber]->_getEncodedName() . "' />".
"<br/><a href='http://". $_SERVER['HTTP_HOST']. "/". $_SERVER['REQUEST_URI'] ."'>original</a> uploaded".
" with <a href='http://www.grslideshow.com'>grslideshow</a>";
?></textarea>
<script src="http://cdn.gigya.com/wildfire/JS/WFButton.js?module=post&cid=gigya_text_area&partner=98681"></script>
<!--<input class='formbttn' type='button' value='Flickr Upload' onclick="flickrUpload()">-->
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr height='33%'>
<td align='center'>
<table border='0' width='100%' >
<?php
if (PREV_THUMBNAIL_POSITION=='left' && sizeof($this->_pictures)>1)
{
?>
<tr>
<td align=center>
<?php
if (sizeof($this->_pictures)>1)
{
$this->_displayPrevImageThumbnail($this->_imageNumber);
}
?>
</td>
</tr>
<tr>
<!--<a href=\"."\">-->
<td align=center>
<?php
if (sizeof($this->_pictures)>1)
{
$this->_showBackButton();
}
?>
</td>
</tr>
<?php
}
if (NEXT_THUMBNAIL_POSITION=='left' && sizeof($this->_pictures)>1)
{
?>
<tr height=20%>
<td>
</td>
</tr>
<tr>
<td align=center>
<?php $this->_displayNextImageThumbnail($this->_imageNumber); ?>
</td>
</tr>
<tr>
<td align=center>
<?php
$this->_showNextButton();
?>
</td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
<tr>
<td align=center>
<table border='0' width='100%' height='100%'>
<tr>
<td class='text' dir=ltr>
<span id='spanpicturenumber'><?php echo "Picture " . ($this->_imageNumber+1) . " of " . $this->_numOfPictures ?></span>
</td>
</tr>
<tr>
<td class='text' >
File Name:<br/><span id='spanimagename'><?php echo $this->_pictures[$this->_imageNumber]->Name() ?></span>
</td>
</tr>
<?php
if (DISPLAY_FILE_SIZE==1)
{
?>
<tr>
<td class='text' dir=ltr><?php echo "Size: <span id='spanfilesize'>" . $this->_pictures[$this->_imageNumber]->GetFormattedFileSize() ; ?></span>
</td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
</td>
<?php
echo "<td id=center_image align='".IMAGE_PAGE_ALIGNMENT."'>\n";
echo "<table>\n";
echo "<tr>\n";
echo "<td>\n";
$this->_pictures[$this->_imageNumber]->DisplayPicture();
//LOAD THE NEXT PICTURE TO CACHE
for($i=0;$i<3;$i++)
{
$tmp = $this->_getNextImageNumber($this->_imageNumber + $i);
@$this->_pictures[$tmp]->LoadToCache("imgcache$i") ;
}
?>
</td>
</tr>
<tr>
<td align=center class='text2'>
<!--<input class='formbttn' type='button' value='Print T-Shirt' onclick="flickrUpload()">-->
<?php
$this->_pictures[$this->_imageNumber]->showPrintButton(true);
if ($this->_pictures[$this->_imageNumber]->hasDescription())
{
echo "<br/><span id='spandescription'>". $this->_pictures[$this->_imageNumber]->Description() ."</span>";
}
else
{
showCreditLink();
}
?>
</td>
</tr>
</table>
</td>
<td width='12%' align='center' valign='middle'>
<table>
<tr height='33%'>
<td>
</td>
</tr>
<tr height='33%'>
<td align=center>
<table border='0' width='100%' height='100%'>
<?php
$nothing=true;
if (PREV_THUMBNAIL_POSITION=='right' && sizeof($this->_pictures)>1)
{
$nothing=false;
?>
<tr>
<td align=center>
<?php
if (sizeof($this->_pictures)>1)
{
$this->_displayPrevImageThumbnail($this->_imageNumber);
}
?>
</td>
</tr>
<tr>
<!--<a href=\"."\">-->
<td align=center>
<?php
if (sizeof($this->_pictures)>1)
{
$this->_showBackButton();
}
?>
</td>
</tr>
<?php
}
if (NEXT_THUMBNAIL_POSITION=='right' && sizeof($this->_pictures)>1)
{
$nothing=false;
?>
<tr>
<td align=center>
<?php $this->_displayNextImageThumbnail($this->_imageNumber); ?>
</td>
</tr>
<tr>
<td align=center>
<?php
$this->_showNextButton();
?>
</td>
</tr>
<?php
}
if ($nothing)
{
echo "<tr><td> </td></tr>";
}
?>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<?php
if (MODE_SLIDE_SHOW == $this->_mode)
{
echo "<script type='text/javascript'>forevertimer = setTimeout(\"switchImage(1,true)\",". $this->getSpeed() . "* 1000 );setButtonsVisibility(true);</script>";
}
?>
<!--
This is the end of the dispaly table
-->
<?php
}
function StandAloneImageSlideShow()
{
echo "<script type='text/javascript'>\n";
echo "var numOfImages= ".sizeof($this->_pictures).";\n";
echo "var images= new Array(".sizeof($this->_pictures).");\n";
echo "var descriptions= new Array(".sizeof($this->_pictures).");\n";
echo "var sizes= new Array(".sizeof($this->_pictures).");\n";
echo "var doesOriginalExist= new Array(".sizeof($this->_pictures).");\n";
echo "var isReady= new Array(".sizeof($this->_pictures).");\n";
echo "var isOrderd= new Array(".sizeof($this->_pictures).");\n";
echo "var ratio= new Array(".sizeof($this->_pictures).");\n";
echo "var thumbnailPath= new Array(".sizeof($this->_pictures).");\n";
for($i=0;$i<sizeof($this->_pictures);$i++)
{
echo "images[$i]='".$this->_pictures[$i]->Name()."';\n";
echo "descriptions[$i]=\"".$this->_pictures[$i]->Description()."\";\n";
echo "sizes[$i]='".$this->_pictures[$i]->GetFormattedFileSize()."';\n";
echo "doesOriginalExist[$i]=".$this->_pictures[$i]->doesOriginalExist().";\n";
echo "isReady[$i]=".$this->_pictures[$i]->isReady().";\n";
echo "ratio[$i]=".$this->_pictures[$i]->_ratio.";\n";
echo "thumbnailPath[$i]='".$this->_pictures[$i]->_getThumbnailPath()."';\n";
}
if (preg_match("/msie/i",$_SERVER['HTTP_USER_AGENT']))
{
echo "var isIE = true;\n";
echo "var isMozilla = false;\n";
}
else
{
echo "var isIE = false;\n";
if (preg_match("/mozilla/i",$_SERVER['HTTP_USER_AGENT']))
{
echo "var isMozilla = true;\n";
}
else
{
echo "var isMozilla = false;\n";
}
}
?>
var imageNumber = <?php echo $this->_imageNumber; ?>;
var forevertimer ;
var folderName = '<?php echo $this->_folderName;?>';
var fadeInDegree = 0;
var speed = 4;
var foreverFlag = true;
function setOpacity(img,opacity)
{
opacity = (opacity == 100)?99.999:opacity;
// IE/Win
img.style.filter = "alpha(opacity:"+opacity+")";
// Safari<1.2, Konqueror
img.style.KHTMLOpacity = opacity/100;
// Older Mozilla and Firefox
img.style.MozOpacity = opacity/100;
// Safari 1.2, newer Firefox and Mozilla, CSS3
img.style.opacity = opacity/100;
}
function fadeIn()
{
img = document.getElementById('imgmain');
if (fadeInDegree>=100)
{
setOpacity(img,100);
return;
}
setOpacity(img,fadeInDegree);
fadeInDegree = fadeInDegree+20;
setTimeout("fadeIn()",30);
}
function switchMainImage()
{
img = document.getElementById('imgmain');
img.src= folderName + "/"+images[imageNumber];
}
function fadeOut()
{
//return;
img = document.getElementById('imgmain');
if (fadeInDegree<=0)
{
switchMainImage();
fadeInDegree = 0;
fadeIn();
return;
}
setOpacity(img,fadeInDegree);
fadeInDegree = fadeInDegree-20;
setTimeout("fadeOut()",50);
}
function imageLoaded()
{
if (foreverFlag)
{
forevertimer = setTimeout("switchImage(1,true)",speed* 1000 );
}
}
function switchImage(direction,forever)
{
foreverFlag = forever;
currentImageNumber = imageNumber
imageNumber = (imageNumber + direction + numOfImages) % images.length;
for(i=0;i<3;i++)
{
var imageName = "imgcache" + i;
nextImageNumber = (imageNumber + 1 + i) % images.length;
img = document.getElementById(imageName);
if (img)
{
img.src= folderName + "/"+images[nextImageNumber];
}
}
<?php
if (IMAGE_OPACITY_ENABLED == 1)
{
echo "var imageOpacityEnabled = true;\n";
}
else
{
echo "var imageOpacityEnabled = false;\n";
}
?>
if (forever && imageOpacityEnabled && speed > 2)
{
fadeInDegree = 90;
fadeOut();
}
else
{
switchMainImage();
}
}
</script>
<?php
$this->_pictures[$this->_imageNumber]->DisplayPicture(false);
}
function _writeFooter()
{
echo "</body></html>";
}
function Go($optionalMode = "" )
{
if ($optionalMode != "")
{
$this->_mode = $optionalMode;
}
if (!function_exists("imagecreatefromjpeg"))
{
echo "The GD library is not installed on this server. slideshow can not continue.";
return;
}
switch($this->_mode )
{
case MODE_INDEX:
$this->_displayPageIndex();
break;
case MODE_ORDER_UPDATE:
abortIfDemo();
$this->updateOrderList();
$this->orderList = $this->getOrderList();
$this->_mode = MODE_ORDER_LIST;
$this->dispalyPageOrderList();
break;
case MODE_ORDER_LIST:
$this->dispalyPageOrderList();
break;
case MODE_ABOUT:
echo DOCTYPE."<html><head>";
echo STYLE_HEADER .HTML_HEADERS ."\n";
echo "</head>";
echo "<body class=\"Pictures\">";
helpAbout();
break;
case MODE_VIEW_ALL:
$this->_displayPageViewAll();
break;
case MODE_DOWNLOAD:
$this->_displayDownloadPage();
break;
case MODE_VIDEO:
$this->_displayVideoPage();
break;
case MODE_HANDOUT:
$this->_displayHandOutPage();
break;
case MODE_CREDIT:
$this->_displayCreditPage();
break;
case MODE_ORDER_PICTURE:
abortIfDemo();
$this->orderImage();
$this->orderList = $this->getOrderList();
$this->_mode = MODE_SINGLE_SLIDE;
$this->_displaySlideShowPage();
$this->_writeFooter();
break;
default:
$this->_displaySlideShowPage();
$this->_writeFooter();
break;
}
}
} // end of class GRSlideShow
?>
|