Overview

Packages

  • admin
  • classes
    • media
  • CodeIgniter
    • Libraries
  • core
  • functions
  • JSMin
  • None
  • OpenID
  • PHP
  • PHPMailer
  • plugins
    • admin
    • development
    • feed
    • mail
    • media
    • misc
    • seo
    • spam
    • uploader
    • users
    • zenpage
    • zenphoto
      • news
  • Services
    • JSON

Classes

  • _zp_captcha
  • _zp_HTML_cache
  • admin_approval
  • Album
  • AlbumBase
  • AlbumZip
  • AMFReader
  • AMFStream
  • AnyFile
  • AnyFile_Options
  • Auth_OpenID
  • Auth_OpenID_AlreadySigned
  • Auth_OpenID_AssociateRequest
  • Auth_OpenID_Association
  • Auth_OpenID_AuthRequest
  • Auth_OpenID_AX
  • Auth_OpenID_AX_AttrInfo
  • Auth_OpenID_AX_Error
  • Auth_OpenID_AX_FetchRequest
  • Auth_OpenID_AX_FetchResponse
  • Auth_OpenID_AX_KeyValueMessage
  • Auth_OpenID_AX_Message
  • Auth_OpenID_AX_StoreRequest
  • Auth_OpenID_AX_StoreResponse
  • Auth_OpenID_BcMathWrapper
  • Auth_OpenID_CancelResponse
  • Auth_OpenID_CheckAuthRequest
  • Auth_OpenID_CheckIDRequest
  • Auth_OpenID_Consumer
  • Auth_OpenID_ConsumerResponse
  • Auth_OpenID_CryptUtil
  • Auth_OpenID_DatabaseConnection
  • Auth_OpenID_Decoder
  • Auth_OpenID_DiffieHellman
  • Auth_OpenID_DiffieHellmanSHA1ConsumerSession
  • Auth_OpenID_DiffieHellmanSHA1ServerSession
  • Auth_OpenID_DiffieHellmanSHA256ConsumerSession
  • Auth_OpenID_DiffieHellmanSHA256ServerSession
  • Auth_OpenID_DumbStore
  • Auth_OpenID_Encoder
  • Auth_OpenID_EncodingError
  • Auth_OpenID_Extension
  • Auth_OpenID_FailureResponse
  • Auth_OpenID_FileStore
  • Auth_OpenID_GenericConsumer
  • Auth_OpenID_GmpMathWrapper
  • Auth_OpenID_KVForm
  • Auth_OpenID_MalformedReturnURL
  • Auth_OpenID_MalformedTrustRoot
  • Auth_OpenID_Mapping
  • Auth_OpenID_MathLibrary
  • Auth_OpenID_MDB2Store
  • Auth_OpenID_MemcachedStore
  • Auth_OpenID_Message
  • Auth_OpenID_MySQLStore
  • Auth_OpenID_NamespaceMap
  • Auth_OpenID_NoReturnToError
  • Auth_OpenID_OpenIDStore
  • Auth_OpenID_PAPE_Request
  • Auth_OpenID_PAPE_Response
  • Auth_OpenID_Parse
  • Auth_OpenID_PlainTextConsumerSession
  • Auth_OpenID_PlainTextServerSession
  • Auth_OpenID_PostgreSQLStore
  • Auth_OpenID_Request
  • Auth_OpenID_Server
  • Auth_OpenID_ServerError
  • Auth_OpenID_ServerErrorContainer
  • Auth_OpenID_ServerRequest
  • Auth_OpenID_ServerResponse
  • Auth_OpenID_ServiceEndpoint
  • Auth_OpenID_ServiceEndpointLoader
  • Auth_OpenID_SessionNegotiator
  • Auth_OpenID_SetupNeededResponse
  • Auth_OpenID_Signatory
  • Auth_OpenID_SigningEncoder
  • Auth_OpenID_SQLiteStore
  • Auth_OpenID_SQLStore
  • Auth_OpenID_SRegBase
  • Auth_OpenID_SRegRequest
  • Auth_OpenID_SRegResponse
  • Auth_OpenID_SuccessResponse
  • Auth_OpenID_TrustRoot
  • Auth_OpenID_TypeURIMismatch
  • Auth_OpenID_UntrustedReturnURL
  • Auth_OpenID_WebResponse
  • Auth_Yadis_Discovery
  • Auth_Yadis_DiscoveryResult
  • Auth_Yadis_dom
  • Auth_Yadis_domxml
  • Auth_Yadis_HTTPFetcher
  • Auth_Yadis_HTTPResponse
  • Auth_Yadis_Manager
  • Auth_Yadis_ManagerLoader
  • Auth_Yadis_ParanoidHTTPFetcher
  • Auth_Yadis_ParseHTML
  • Auth_Yadis_PHPSession
  • Auth_Yadis_PlainHTTPFetcher
  • Auth_Yadis_ProxyResolver
  • Auth_Yadis_Service
  • Auth_Yadis_SessionLoader
  • Auth_Yadis_XMLParser
  • Auth_Yadis_XRDS
  • Auth_Yadis_Yadis
  • auto_backup
  • AVCSequenceParameterSetReader
  • bxslider
  • cacheManager
  • cacheManagerFeed
  • CI_jsmin
  • CI_load
  • cloneZenphoto
  • codeIgniter_kludge
  • colorbox
  • Comment
  • comment_form
  • contactformOptions
  • crop_image
  • cycle
  • defaultCodeblocks
  • deprecated_functions
  • DownloadList
  • dynamic_locale
  • dynamicAlbum
  • elFinder_options
  • email_new_user
  • exampleMacros
  • external_auth
  • ExternalFeed
  • externalFeed_options
  • favorites
  • favoritesOptions
  • federated_logon
  • feed
  • fieldExtender
  • flag_thumbnail
  • Gallery
  • galleryArticles
  • getID3
  • getid3_aac
  • getid3_apetag
  • getid3_flv
  • getid3_handler
  • getid3_id3v1
  • getid3_id3v2
  • getid3_lib
  • getid3_lyrics3
  • getid3_mp3
  • getid3_mpeg
  • getid3_quicktime
  • getid3_swf
  • GoogleMap
  • Googlemaps
  • googleVerifyOptions
  • hitcounter
  • HTML
  • htmlmetatags
  • http_auth
  • Image
  • image_effects
  • internal_deprecations
  • ipBlocker
  • jcarousel
  • jPlayer
  • jplayer_options
  • jquery_rating
  • JSMin
  • lib_GD_Options
  • lib_Imagick_Options
  • lib_NoGraphics
  • MediaObject
  • menu_manager
  • MergedRSS
  • MergedRSSOptions
  • mobile
  • Mobile_Detect
  • mobileTheme
  • multipleLayoutOptions
  • null_seo
  • OAuthConsumer
  • OAuthDataStore
  • OAuthRequest
  • OAuthServer
  • OAuthSignatureMethod
  • OAuthSignatureMethod_HMAC_SHA1
  • OAuthSignatureMethod_PLAINTEXT
  • OAuthSignatureMethod_RSA_SHA1
  • OAuthToken
  • OAuthUtil
  • pagedThumbsNav
  • pagedthumbsOptions
  • PclZip
  • PersistentObject
  • PHPMailer
  • PlainText
  • POP3
  • print_album_menu
  • pseudoPlayer
  • publishContent
  • quota_manager
  • reCaptcha
  • ReCaptchaResponse
  • register_user
  • rewriteRules
  • rewriteTokens
  • RSS
  • RSS_internal_deprecations
  • rss_options
  • search_statistics
  • SearchEngine
  • security_logger
  • seo_locale
  • Services_JSON
  • Services_JSON_Error
  • setupexternalFeed
  • setupRSS
  • show_not_loggedin
  • sitemap
  • slideshow
  • SMTP
  • static_html_cache
  • tagsuggest
  • TextObject
  • TextObject_internal_deprecations
  • TextObject_Options
  • ThemeObject
  • themeSwitcher
  • tinymce4Options
  • tinyURL
  • Transientimage
  • tweet
  • TwitterOAuth
  • UploadHandler
  • user_expiry
  • user_groups
  • user_logout_options
  • userAddressFields
  • utf8
  • Video
  • Video_internal_deprecations
  • VideoObject_Options
  • viewer_size_image_options
  • WEBdocs
  • WEBdocs_Options
  • xmpMetadata
  • Zenpage
  • Zenpage_internal_deprecations
  • ZenpageCategory
  • zenpagecms
  • ZenpageItems
  • ZenpageNews
  • ZenpagePage
  • ZenpageRoot
  • Zenphoto_Administrator
  • Zenphoto_Authority
  • zenphoto_org_news
  • zenphoto_seo
  • zenphotoDonate
  • ZipStream
  • zp_PHPMailer
  • zpCaptcha
  • zpFunctions
  • zpLegacySpam
  • zpMutex
  • zpSimpleSpam
  • zpTrivialSpam

Exceptions

  • BadFunctionCallException
  • BadMethodCallException
  • Exception
  • getid3_exception
  • JSMin_UnterminatedCommentException
  • JSMin_UnterminatedRegExpException
  • JSMin_UnterminatedStringException
  • LogicException
  • OAuthExcept
  • phpmailerException

Functions

  • __autoload
  • _escape_xref
  • _recaptcha_aes_encrypt
  • _recaptcha_aes_pad
  • _recaptcha_http_post
  • _recaptcha_mailhide_email_parts
  • _recaptcha_mailhide_urlbase64
  • _recaptcha_qsencode
  • accessAllAlbums
  • add_context
  • addalbumsToDatabase
  • addCategoriesToDatabase
  • addGeoCoord
  • addItem
  • addPagesToDatabase
  • addPluginScript
  • addPluginType
  • addSubalbumMenus
  • admin_album_list
  • admin_securityChecks
  • admin_showupdate
  • adminPageNav
  • adminToolbox
  • albumNumber
  • applyMacros
  • Auth_OpenID_arrangeByType
  • Auth_OpenID_AX_checkAlias
  • Auth_OpenID_AX_toTypeURIs
  • Auth_OpenID_bestMatchingService
  • Auth_OpenID_checkFieldName
  • Auth_OpenID_checkSessionType
  • Auth_OpenID_checkTimestamp
  • Auth_OpenID_detectMathLibrary
  • Auth_OpenID_discover
  • Auth_OpenID_discoverURI
  • Auth_OpenID_discoverWithoutYadis
  • Auth_OpenID_discoverWithYadis
  • Auth_OpenID_discoverXRI
  • Auth_OpenID_extractReturnURL
  • Auth_OpenID_findOPLocalIdentifier
  • Auth_OpenID_getAllAssociationTypes
  • Auth_OpenID_getAllowedReturnURLs
  • Auth_OpenID_getAuthorityPattern
  • Auth_OpenID_getAvailableSessionTypes
  • Auth_OpenID_getDefaultAssociationOrder
  • Auth_OpenID_getDefaultGen
  • Auth_OpenID_getDefaultMod
  • Auth_OpenID_getDefaultNegotiator
  • Auth_OpenID_getEncodedPattern
  • Auth_OpenID_getEncryptedNegotiator
  • Auth_OpenID_getEscapeRE
  • Auth_OpenID_getMathLib
  • Auth_OpenID_getOnlyEncryptedOrder
  • Auth_OpenID_getOpenIDConsumerTypeURIs
  • Auth_OpenID_getOpenIDTypeName
  • Auth_OpenID_getOpenIDTypeURIs
  • Auth_OpenID_getOPOrUserServices
  • Auth_OpenID_getSecretSize
  • Auth_OpenID_getSessionTypes
  • Auth_OpenID_getSupportedAssociationTypes
  • Auth_OpenID_getUnreserved
  • Auth_OpenID_getURIPattern
  • Auth_OpenID_getURLIllegalCharRE
  • Auth_OpenID_HMACSHA1
  • Auth_OpenID_HMACSHA256
  • Auth_OpenID_include_init
  • Auth_OpenID_isError
  • Auth_OpenID_isOpenID1
  • Auth_OpenID_legacy_discover
  • Auth_OpenID_makeOpenIDEndpoints
  • Auth_OpenID_math_extensions
  • Auth_OpenID_mkNonce
  • Auth_OpenID_noMathSupport
  • Auth_OpenID_pct_encoded_replace
  • Auth_OpenID_pct_encoded_replace_unreserved
  • Auth_OpenID_registerNamespaceAlias
  • Auth_OpenID_remove_dot_segments
  • Auth_OpenID_removeNamespaceAlias
  • Auth_OpenID_returnToMatches
  • Auth_OpenID_setNoMathSupport
  • Auth_OpenID_SHA1
  • Auth_OpenID_SHA256
  • Auth_OpenID_splitNonce
  • Auth_OpenID_supportsSReg
  • Auth_OpenID_urinorm
  • Auth_OpenID_verifyReturnTo
  • Auth_Yadis_array_scramble
  • Auth_Yadis_escapeForIRI
  • Auth_Yadis_getCanonicalID
  • Auth_Yadis_getDefaultProxy
  • Auth_Yadis_getEscapeRE
  • Auth_Yadis_getIPrivateChars
  • Auth_Yadis_getNSMap
  • Auth_Yadis_getServiceEndpoints
  • Auth_Yadis_getSupportedExtensions
  • Auth_Yadis_getUCSChars
  • Auth_Yadis_getXMLParser
  • Auth_Yadis_getXRDExpiration
  • Auth_Yadis_getXrefRE
  • Auth_Yadis_getXRIAuthorities
  • Auth_Yadis_identifierScheme
  • Auth_Yadis_iriToURI
  • Auth_Yadis_pct_escape_unicode
  • Auth_Yadis_providerIsAuthoritative
  • Auth_Yadis_rootAuthority
  • Auth_Yadis_setDefaultParser
  • Auth_Yadis_startswith
  • Auth_Yadis_toIRINormal
  • Auth_Yadis_toURINormal
  • Auth_Yadis_XRI
  • Auth_Yadis_XRIAppendArgs
  • authorSelector
  • build_query
  • build_url
  • bulkActionRedirect
  • bulkTags
  • byteConvert
  • cacheImage
  • checkAccess
  • checkAlbumimagesort
  • checkAlbumParentid
  • checkAlbumPassword
  • checkChosenItemStatus
  • checkChosenMenuset
  • checked
  • checkFolder
  • checkForEmptyTitle
  • checkForGuest
  • checkForPage
  • checkForPassword
  • checkForUpdate
  • checkHitcounterDisplay
  • checkIfChecked
  • checkIfLockedNews
  • checkIfLockedPage
  • checkIfNew
  • checkInstall
  • checkLayoutUseForImages
  • checkNewsAccess
  • checkNewsCategoryPassword
  • checkObjectsThumb
  • checkPagePassword
  • checkPageValidity
  • checkParentLayouts
  • checkPublishDates
  • checkRequiredField
  • checkSelectedAlbum
  • checkSignature
  • cleanAlbum
  • cleanHTML
  • clearSitemapCache
  • clonedFrom
  • codeblocktabsJS
  • comment_form_addComment
  • comment_form_handle_comment
  • comment_form_PaginationJS
  • comment_form_postcomment
  • comment_form_print10Most
  • comment_form_visualEditor
  • commentFormUseCaptcha
  • commentReply
  • commentsAllowed
  • consolidatedEditMessages
  • copyLayoutSelection
  • copyThemeDirectory
  • countArticles
  • countCombiNews
  • createMenuIfNotExists
  • createRelatedItemsResultArray
  • cron_starter
  • currentRelativeURL
  • customOptions
  • dateDiff
  • datepickerJS
  • dateTimeConvert
  • db_affected_rows
  • db_close
  • db_collation
  • db_connect
  • db_count
  • db_create
  • db_create_table
  • db_error
  • db_fetch_assoc
  • db_fetch_row
  • db_free_result
  • db_getSQLmode
  • db_insert_id
  • db_LIKE_escape
  • db_list_fields
  • db_name
  • db_num_rows
  • db_permissions
  • db_quote
  • db_setSQLmode
  • db_show
  • db_software
  • db_table_update
  • db_truncate_table
  • debug404
  • debugLog
  • debugLogBacktrace
  • debugLogVar
  • defaultCodeblocks_codebox
  • deleteArticle
  • deleteCategory
  • deleteItem
  • deleteLayoutSelection
  • deletePage
  • deleteThemeDirectory
  • detect_fetcher
  • detect_math
  • detect_query_corruption
  • detect_random
  • detect_stores
  • detect_xml
  • dircopy
  • displayError
  • doIncludes
  • elFinder_admin_tabs
  • elFinder_tinymce
  • enableExtension
  • escape
  • executeRSS
  • exitZP
  • exposeZenPhotoInformations
  • extensionEnabled
  • fetchComments
  • filesystemToInternal
  • filter_extractReturnURL
  • filter_MatchesAnyOpenIDConsumerType
  • filter_MatchesAnyOpenIDType
  • filterImageQuery
  • fix_path_redirect
  • formatList
  • fullText
  • galleryAlbumsPerPage
  • genAlbumList
  • generateCaptcha
  • generateLanguageList
  • generateListFromArray
  • generateListFromFiles
  • generateRadiobuttonsFromArray
  • generateSitemapCacheFile
  • generateSitemapIndexCacheFile
  • generateUnorderedListFromArray
  • get_AnyFile_suffixes
  • get_context
  • get_filterScript
  • get_instance
  • get_language_string
  • getAdminThumb
  • getAlbumArray
  • getAlbumBreadcrumb
  • getAlbumBreadcrumbAdmin
  • getAlbumCustomData
  • getAlbumData
  • getAlbumDate
  • getAlbumDesc
  • getAlbumFolder
  • getAlbumGeodata
  • getAlbumId
  • getAlbumInherited
  • getAlbumLinkURL
  • getAlbumLocation
  • getAlbumPage
  • getAlbumPlace
  • getAlbumStatistic
  • getAlbumThumb
  • getAlbumTitle
  • getAlbumURL
  • getAllAccessibleAlbums
  • getAllAlbums
  • getAllArticleDates
  • getAllCategories
  • getAllDates
  • getAllowedTags
  • getAllSubAlbumIDs
  • getAllSubalbums
  • getAllTagsCount
  • getAllTagsFromAlbum
  • getAllTagsFromAlbum_multi_unique
  • getAllTagsFromZenpage
  • getAllTagsUnique
  • getAllTranslations
  • getAnnotatedAlbumTitle
  • getAnnotatedImageTitle
  • getArticles
  • getAuthor
  • getBare
  • getBareAlbumDesc
  • getBareAlbumTitle
  • getBareGalleryDesc
  • getBareGalleryTitle
  • getBareImageDesc
  • getBareImageTitle
  • getBareNewsAlbumTitle
  • getBareNewsTitle
  • getBarePageTitle
  • getCategory
  • getCategoryID
  • getCategoryLink
  • getCategoryParentID
  • getCategorySortOrder
  • getCategoryTitle
  • getCheckboxState
  • getCodeblock
  • getCombiNews
  • getCommentAddress
  • getCommentAuthorEmail
  • getCommentAuthorLink
  • getCommentAuthorName
  • getCommentAuthorSite
  • getCommentBody
  • getCommentCount
  • getCommentDate
  • getCommentDateTime
  • getCommentErrors
  • getCommentsAllowed
  • getCommentStored
  • getCommentTime
  • getConsumer
  • getContentShorten
  • getCurrentMenuItem
  • getCurrentNewsArchive
  • getCurrentNewsCategory
  • getCurrentNewsCategoryID
  • getCurrentNewsCategoryParentID
  • getCurrentNewsPage
  • getCurrentPage
  • getCurrentTheme
  • getCustomAlbumThumb
  • getCustomAlbumThumbMaxSpace
  • getCustomImageURL
  • getCustomPageURL
  • getCustomSizedImageMaxSpace
  • getCustomSizedImageThumbMaxSpace
  • getDefaultHeight
  • getDefaultSizedImage
  • getDefaultWidth
  • getDownloadLink
  • getdownloadList
  • getDownloadURL
  • getE
  • getEnabledPlugins
  • getExpiryDatePost
  • getFavoritesURL
  • getField
  • getFirstImageURL
  • getFullHeight
  • getFullImageURL
  • getFullNewsImage
  • getFullWidth
  • getGalleryDesc
  • getGalleryIndexURL
  • getGalleryTitle
  • getGeoCoord
  • getHeadTitle
  • getHitcounter
  • getImageArgs
  • getImageCacheFilename
  • getImageCachePostfix
  • getImageCity
  • getImageCountry
  • getImageCustomData
  • getImageData
  • getImageDate
  • getImageDesc
  • getImageEXIFData
  • getImageGeodata
  • getImageID
  • getImageLinkURL
  • getImageLocation
  • getImageMetaData
  • getImageParameters
  • getImageProcessorURI
  • getImageProcessorURIFromCacheName
  • getImageRotation
  • getImageSortOrder
  • getImageState
  • getImageStatistic
  • getImageThumb
  • getImageTitle
  • getImageURI
  • getImageURL
  • getItem
  • getItemByID
  • getItemTitleAndURL
  • getjPlayerSkinCSS
  • getjPlayerSkins
  • getLanguageArray
  • getLanguageFlag
  • getLastImageURL
  • getLatestComments
  • getLatestNews
  • getLatestZenpageComments
  • getLayout
  • getLayoutSelector
  • getLink
  • getLinkHTML
  • getLogTabs
  • getMacros
  • getMainSiteName
  • getMainSiteURL
  • getManagedAlbumList
  • getMaxSpaceContainer
  • getMenuFromLink
  • getMenuItemChilds
  • getMenuItems
  • getMenumanagerPredicessor
  • getMenumanagerSuccessor
  • getMenuSetSelector
  • getMenuVisibility
  • getMimeString
  • getNestedAlbumList
  • getNewsAdminOption
  • getNewsAdminOptionPath
  • getNewsAlbumName
  • getNewsAlbumTitle
  • getNewsAlbumURL
  • getNewsArchivePath
  • getNewsArchiveURL
  • getNewsAuthor
  • getNewsCategories
  • getNewsCategoryCustomData
  • getNewsCategoryDesc
  • getNewsCategoryPath
  • getNewsCategoryURL
  • getNewsContent
  • getNewsContentShorten
  • getNewsCustomData
  • getNewsDate
  • getNewsExtraContent
  • getNewsID
  • getNewsImageTags
  • getNewsIndexURL
  • getNewsLink
  • getNewsPagesStatistic
  • getNewsPathNav
  • getNewsReadMore
  • getNewsTitle
  • getNewsTitleLink
  • getNewsTitlePath
  • getNewsType
  • getNewsURL
  • getNewsVideoContent
  • getNextAlbum
  • getNextAlbumURL
  • getNextImageThumb
  • getNextImageURL
  • getNextNewsPageURL
  • getNextNewsURL
  • getNextPageURL
  • getNextPrevNews
  • getNotViewableAlbums
  • getNotViewableImages
  • getNumAlbums
  • getNumAllSubalbums
  • getNumImages
  • getNumNews
  • getNumPages
  • getNumSubalbums
  • getOpenIDURL
  • getOption
  • getOptionFromDB
  • getOptionList
  • getPageAuthor
  • getPageContent
  • getPageCustomData
  • getPageDate
  • getPageExtraContent
  • getPageID
  • getPageLastChangeDate
  • getPageLinkPath
  • getPageLinkURL
  • getPageNavList
  • getPageNumURL
  • getPageParentID
  • getPageRedirect
  • getPages
  • getPageSelector
  • getPageSortorder
  • getPageTitle
  • getPageTitleLink
  • getPageURL
  • getParentAlbums
  • getParentAlbumsAdmin
  • getParentBreadcrumb
  • getParentItems
  • getParentMenuItems
  • getParentNewsCategories
  • getParentPages
  • getPasswordProtectImage
  • getPHPFiles
  • getPlugin
  • getPluginFiles
  • getPluginTabs
  • getPrevAlbum
  • getPrevAlbumURL
  • getPrevImageThumb
  • getPrevImageURL
  • getPrevNewsPageURL
  • getPrevNewsURL
  • getPrevPageURL
  • getProtectedImageURL
  • getRandomImages
  • getRandomImagesAlbum
  • getRating
  • getRelatedItems
  • getRequestURI
  • getReturnTo
  • getRSSHeaderLink
  • getRSSLink
  • getScheme
  • getSearchDate
  • getSearchURL
  • getSearchWords
  • getSelectedLayout
  • getSerializedArray
  • getSetClause
  • getSiteHomeURL
  • getSitemapAlbumList
  • getSitemapAlbums
  • getSitemapGoogleImageVideoExtras
  • getSitemapGoogleLoopIndex
  • getSitemapImages
  • getSitemapIndexLinks
  • getSitemapZenpageNewsArticles
  • getSitemapZenpageNewsCategories
  • getSitemapZenpageNewsIndex
  • getSitemapZenpagePages
  • getSizeCustomImage
  • getSizeDefaultImage
  • getSizeDefaultThumb
  • getSizedImageURL
  • getSizeFullImage
  • getStore
  • getSubCategories
  • getSubtabs
  • getSuffix
  • getTagCountByAccess
  • getTagOrder
  • getTags
  • gettext_pl
  • gettext_th
  • getTheme
  • getThemeFiles
  • getThemeOption
  • getTimezones
  • getTinyMCE4ConfigFiles
  • getTitle
  • getTotalArticles
  • getTotalImagesIn
  • getTotalNewsPages
  • getTotalPages
  • getTrustRoot
  • getUnprotectedImageURL
  • getUrAlbum
  • getURL
  • getUserIP
  • getUserLocale
  • getVersion
  • getViewerImageSize
  • getWatermarkParam
  • getWatermarkPath
  • getWatermarks
  • getWhereClause
  • getXSRFToken
  • getZenpageHitcounter
  • getZenpageRSSHeaderLink
  • getZenpageRSSLink
  • getZenpageStatistic
  • googleVerifyHead
  • handleSearchParms
  • hasDynamicAlbumSuffix
  • hasNextImage
  • hasNextPage
  • hasPrevImage
  • hasPrevPage
  • hitcounter
  • html_decode
  • html_encode
  • html_encodeTagged
  • httpsRedirect
  • httpUploadHandler
  • httpUploadHandler_admin_tabs
  • i18nSetLocale
  • imageBlurGD
  • imageDebug
  • imageError
  • imageNumber
  • imgSrcURI
  • in_context
  • inNewsCategory
  • inProtectedNewsCategory
  • installSignature
  • instrument
  • inSubNewsCategoryOf
  • internalToFilesystem
  • inventMenuItem
  • iptc_make_tag
  • is_AdminEditPage
  • is_connected
  • is_GalleryNewsType
  • is_News
  • is_NewsArchive
  • is_NewsArticle
  • is_NewsCategory
  • is_NewsPage
  • is_NewsType
  • is_Pages
  • is_valid_email_zp
  • is_valid_image
  • is_valid_other_type
  • is_zip
  • isAlbumClass
  • isAlbumPage
  • isArchive
  • isHandledAlbum
  • isImageClass
  • isImagePage
  • isImagePhoto
  • isImageVideo
  • isLandscape
  • isMyAlbum
  • isMyNews
  • isMyPage
  • isolate
  • isProtectedAlbum
  • isProtectedNewsCategory
  • isProtectedPage
  • isSubNewsCategoryOf
  • isValidURL
  • jQueryUpload_head
  • jQueryUpload_headers
  • jQueryUploadHandler
  • jQueryUploadHandler_admin_tabs
  • js_encode
  • json_decode
  • json_encode
  • kses
  • kses_array_lc
  • kses_attr
  • kses_bad_protocol
  • kses_bad_protocol_once
  • kses_bad_protocol_once2
  • kses_check_attr_val
  • kses_decode_entities
  • kses_hair
  • kses_hook
  • kses_html_error
  • kses_js_entities
  • kses_no_null
  • kses_normalize_entities
  • kses_normalize_entities2
  • kses_split
  • kses_split2
  • kses_stripslashes
  • kses_version
  • ksesProcess
  • layoutSelector
  • layoutSelector_album
  • listDBUses
  • listDirectoryFiles
  • listUses
  • load_zenpage_news
  • load_zenpage_pages
  • loadLocalOptions
  • log_message
  • lookupSortKey
  • macro_admin_tabs
  • macroList_show
  • makeAlbumCurrent
  • makeImageCurrent
  • makeSpecialImageName
  • markRelease_button
  • mb_strlen
  • mb_strpos
  • mb_strrpos
  • mb_strtolower
  • mb_strtoupper
  • mb_substr
  • mb_substr_count
  • menu_admin_toolbox_global
  • menu_tabs
  • minDiff
  • mkdir_recursive
  • my_truncate_string
  • myts_date
  • newAlbum
  • newImage
  • next_album
  • next_comment
  • next_image
  • next_news
  • next_page
  • ngettext_pl
  • ngettext_th
  • normalizeColumns
  • omsAdditions
  • openedForComments
  • parse_query
  • parse_size
  • parseAllowedTags
  • parseHttpAcceptLanguage
  • passAlbums
  • passImages
  • pathurlencode
  • PclZipUtilCopyBlock
  • PclZipUtilOptionText
  • PclZipUtilPathInclusion
  • PclZipUtilPathReduction
  • PclZipUtilRename
  • PclZipUtilTranslateWinPath
  • PHPMailerAutoload
  • populateManagedObjectsList
  • postAlbumSort
  • postIndexDecode
  • postIndexEncode
  • prefix
  • prepareAlbumPage
  • prepareCustomPage
  • prepareImagePage
  • prepareIndexPage
  • print404status
  • print_language_string_list
  • printAddToFavorites
  • printAdminFooter
  • printAdminHeader
  • printAdminRightsTable
  • printAdminToolbox
  • printAlbumBreadcrumb
  • printAlbumButtons
  • printAlbumCustomData
  • printAlbumData
  • printAlbumDate
  • printAlbumDesc
  • printAlbumEditForm
  • printAlbumEditRow
  • printAlbumLegend
  • printAlbumLink
  • printAlbumLocation
  • printAlbumMap
  • printAlbumMenu
  • printAlbumMenuJump
  • printAlbumMenuList
  • printAlbumMenuListAlbum
  • printAlbumPlace
  • printAlbumRating
  • printAlbumsSelector
  • printAlbumStatistic
  • printAlbumStatisticItem
  • printAlbumThumbImage
  • printAlbumTitle
  • printAlbumURL
  • printAlbumZip
  • printAllDates
  • printAllNewsCategories
  • printAllTags
  • printAllTagsAs
  • printAllTagsFromAlbum
  • printAllTagsFromZenpage
  • printAnnotatedAlbumTitle
  • printAnnotatedImageTitle
  • printArticleCategories
  • printArticleDatesDropdown
  • printArticlesPerPageDropdown
  • printBareAlbumDesc
  • printBareAlbumTitle
  • printBareGalleryDesc
  • printBareGalleryTitle
  • printBareImageDesc
  • printBareImageTitle
  • printBareNewsTitle
  • printBarePageTitle
  • printBulkActions
  • printCaptcha
  • printCategoriesStatistic
  • printCategoryCheckboxListEntry
  • printCategoryDropdown
  • printCategoryListSortableTable
  • printCategorySelection
  • printCodeblock
  • printCodeblockEdit
  • printCommentAuthorLink
  • printCommentErrors
  • printCommentForm
  • printContactForm
  • printCurrentNewsArchive
  • printCurrentNewsCategory
  • printCustomAlbumThumbImage
  • printCustomAlbumThumbMaxSpace
  • printCustomMenu
  • printCustomPageSelector
  • printCustomPageURL
  • printCustomSizedImage
  • printCustomSizedImageMaxHeight
  • printCustomSizedImageMaxSpace
  • printCustomSizedImageThumbMaxSpace
  • printDefaultSizedImage
  • printDownloadAlbumZipURL
  • printDownloadLink
  • printDownloadLinkAlbumZip
  • printdownloadList
  • printDownloadURL
  • printEditable
  • printEditCommentLink
  • printEditDropdown
  • printExpired
  • printFavoritesLink
  • printFavoritesURL
  • printField
  • printGalleryDesc
  • printGalleryIndexURL
  • printGalleryTitle
  • printGoogleMap
  • printHeadTitle
  • printHomeLink
  • printImageCustomData
  • printImageData
  • printImageDate
  • printImageDesc
  • printImageDiv
  • printImageEXIFData
  • printImageID
  • printImageLink
  • printImageMap
  • printImageMetadata
  • printImageRating
  • printImageSortOrder
  • printImageStatistic
  • printImageThumb
  • printImageTitle
  • printImageURL
  • printItemEditLink
  • printItemsList
  • printItemsListTable
  • printItemStatusDropdown
  • printjCarouselThumbNav
  • printjPlayerPlaylist
  • printLanguageSelector
  • printLatestAlbums
  • printLatestComments
  • printLatestImages
  • printLatestImagesByDate
  • printLatestImagesByMtime
  • printLatestNews
  • printLatestUpdatedAlbums
  • printLatestZenpageComments
  • printLink
  • printLinkHTML
  • printLogoAndLinks
  • printManagedObjects
  • printMenuemanagerPageList
  • printMenuemanagerPageListWithNav
  • printMenumanagerBreadcrumb
  • printMenumanagerNextLink
  • printMenumanagerPrevLink
  • printMostPopularItems
  • printMostRatedAlbums
  • printMostRatedImages
  • printMostRatedItems
  • printNestedAlbumsList
  • printNestedItemsList
  • printNestedMenu
  • printNews
  • printNewsArchive
  • printNewsAuthor
  • printNewsCategories
  • printNewsCategoryCustomData
  • printNewsCategoryDesc
  • printNewsCategoryURL
  • printNewsContent
  • printNewsCustomData
  • printNewsDate
  • printNewsExtraContent
  • printNewsImageTags
  • printNewsIndexURL
  • printNewsLink
  • printNewsPageList
  • printNewsPageListWithNav
  • printNewsReadMoreLink
  • printNewsStatistic
  • printNewsTitle
  • printNewsTitleLink
  • printNewsURL
  • printNextNewsLink
  • printNextNewsPageLink
  • printNextPageLink
  • printNextPageURL
  • printPageArticleTags
  • printPageAuthor
  • printPageContent
  • printPageCustomData
  • printPageDate
  • printPagedThumbsNav
  • printPageExtraContent
  • printPageID
  • printPageLastChangeDate
  • printPageLinkURL
  • printPageList
  • printPageListWithNav
  • printPageMenu
  • printPageNav
  • printPageSelector
  • printPagesListTable
  • printPagesStatistic
  • printPageTitle
  • printPageTitleLink
  • printPageURL
  • printParentBreadcrumb
  • printParentPagesBreadcrumb
  • printPasswordForm
  • printPopularAlbums
  • printPopularImages
  • printPreloadScript
  • printPrevNewsLink
  • printPrevNewsPageLink
  • printPrevPageLink
  • printPrevPageURL
  • printPublished
  • printPublishIconLink
  • printRandomImages
  • printRating
  • printRegisterURL
  • printRegistrationForm
  • printRelatedItems
  • printRSSHeaderLink
  • printRSSLink
  • printSearchBreadcrumb
  • printSearchForm
  • printSiteHomeURL
  • printSizedImageLink
  • printSizedImageURL
  • printSlideShow
  • printSlideShowJS
  • printSlideShowLink
  • printSortableHead
  • printSortOrderDropdown
  • printSubPagesExcerpts
  • printSubtabs
  • printTabs
  • printTags
  • printThumbNav
  • printTopRatedAlbums
  • printTopRatedImages
  • printTopRatedItems
  • printUnpublishedDropdown
  • printUserLogin_out
  • printUserSizeImage
  • printUserSizeSelector
  • printVersion
  • printZenJavascripts
  • printZenpageIconLegend
  • printZenpageItemsBreadcrumb
  • printZenpageNewsCategorySelector
  • printZenpagePagesSelector
  • printZenpageRSSHeaderLink
  • printZenpageRSSLink
  • printZenpageStatistic
  • printZenphotoLink
  • process_language_string_save
  • processAlbumBulkActions
  • processAlbumEdit
  • processCodeblockSave
  • processCommentBulkActions
  • processCredentials
  • processCustomOptionSave
  • processEditSelection
  • processExpired
  • processImageBulkActions
  • processImageEdit
  • processManagedObjects
  • processMenuBulkActions
  • processOrder
  • processRights
  • processTags
  • processZenpageBulkActions
  • propSizes
  • publishItem
  • purgeOption
  • query
  • query_full_array
  • query_single_row
  • rc4
  • read_exif_data_protected
  • readTags
  • recaptcha_check_answer
  • recaptcha_get_html
  • recaptcha_get_signup_url
  • recaptcha_mailhide_html
  • recaptcha_mailhide_url
  • reconfigureAction
  • reconfigureCS
  • reconfigurePage
  • recordMissing
  • rem_context
  • removeParentAlbumNames
  • resetCurrentAlbum
  • restore_context
  • reveal
  • rewrite_get_album_image
  • rewrite_path
  • rewrite_path_zenpage
  • RSS_Channel
  • RSS_Retrieve
  • RSS_Tags
  • rulesList
  • run
  • safe_fnmatch
  • safe_glob
  • sanitize
  • sanitize_numeric
  • sanitize_path
  • sanitize_script
  • sanitize_string
  • sanitizeRedirect
  • save_context
  • saveLayoutSelection
  • saveZenphotoLayoutSelection
  • search_quote
  • secureServer
  • seo_cleanup_button
  • seoFriendly
  • seoFriendlyJS
  • set_context
  • setAlbumCustomData
  • setAlbumSubtabs
  • setImageCustomData
  • setMainDomain
  • setOption
  • setOptionDefault
  • setPluginDomain
  • setThemeColumns
  • setThemeDomain
  • setThemeOption
  • setThemeOptionDefault
  • setupAllowedMaps
  • setupCurrentLocale
  • setupDomain
  • setupTheme
  • shortenContent
  • showOrNotShowField
  • shuffle_assoc
  • signatureChange
  • site_upgrade_button
  • site_upgrade_status
  • sitemap_echonl
  • sitemap_getChangefreq
  • sitemap_getDateformat
  • sitemap_getDBLimit
  • sitemap_getISO8601Date
  • skipScheduledPublishing
  • sortByKey
  • sortByMultilingual
  • sortMultiArray
  • standardScripts
  • standardThemeOptions
  • stickyNews
  • storeConfig
  • storeTags
  • stripSuffix
  • submenuOf
  • switchLog
  • tagSelector
  • tagSuggestJS
  • tagSuggestJS_admin
  • tagSuggestJS_frontend
  • themeIsEditable
  • themeSetup
  • timezoneDiff
  • tinymce4ConfigJS
  • truncate_string
  • unpublishedZenphotoItemCheck
  • unpublishSubalbums
  • unQuote
  • unzip
  • updateArticle
  • updateCacheName
  • updateCategory
  • updateConfigItem
  • updateItemSortorder
  • updateItemsSortorder
  • updateMenuItem
  • updatePage
  • upload_extra
  • upload_form
  • upload_head
  • user_mailing_list_button
  • validateLocale
  • wordpress_import_button
  • wp_prefix
  • wp_query_full_array
  • wpimport_TryAgainError
  • XSRFdefender
  • XSRFToken
  • zenJavascript
  • zenpageAlbumImage
  • zenpageBulkActionMessage
  • zenpageHitcounter
  • zenpageJSCSS
  • zenpageOpenedForComments
  • zenpagePublish
  • zenphoto_PHPMailer
  • zenphoto_sendmail
  • zenPhotoTheme
  • zp_apply_filter
  • zp_clearCookie
  • zp_colorAllocate
  • zp_cookieEncode
  • zp_copyCanvas
  • zp_createImage
  • zp_drawRectangle
  • zp_error
  • zp_filter_slot
  • zp_filter_unique_id
  • zp_getCookie
  • zp_getFonts
  • zp_graphicsLibInfo
  • zp_handle_password
  • zp_handle_password_single
  • zp_has_filter
  • zp_image_types
  • zp_imageCanRotate
  • zp_imageColorTransparent
  • zp_imageDims
  • zp_imageFill
  • zp_imageFontHeight
  • zp_imageFontWidth
  • zp_imageFromString
  • zp_imageGet
  • zp_imageGray
  • zp_imageHeight
  • zp_imageIPTC
  • zp_imageKill
  • zp_imageLoadFont
  • zp_imageMerge
  • zp_imageOutput
  • zp_imageResizeAlpha
  • zp_imageUnsharpMask
  • zp_imageWidth
  • zp_load_album
  • zp_load_gallery
  • zp_load_image
  • zp_load_page
  • zp_load_request
  • zp_load_search
  • zp_loggedin
  • zp_mail
  • zp_register_filter
  • zp_remove_filter
  • zp_resampleImage
  • zp_rotateImage
  • zp_session_start
  • zp_setCookie
  • zp_writeString
  • zpErrorHandler
  • zpFormattedDate
  • zpRewriteURL
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
   1: <?php
   2: /**
   3:  * support functions for Admin
   4:  * @package admin
   5:  */
   6: // force UTF-8 Ø
   7: 
   8: require_once(dirname(__FILE__) . '/functions.php');
   9: 
  10: define('TEXTAREA_COLUMNS', 50);
  11: define('TEXT_INPUT_SIZE', 48);
  12: define('TEXTAREA_COLUMNS_SHORT', 32);
  13: define('TEXT_INPUT_SIZE_SHORT', 30);
  14: if (!defined('EDITOR_SANITIZE_LEVEL'))
  15:     define('EDITOR_SANITIZE_LEVEL', 1);
  16: 
  17: /**
  18:  * Print the footer <div> for the bottom of all admin pages.
  19:  *
  20:  * @param string $addl additional text to output on the footer.
  21:  * @author Todd Papaioannou (lucky@luckyspin.org)
  22:  * @since  1.0.0
  23:  */
  24: function printAdminFooter($addl = '') {
  25:     ?>
  26:     <div id="footer">
  27:         <?php
  28:         printf(gettext('<a href="http://www.zenphoto.org" title="The simpler media website CMS">Zen<strong>photo</strong></a> version %1$s [%2$s]'), ZENPHOTO_VERSION, ZENPHOTO_RELEASE);
  29:         if (!empty($addl)) {
  30:             echo ' | ' . $addl;
  31:         }
  32:         ?>
  33:         | <a href="<?php echo FULLWEBPATH . '/' . ZENFOLDER . '/license.php' ?>" title="<?php echo gettext('Zenphoto licence'); ?>"><?php echo gettext('License'); ?></a>
  34:         | <a href="http://www.zenphoto.org/news/category/user-guide" title="<?php echo gettext('User guide'); ?>"><?php echo gettext('User guide'); ?></a>
  35:         | <a href="http://www.zenphoto.org/support/" title="<?php echo gettext('Forum'); ?>"><?php echo gettext('Forum'); ?></a>
  36:         | <a href="https://github.com/zenphoto/zenphoto/issues" title="<?php echo gettext('Bugtracker'); ?>"><?php echo gettext('Bugtracker'); ?></a>
  37:         | <a href="http://www.zenphoto.org/news/category/changelog" title="<?php echo gettext('View Change log'); ?>"><?php echo gettext('Change log'); ?></a>
  38:         | <?php printf(gettext('Server date: %s'), date('Y-m-d H:i:s')); ?>
  39:     </div>
  40:     <?php
  41:     db_close(); //  close the database as we are done
  42: }
  43: 
  44: function datepickerJS() {
  45:     $lang = str_replace('_', '-', getOption('locale'));
  46:     if (!file_exists(SERVERPATH . '/' . ZENFOLDER . '/js/jqueryui/i18n/jquery.ui.datepicker-' . $lang . '.js')) {
  47:         $lang = substr($lang, 0, 2);
  48:         if (!file_exists(SERVERPATH . '/' . ZENFOLDER . '/js/jqueryui/i18n/jquery.ui.datepicker-' . $lang . '.js')) {
  49:             $lang = '';
  50:         }
  51:     }
  52:     if (!empty($lang)) {
  53:         ?>
  54:         <script src="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/js/jqueryui/i18n/jquery.ui.datepicker-<?php echo $lang; ?>.js" type="text/javascript"></script>
  55:         <?php
  56:     }
  57: }
  58: 
  59: /**
  60:  * Print the header for all admin pages. Starts at <DOCTYPE> but does not include the </head> tag,
  61:  * in case there is a need to add something further.
  62:  *
  63:  * @param string $tab the album page
  64:  * @param string $subtab the sub-tab if any
  65:  */
  66: function printAdminHeader($tab, $subtab = NULL) {
  67:     global $_zp_admin_tab, $_zp_admin_subtab, $_zp_gallery, $zenphoto_tabs, $_zp_RTL_css;
  68:     $_zp_admin_tab = $tab;
  69:     if (isset($_GET['tab'])) {
  70:         $_zp_admin_subtab = sanitize($_GET['tab'], 3);
  71:     } else {
  72:         $_zp_admin_subtab = $subtab;
  73:     }
  74:     $tabtext = $_zp_admin_tab;
  75:     $tabrow = NULL;
  76:     foreach ($zenphoto_tabs as $key => $tabrow) {
  77:         if ($key == $_zp_admin_tab) {
  78:             $tabtext = $tabrow['text'];
  79:             break;
  80:         }
  81:         $tabrow = NULL;
  82:     }
  83:     if (empty($_zp_admin_subtab) && $tabrow && isset($tabrow['default'])) {
  84:         $_zp_admin_subtab = $zenphoto_tabs[$_zp_admin_tab]['default'];
  85:     }
  86:     $subtabtext = '';
  87:     if ($_zp_admin_subtab && $tabrow && array_key_exists('subtabs', $tabrow) && $tabrow['subtabs']) {
  88:         foreach ($tabrow['subtabs'] as $key => $link) {
  89:             $i = strpos($link, '&tab=');
  90:             if ($i !== false) {
  91:                 $text = substr($link, $i + 9);
  92:                 if ($text == $_zp_admin_subtab) {
  93:                     $subtabtext = '-' . $key;
  94:                     break;
  95:                 }
  96:             }
  97:         }
  98:     }
  99:     if (empty($subtabtext)) {
 100:         if ($_zp_admin_subtab) {
 101:             $subtabtext = '-' . $_zp_admin_subtab;
 102:         }
 103:     }
 104:     header('Last-Modified: ' . ZP_LAST_MODIFIED);
 105:     header('Content-Type: text/html; charset=' . LOCAL_CHARSET);
 106:     zp_apply_filter('admin_headers');
 107:     ?>
 108:     <!DOCTYPE html>
 109:     <html>
 110:         <head>
 111:             <meta http-equiv="content-type" content="text/html; charset=<?php echo LOCAL_CHARSET; ?>" />
 112:             <link rel="stylesheet" href="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/js/toggleElements.css" type="text/css" />
 113:             <link rel="stylesheet" href="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/js/jqueryui/jquery-ui-zenphoto.css" type="text/css" />
 114:             <link rel="stylesheet" href="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/admin.css" type="text/css" />
 115:             <?php
 116:             if ($_zp_RTL_css) {
 117:                 ?>
 118:                 <link rel="stylesheet" href="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/admin-rtl.css" type="text/css" />
 119:                 <?php
 120:             }
 121:             ?>
 122:             <title><?php echo sprintf(gettext('%1$s %2$s: %3$s%4$s'), html_encode($_zp_gallery->getTitle()), gettext('admin'), html_encode($tabtext), html_encode($subtabtext)); ?></title>
 123:             <script src="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/js/jquery.js" type="text/javascript"></script>
 124:             <script src="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/js/jqueryui/jquery-ui-zenphoto.js" type="text/javascript"></script>
 125:             <script src="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/js/zenphoto.js" type="text/javascript" ></script>
 126:             <script src="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/js/admin.js" type="text/javascript" ></script>
 127:             <script src="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/js/jquery.scrollTo.js" type="text/javascript"></script>
 128:             <script src="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/js/jquery.dirtyforms.min.js" type="text/javascript"></script>
 129:             <script type="text/javascript">
 130:                 // <!-- <![CDATA[
 131: 
 132:                 $(document).ready(function() {
 133:                 <?php
 134:                 if (zp_has_filter('admin_head', 'colorbox::css')) {
 135:                     ?>
 136:                                     $("a.colorbox").colorbox({
 137:                                         maxWidth: "98%",
 138:                                         maxHeight: "98%",
 139:                                         close: '<?php echo addslashes(gettext("close")); ?>'
 140:                                     });
 141: 
 142:                     <?php
 143:                 }
 144:                 ?>
 145:                 $('form.dirty-check').dirtyForms({ 
 146:                     message: '<?php echo addslashes(gettext('You have unsaved changes!')); ?>' 
 147:                 });
 148:                 });
 149:                 $(function() {
 150:                     $(".tooltip ").tooltip({
 151:                         show: 1000,
 152:                         hide: 1000,
 153:                         position: {
 154:                             my: "center bottom-20",
 155:                             at: "center top",
 156:                             using: function(position, feedback) {
 157:                                 $(this).css(position);
 158:                                 $("<div>")
 159:                                                 .addClass("arrow")
 160:                                                 .addClass(feedback.vertical)
 161:                                                 .addClass(feedback.horizontal)
 162:                                                 .appendTo(this);
 163:                             }
 164:                         }
 165:                     });
 166:                     $(".page-list_icon").tooltip({
 167:                         show: 1000,
 168:                         hide: 1000,
 169:                         position: {
 170:                             my: "center bottom-20",
 171:                             at: "center top",
 172:                             using: function(position, feedback) {
 173:                                 $(this).css(position);
 174:                                 $("<div>")
 175:                                                 .addClass("arrow")
 176:                                                 .addClass(feedback.vertical)
 177:                                                 .addClass(feedback.horizontal)
 178:                                                 .appendTo(this);
 179:                             }
 180:                         }
 181:                     });
 182:                 });
 183:                 jQuery(function($) {
 184:                     $(".fade-message").fadeTo(5000, 1).fadeOut(1000);
 185:                 })
 186:                 // ]]> -->
 187:             </script>
 188:             <?php
 189:             zp_apply_filter('admin_head');
 190:         }
 191: 
 192:         function printSortableHead() {
 193:             ?>
 194:             <!--Nested Sortables-->
 195:             <script type="text/javascript" src="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/js/jquery.ui.nestedSortable.js"></script>
 196:             <script type="text/javascript">
 197:                 //<!-- <![CDATA[
 198:                 $(document).ready(function() {
 199: 
 200:                     $('ul.page-list').nestedSortable({
 201:                         disableNesting: 'no-nest',
 202:                         forcePlaceholderSize: true,
 203:                         handle: 'div',
 204:                         items: 'li',
 205:                         opacity: .6,
 206:                         placeholder: 'placeholder',
 207:                         tabSize: 25,
 208:                         tolerance: 'intersect',
 209:                         toleranceElement: '> div',
 210:                         listType: 'ul'
 211:                     });
 212: 
 213:                     $('.serialize').click(function() {
 214:                         serialized = $('ul.page-list').nestedSortable('serialize');
 215:                         if (serialized != original_order) {
 216:                             $('#serializeOutput').html('<input type="hidden" name="order" size="30" maxlength="1000" value="' + serialized + '" />');
 217:                         }
 218:                     })
 219:                     var original_order = $('ul.page-list').nestedSortable('serialize');
 220:                 });
 221:                 // ]]> -->
 222:             </script>
 223:             <!--Nested Sortables End-->
 224:             <?php
 225:         }
 226: 
 227:         /**
 228:          * Print the html required to display the ZP logo and links in the top section of the admin page.
 229:          *
 230:          * @author Todd Papaioannou (lucky@luckyspin.org)
 231:          * @since  1.0.0
 232:          */
 233:         function printLogoAndLinks() {
 234:             global $_zp_current_admin_obj, $_zp_admin_tab, $_zp_admin_subtab, $_zp_gallery;
 235:             if ($_zp_admin_subtab) {
 236:                 $subtab = '-' . $_zp_admin_subtab;
 237:             } else {
 238:                 $subtab = '';
 239:             }
 240:             ?>
 241:         <span id="administration">
 242:             <img id="logo" src="<?php echo WEBPATH . '/' . ZENFOLDER; ?>/images/zen-logo.png"
 243:                      title="<?php echo sprintf(gettext('%1$s administration:%2$s%3$s'), html_encode($_zp_gallery->getTitle()), html_encode($_zp_admin_tab), html_encode($subtab)); ?>"
 244:                      alt="<?php echo gettext('Zenphoto Administration'); ?>" align="bottom" />
 245:         </span>
 246:         <?php
 247:         echo "\n<div id=\"links\">";
 248:         echo "\n  ";
 249:         if (!is_null($_zp_current_admin_obj)) {
 250:             $sec = (int) ((SERVER_PROTOCOL == 'https') & true);
 251:             $last = $_zp_current_admin_obj->getLastlogon();
 252:             if (empty($last)) {
 253:                 printf(gettext('Logged in as %1$s'), $_zp_current_admin_obj->getUser());
 254:             } else {
 255:                 printf(gettext('Logged in as %1$s (last login %2$s)'), $_zp_current_admin_obj->getUser(), $last);
 256:             }
 257:             if ($_zp_current_admin_obj->logout_link) {
 258:                 $link = WEBPATH . "/" . ZENFOLDER . "/admin.php?logout=" . $sec;
 259:                 echo " &nbsp; | &nbsp; <a href=\"" . $link . "\">" . gettext("Log Out") . "</a> &nbsp; | &nbsp; ";
 260:             }
 261:         }
 262:         echo ' <a href="' . FULLWEBPATH . '/">';
 263:         $t = $_zp_gallery->getTitle();
 264:         if (!empty($t)) {
 265:             printf(gettext("View <em>%s</em>"), $t);
 266:         } else {
 267:             echo gettext("View gallery index");
 268:         }
 269:         echo "</a>";
 270:         echo "\n</div>";
 271:     }
 272: 
 273:     /**
 274:      * Print the nav tabs for the admin section. We determine which tab should be highlighted
 275:      * from the $_GET['page']. If none is set, we default to "home".
 276:      *
 277:      * @author Todd Papaioannou (lucky@luckyspin.org)
 278:      * @since  1.0.0
 279:      */
 280:     function printTabs() {
 281:         global $subtabs, $zenphoto_tabs, $main_tab_space, $_zp_admin_tab;
 282:         $chars = 0;
 283:         foreach ($zenphoto_tabs as $atab) {
 284:             $chars = $chars + mb_strlen($atab['text']);
 285:         }
 286:         switch (getOption('locale')) {
 287:             case 'zh_CN':
 288:             case 'zh_TW':
 289:             case 'ja_JP':
 290:                 $main_tab_space = count($zenphoto_tabs) * 3 + $chars;
 291:                 break;
 292:             default:
 293:                 $main_tab_space = round((count($zenphoto_tabs) * 32 + round($chars * 7.5)) / 11.5);
 294:                 break;
 295:         }
 296:         ?>
 297:         <ul class="nav" style="width: <?php echo $main_tab_space; ?>em">
 298:             <?php
 299:             foreach ($zenphoto_tabs as $key => $atab) {
 300:                 ?>
 301:                 <li <?php if ($_zp_admin_tab == $key) echo 'class="current"' ?>>
 302:                     <a href="<?php echo html_encode($atab['link']); ?>"><?php echo html_encode(ucfirst($atab['text'])); ?></a>
 303:                     <?php
 304:                     $subtabs = $zenphoto_tabs[$key]['subtabs'];
 305:                     if (is_array($subtabs)) { // don't print <ul> if there is nothing
 306:                         if ($_zp_admin_tab != $key) { // don't print sublist if already on the main tab
 307:                             ?>
 308:                             <ul class="subdropdown">
 309:                                 <?php
 310:                                 foreach ($subtabs as $key => $link) {
 311:                                     if (strpos($link, '/') !== 0) { // zp_core relative
 312:                                         $link = WEBPATH . '/' . ZENFOLDER . '/' . $link;
 313:                                     } else {
 314:                                         $link = WEBPATH . $link;
 315:                                     }
 316:                                     ?>
 317:                                     <li><a href="<?php echo html_encode($link); ?>"><?php echo html_encode(ucfirst($key)); ?></a></li>
 318:                                     <?php
 319:                                 } // foreach end
 320:                                 ?>
 321:                             </ul>
 322:                             <?php
 323:                         } // if $subtabs end
 324:                     } // if array
 325:                     ?>
 326:                 </li>
 327:                 <?php
 328:             }
 329:             ?>
 330:         </ul>
 331:         <br class="clearall" /><!-- needed so the nav sits correctly -->
 332:         <?php
 333:     }
 334: 
 335:     function getSubtabs() {
 336:         global $zenphoto_tabs, $_zp_admin_tab, $_zp_admin_subtab;
 337:         $tabs = @$zenphoto_tabs[$_zp_admin_tab]['subtabs'];
 338:         if (!is_array($tabs))
 339:             return $_zp_admin_subtab;
 340:         $current = $_zp_admin_subtab;
 341:         if (isset($_GET['tab'])) {
 342:             $test = sanitize($_GET['tab']);
 343:             foreach ($tabs as $link) {
 344:                 $i = strrpos($link, 'tab=');
 345:                 $amp = strrpos($link, '&');
 346:                 if ($i !== false) {
 347:                     if ($amp > $i) {
 348:                         $link = substr($link, 0, $amp);
 349:                     }
 350:                     if ($test == substr($link, $i + 4)) {
 351:                         $current = $test;
 352:                         break;
 353:                     }
 354:                 }
 355:             }
 356:         }
 357:         if (empty($current)) {
 358:             if (isset($zenphoto_tabs[$_zp_admin_tab]['default'])) {
 359:                 $current = $zenphoto_tabs[$_zp_admin_tab]['default'];
 360:             } else if (empty($_zp_admin_subtab)) {
 361:                 $current = array_shift($tabs);
 362:                 $i = strrpos($current, 'tab=');
 363:                 $amp = strrpos($current, '&');
 364:                 if ($i === false) {
 365:                     $current = '';
 366:                 } else {
 367:                     if ($amp > $i) {
 368:                         $current = substr($current, 0, $amp);
 369:                     }
 370:                     $current = substr($current, $i + 4);
 371:                 }
 372:             } else {
 373:                 $current = $_zp_admin_subtab;
 374:             }
 375:         }
 376:         return $current;
 377:     }
 378: 
 379:     function printSubtabs() {
 380:         global $zenphoto_tabs, $_zp_admin_tab, $_zp_admin_subtab;
 381:         $tabs = @$zenphoto_tabs[$_zp_admin_tab]['subtabs'];
 382:         $current = getSubtabs();
 383:         if (!empty($tabs)) {
 384:             $chars = 0;
 385:             foreach ($tabs as $atab => $val) {
 386:                 $chars = $chars + mb_strlen($atab);
 387:             }
 388:             switch (getOption('locale')) {
 389:                 case 'zh_CN':
 390:                 case 'zh_TW':
 391:                 case 'ja_JP':
 392:                     $sub_tab_space = count($tabs) * 3 + $chars;
 393:                     break;
 394:                 default:
 395:                     $sub_tab_space = round((count($tabs) * 32 + round($chars * 7.5)) / 11.5);
 396:                     break;
 397:             }
 398:             ?>
 399:             <ul class="subnav" style="width: <?php echo $sub_tab_space; ?>em">
 400:                 <?php
 401:                 foreach ($tabs as $key => $link) {
 402:                     $i = strrpos($link, 'tab=');
 403:                     $amp = strrpos($link, '&');
 404:                     if ($i === false) {
 405:                         $tab = $_zp_admin_subtab;
 406:                     } else {
 407:                         if ($amp > $i) {
 408:                             $source = substr($link, 0, $amp);
 409:                         } else {
 410:                             $source = $link;
 411:                         }
 412:                         $tab = substr($source, $i + 4);
 413:                     }
 414:                     if (!$link) {
 415:                         $bt = debug_backtrace();
 416:                         $bt = array_shift($bt);
 417:                         if (isset($bt['file'])) {
 418:                             $link = str_replace(SERVERPATH, '', str_replace('\\', '/', $bt['file']));
 419:                         }
 420:                     }
 421:                     if (strpos($link, '/') !== 0) { // zp_core relative
 422:                         $link = WEBPATH . '/' . ZENFOLDER . '/' . $link;
 423:                     } else {
 424:                         $link = WEBPATH . $link;
 425:                     }
 426:                     echo '<li' . (($current == $tab) ? ' class="current"' : '') . '><a href="' . html_encode($link) . '">' . html_encode(ucfirst($key)) . '</a></li>' . "\n";
 427:                 }
 428:                 ?>
 429:             </ul>
 430:             <?php
 431:         }
 432:         return $current;
 433:     }
 434: 
 435:     function setAlbumSubtabs($album) {
 436:         global $zenphoto_tabs;
 437:         $albumlink = '?page=edit&album=' . urlencode($album->name);
 438:         $default = NULL;
 439:         if (!is_array($zenphoto_tabs['edit']['subtabs'])) {
 440:             $zenphoto_tabs['edit']['subtabs'] = array();
 441:         }
 442:         $subrights = $album->albumSubRights();
 443:         if (!$album->isDynamic() && $album->getNumImages()) {
 444:             if ($subrights & (MANAGED_OBJECT_RIGHTS_UPLOAD || MANAGED_OBJECT_RIGHTS_EDIT)) {
 445:                 $zenphoto_tabs['edit']['subtabs'] = array_merge(
 446:                                 array(gettext('Images') => 'admin-edit.php' . $albumlink . '&tab=imageinfo'), $zenphoto_tabs['edit']['subtabs']
 447:                 );
 448:                 $default = 'imageinfo';
 449:             }
 450:             if ($subrights & MANAGED_OBJECT_RIGHTS_EDIT) {
 451:                 $zenphoto_tabs['edit']['subtabs'] = array_merge(
 452:                                 array(gettext('Image order') => 'admin-albumsort.php' . $albumlink . '&tab=sort'), $zenphoto_tabs['edit']['subtabs']
 453:                 );
 454:             }
 455:         }
 456:         if (!$album->isDynamic() && $album->getNumAlbums()) {
 457:             $zenphoto_tabs['edit']['subtabs'] = array_merge(
 458:                             array(gettext('Subalbums') => 'admin-edit.php' . $albumlink . '&tab=subalbuminfo'), $zenphoto_tabs['edit']['subtabs']
 459:             );
 460:             $default = 'subalbuminfo';
 461:         }
 462:         if ($subrights & MANAGED_OBJECT_RIGHTS_EDIT) {
 463:             $zenphoto_tabs['edit']['subtabs'] = array_merge(
 464:                             array(gettext('Album') => 'admin-edit.php' . $albumlink . '&tab=albuminfo'), $zenphoto_tabs['edit']['subtabs']
 465:             );
 466:             $default = 'albuminfo';
 467:         }
 468:         $zenphoto_tabs['edit']['default'] = $default;
 469:         if (isset($_GET['tab'])) {
 470:             return sanitize($_GET['tab']);
 471:         }
 472:         return $default;
 473:     }
 474: 
 475:     function checked($checked, $current) {
 476:         if ($checked == $current)
 477:             echo ' checked="checked"';
 478:     }
 479: 
 480:     function genAlbumList(&$list, $curAlbum = NULL, $rights = UPLOAD_RIGHTS) {
 481:         global $_zp_gallery;
 482:         if (is_null($curAlbum)) {
 483:             $albums = array();
 484:             $albumsprime = $_zp_gallery->getAlbums(0);
 485:             foreach ($albumsprime as $album) { // check for rights
 486:                 $albumobj = newAlbum($album);
 487:                 if ($albumobj->isMyItem($rights)) {
 488:                     $albums[] = $album;
 489:                 }
 490:             }
 491:         } else {
 492:             $albums = $curAlbum->getAlbums(0);
 493:         }
 494:         if (is_array($albums)) {
 495:             foreach ($albums as $folder) {
 496:                 $album = newAlbum($folder);
 497:                 if ($album->isDynamic()) {
 498:                     if ($rights == ALL_ALBUMS_RIGHTS) {
 499:                         $list[$album->getFileName()] = $album->getTitle();
 500:                     }
 501:                 } else {
 502:                     $list[$album->getFileName()] = $album->getTitle();
 503:                     genAlbumList($list, $album, $rights); /* generate for subalbums */
 504:                 }
 505:             }
 506:         }
 507:     }
 508: 
 509:     define('CUSTOM_OPTION_PREFIX', '_ZP_CUSTOM_');
 510:     /**
 511:      * Generates the HTML for custom options (e.g. theme options, plugin options, etc.)
 512:      * Note: option names may not contain '.', '+', nor '%' as PHP POST handling will replace
 513:      * these with an underscore.
 514:      *
 515:      * @param object $optionHandler the object to handle custom options
 516:      * @param string $indent used to indent the option for nested options
 517:      * @param object $album if not null, the album to which the option belongs
 518:      * @param bool $hide set to true to hide the output (used by the plugin-options folding
 519:      * $paran array $supportedOptions pass these in if you already have them
 520:      * @param bool $theme set true if dealing with theme options
 521:      * @param string $initial initila show/hide state
 522:      *
 523:      * Custom options:
 524:      *    OPTION_TYPE_TEXTBOX:          A textbox
 525:      *    OPTION_TYPE_PASSWORD:         A passowrd textbox
 526:      *    OPTION_TYPE_CLEARTEXT:          A textbox, but no sanitization on save
 527:      *    OPTION_TYPE_CHECKBOX:         A checkbox
 528:      *    OPTION_TYPE_CUSTOM:           Handled by $optionHandler->handleOption()
 529:      *    OPTION_TYPE_TEXTAREA:         A textarea
 530:      *    OPTION_TYPE_RICHTEXT:         A textarea with WYSIWYG editor attached
 531:      *    OPTION_TYPE_RADIO:            Radio buttons (button names are in the 'buttons' index of the supported options array)
 532:      *    OPTION_TYPE_SELECTOR:         Selector (selection list is in the 'selections' index of the supported options array
 533:      *                                  null_selection contains the text for the empty selection. If not present there
 534:      *                                  will be no empty selection)
 535:      *    OPTION_TYPE_CHECKBOX_ARRAY:   Checkbox array (checkbox list is in the 'checkboxes' index of the supported options array.)
 536:      *    OPTION_TYPE_CHECKBOX_UL:      Checkbox UL (checkbox list is in the 'checkboxes' index of the supported options array.)
 537:      *    OPTION_TYPE_COLOR_PICKER:     Color picker
 538:      *    OPTION_TYPE_NOTE:             Places a note in the options area. The note will span all three columns
 539:      *
 540:      *    Types 0 and 5 support multi-lingual strings.
 541:      */
 542:     define('OPTION_TYPE_TEXTBOX', 0);
 543:     define('OPTION_TYPE_CHECKBOX', 1);
 544:     define('OPTION_TYPE_CUSTOM', 2);
 545:     define('OPTION_TYPE_TEXTAREA', 3);
 546:     define('OPTION_TYPE_RADIO', 4);
 547:     define('OPTION_TYPE_SELECTOR', 5);
 548:     define('OPTION_TYPE_CHECKBOX_ARRAY', 6);
 549:     define('OPTION_TYPE_CHECKBOX_UL', 7);
 550:     define('OPTION_TYPE_COLOR_PICKER', 8);
 551:     define('OPTION_TYPE_CLEARTEXT', 9);
 552:     define('OPTION_TYPE_NOTE', 10);
 553:     define('OPTION_TYPE_PASSWORD', 11);
 554:     define('OPTION_TYPE_RICHTEXT', 12);
 555: 
 556:     function customOptions($optionHandler, $indent = "", $album = NULL, $showhide = false, $supportedOptions = NULL, $theme = false, $initial = 'none', $extension = NULL) {
 557:         if (is_null($supportedOptions)) {
 558:             $supportedOptions = $optionHandler->getOptionsSupported();
 559:         }
 560:         if (count($supportedOptions) > 0) {
 561:             $whom = get_class($optionHandler);
 562:             $options = $supportedOptions;
 563:             $option = array_shift($options);
 564:             if (array_key_exists('order', $option)) {
 565:                 $options = sortMultiArray($supportedOptions, 'order', false, true, false, true);
 566:                 $options = array_keys($options);
 567:             } else {
 568:                 $options = array_keys($supportedOptions);
 569:                 natcasesort($options);
 570:             }
 571:             if (method_exists($optionHandler, 'handleOptionSave')) {
 572:                 ?>
 573:                 <input type="hidden" name="<?php echo CUSTOM_OPTION_PREFIX; ?>save-<?php echo $whom; ?>" value="<?php echo $extension; ?>" />
 574:                 <?php
 575:             }
 576:             foreach ($options as $option) {
 577:                 $row = $supportedOptions[$option];
 578:                 if (false !== $i = stripos($option, chr(0))) {
 579:                     $option = substr($option, 0, $i);
 580:                 }
 581: 
 582:                 $type = $row['type'];
 583:                 $desc = $row['desc'];
 584:                 $key = @$row['key'];
 585:                 $optionID = $whom . '_' . $key;
 586:                 if (isset($row['multilingual'])) {
 587:                     $multilingual = $row['multilingual'];
 588:                 } else {
 589:                     $multilingual = $type == OPTION_TYPE_TEXTAREA;
 590:                 }
 591:                 if (isset($row['texteditor']) && $row['texteditor']) {
 592:                     $editor = 'texteditor';
 593:                 } else {
 594:                     $editor = '';
 595:                 }
 596:                 if (isset($row['disabled']) && $row['disabled']) {
 597:                     $disabled = ' disabled="disabled"';
 598:                 } else {
 599:                     $disabled = '';
 600:                 }
 601:                 if (isset($row['deprecated']) && $option) {
 602:                     $deprecated = $row['deprecated'];
 603:                     if (!$deprecated) {
 604:                         $deprecatedd = gettext('Deprecated.');
 605:                     }
 606:                     $option = '<div class="warningbox">' . $option . '<br /><em>' . $deprecated . '</em></div>';
 607:                 }
 608:                 if ($theme) {
 609:                     $v = getThemeOption($key, $album, $theme);
 610:                 } else {
 611:                     $sql = "SELECT `value` FROM " . prefix('options') . " WHERE `name`=" . db_quote($key);
 612:                     $db = query_single_row($sql);
 613:                     if ($db) {
 614:                         $v = $db['value'];
 615:                     } else {
 616:                         $v = NULL;
 617:                     }
 618:                 }
 619: 
 620:                 if ($showhide) {
 621:                     ?>
 622:                     <tr id="tr_<?php echo $optionID; ?>" class="<?php echo $showhide; ?>extrainfo" style="display:<?php echo $initial; ?>">
 623:                         <?php
 624:                     } else {
 625:                         ?>
 626:                     <tr id="tr_<?php echo $optionID; ?>">
 627:                         <?php
 628:                     }
 629:                     if ($type != OPTION_TYPE_NOTE) {
 630:                         ?>
 631:                         <td width="175"><?php if ($option) echo $indent . $option; ?></td>
 632:                         <?php
 633:                     }
 634:                     switch ($type) {
 635:                         case OPTION_TYPE_NOTE:
 636:                             ?>
 637:                             <td colspan="3"><?php echo $desc; ?></td>
 638:                             <?php
 639:                             break;
 640:                         case OPTION_TYPE_CLEARTEXT:
 641:                             $multilingual = false;
 642:                         case OPTION_TYPE_PASSWORD:
 643:                         case OPTION_TYPE_TEXTBOX:
 644:                         case OPTION_TYPE_TEXTAREA:
 645:                         case OPTION_TYPE_RICHTEXT;
 646:                             if ($type == OPTION_TYPE_CLEARTEXT) {
 647:                                 $clear = 'clear';
 648:                             } else {
 649:                                 $clear = '';
 650:                             }
 651:                             if ($type == OPTION_TYPE_PASSWORD) {
 652:                                 $inputtype = 'password';
 653:                                 $multilingual = false;
 654:                             } else {
 655:                                 $inputtype = 'text';
 656:                             }
 657:                             ?>
 658:                             <td width="350">
 659:                                 <input type="hidden" name="<?php echo CUSTOM_OPTION_PREFIX . $clear . 'text-' . $key; ?>" value="1" />
 660:                                 <?php
 661:                                 if ($multilingual) {
 662:                                     print_language_string_list($v, $key, $type, NULL, $editor);
 663:                                 } else {
 664:                                     if ($type == OPTION_TYPE_TEXTAREA || $type == OPTION_TYPE_RICHTEXT) {
 665:                                         $v = get_language_string($v); // just in case....
 666:                                         ?>
 667:                                         <textarea id="<?php echo $key; ?>"<?php if ($type == OPTION_TYPE_RICHTEXT) echo ' class="texteditor"'; ?> name="<?php echo $key; ?>" cols="<?php echo TEXTAREA_COLUMNS; ?>" style="width: 320px" rows="6"<?php echo $disabled; ?>><?php echo html_encode($v); ?></textarea>
 668:                                         <?php
 669:                                     } else {
 670:                                         ?>
 671:                                         <input type="<?php echo $inputtype; ?>" size="40" id="<?php echo $key; ?>" name="<?php echo $key; ?>" style="width: 338px" value="<?php echo html_encode($v); ?>"<?php echo $disabled; ?> />
 672:                                         <?php
 673:                                     }
 674:                                 }
 675:                                 ?>
 676:                             </td>
 677:                             <?php
 678:                             break;
 679:                         case OPTION_TYPE_CHECKBOX:
 680:                             ?>
 681:                             <td width="350">
 682:                                 <input type="hidden" name="<?php echo CUSTOM_OPTION_PREFIX . 'chkbox-' . $key; ?>" value="1" />
 683:                                 <input type="checkbox" id="<?php echo $key; ?>" name="<?php echo $key; ?>" value="1" <?php checked('1', $v); ?><?php echo $disabled; ?> />
 684:                             </td>
 685:                             <?php
 686:                             break;
 687:                         case OPTION_TYPE_CUSTOM:
 688:                             ?>
 689:                             <td width="350">
 690:                                 <input type="hidden" name="<?php echo CUSTOM_OPTION_PREFIX . 'custom-' . $key; ?>" value="0" />
 691:                                 <?php $optionHandler->handleOption($key, $v); ?>
 692:                             </td>
 693:                             <?php
 694:                             break;
 695:                         case OPTION_TYPE_RADIO:
 696:                             $behind = (isset($row['behind']) && $row['behind']);
 697:                             ?>
 698:                             <td width="350">
 699:                                 <input type="hidden" name="<?php echo CUSTOM_OPTION_PREFIX . 'radio-' . $key; ?>" value="1"<?php echo $disabled; ?> />
 700:                                 <?php generateRadiobuttonsFromArray($v, $row['buttons'], $key, $behind, 'checkboxlabel', $disabled); ?>
 701:                             </td>
 702:                             <?php
 703:                             break;
 704:                         case OPTION_TYPE_SELECTOR:
 705:                             ?>
 706:                             <td width="350">
 707:                                 <input type="hidden" name="<?php echo CUSTOM_OPTION_PREFIX . 'selector-' . $key ?>" value="1" />
 708:                                 <select id="<?php echo $key; ?>" name="<?php echo $key; ?>"<?php echo $disabled; ?> >
 709:                                     <?php
 710:                                     if (array_key_exists('null_selection', $row)) {
 711:                                         ?>
 712:                                         <option value=""<?php if (empty($v)) echo ' selected="selected"'; ?> style="background-color:LightGray;"><?php echo $row['null_selection']; ?></option>
 713:                                         <?php
 714:                                     }
 715:                                     ?>
 716:                                     <?php generateListFromArray(array($v), $row['selections'], false, true); ?>
 717:                                 </select>
 718:                             </td>
 719:                             <?php
 720:                             break;
 721:                         case OPTION_TYPE_CHECKBOX_ARRAY:
 722:                             $behind = (isset($row['behind']) && $row['behind']);
 723:                             ?>
 724:                             <td width="350">
 725:                                 <?php
 726:                                 foreach ($row['checkboxes'] as $display => $checkbox) {
 727:                                     if ($theme) {
 728:                                         $v = getThemeOption($checkbox, $album, $theme);
 729:                                     } else {
 730:                                         $sql = "SELECT `value` FROM " . prefix('options') . " WHERE `name`=" . db_quote($checkbox);
 731:                                         $db = query_single_row($sql);
 732:                                         if ($db) {
 733:                                             $v = $db['value'];
 734:                                         } else {
 735:                                             $v = 0;
 736:                                         }
 737:                                     }
 738:                                     $display = str_replace(' ', '&nbsp;', $display);
 739:                                     ?>
 740:                                     <input type="hidden" name="<?php echo CUSTOM_OPTION_PREFIX . 'chkbox-' . $checkbox; ?>" value="1" />
 741: 
 742:                                     <label class="checkboxlabel">
 743:                                         <?php if ($behind) echo($display); ?>
 744:                                         <input type="checkbox" id="<?php echo $checkbox; ?>" name="<?php echo $checkbox; ?>" value="1"<?php checked('1', $v); ?><?php echo $disabled; ?> />
 745:                                         <?php if (!$behind) echo($display); ?>
 746:                                     </label>
 747:                                     <?php
 748:                                 }
 749:                                 ?>
 750:                             </td>
 751:                             <?php
 752:                             break;
 753:                         case OPTION_TYPE_CHECKBOX_UL:
 754:                             ?>
 755:                             <td width="350">
 756:                                 <?php
 757:                                 $all = true;
 758:                                 $cvarray = array();
 759:                                 foreach ($row['checkboxes'] as $display => $checkbox) {
 760:                                     ?>
 761:                                     <input type="hidden" name="<?php echo CUSTOM_OPTION_PREFIX . 'chkbox-' . $checkbox; ?>" value="1" />
 762:                                     <?php
 763:                                     if ($theme) {
 764:                                         $v = getThemeOption($checkbox, $album, $theme);
 765:                                     } else {
 766:                                         $sql = "SELECT `value` FROM " . prefix('options') . " WHERE `name`=" . db_quote($checkbox);
 767:                                         $db = query_single_row($sql);
 768:                                         if ($db) {
 769:                                             $v = $db['value'];
 770:                                         } else {
 771:                                             $v = 0;
 772:                                         }
 773:                                     }
 774:                                     if ($v) {
 775:                                         $cvarray[] = $checkbox;
 776:                                     } else {
 777:                                         $all = false;
 778:                                     }
 779:                                 }
 780:                                 ?>
 781:                                 <ul class="customchecklist">
 782:                                     <?php generateUnorderedListFromArray($cvarray, $row['checkboxes'], '', '', true, true, 'all_' . $key); ?>
 783:                                 </ul>
 784:                                 <script type="text/javascript">
 785:                                     // <!-- <![CDATA[
 786:                                     function <?php echo $key; ?>_all() {
 787:                                         var check = $('#all_<?php echo $key; ?>').prop('checked');
 788:                                         $('.all_<?php echo $key; ?>').prop('checked', check);
 789:                                     }
 790:                                     // ]]> -->
 791:                                 </script>
 792:                                 <label>
 793:                                     <input type="checkbox" name="all_<?php echo $key; ?>" id="all_<?php echo $key; ?>" class="all_<?php echo $key; ?>" onclick="<?php echo $key; ?>_all();" <?php if ($all) echo ' checked="checked"'; ?>/>
 794:                                     <?php echo gettext('all'); ?>
 795:                                 </label>
 796:                             </td>
 797:                             <?php
 798:                             break;
 799:                         case OPTION_TYPE_COLOR_PICKER:
 800:                             if (empty($v))
 801:                                 $v = '#000000';
 802:                             ?>
 803:                             <td width="350" style="margin:0; padding:0">
 804:                                 <input type="hidden" name="<?php echo CUSTOM_OPTION_PREFIX . 'text-' . $key; ?>" value="1" />
 805:                                 <script type="text/javascript">
 806:                                     // <!-- <![CDATA[
 807:                                     $(document).ready(function() {
 808:                                         $('#<?php echo $key; ?>_colorpicker').farbtastic('#<?php echo $key; ?>');
 809:                                     });
 810:                                     // ]]> -->
 811:                                 </script>
 812:                                 <table style="margin:0; padding:0" >
 813:                                     <tr>
 814:                                         <td><input type="text" id="<?php echo $key; ?>" name="<?php echo $key; ?>"  value="<?php echo $v; ?>" style="height:100px; width:100px; float:right;" /></td>
 815:                                         <td><div id="<?php echo $key; ?>_colorpicker"></div></td>
 816:                                     </tr>
 817:                                 </table>
 818:                             </td>
 819:                             <?php
 820:                             break;
 821:                     }
 822:                     if ($type != OPTION_TYPE_NOTE) {
 823:                         ?>
 824:                         <td><?php echo $desc; ?></td>
 825:                         <?php
 826:                     }
 827:                     ?>
 828:                 </tr>
 829:                 <?php
 830:             }
 831:         }
 832:     }
 833: 
 834:     function processCustomOptionSave($returntab, $themename = NULL, $themealbum = NULL) {
 835:   $customHandlers = array();
 836:   foreach ($_POST as $postkey => $value) {
 837:     if (preg_match('/^' . CUSTOM_OPTION_PREFIX . '/', $postkey)) { // custom option!
 838:       $key = substr($postkey, strpos($postkey, '-') + 1);
 839:       $switch = substr($postkey, strlen(CUSTOM_OPTION_PREFIX), -strlen($key) - 1);
 840:       switch ($switch) {
 841:         case 'text':
 842:           $value = process_language_string_save($key, 1);
 843:           break;
 844:         case 'cleartext':
 845:           if (isset($_POST[$key])) {
 846:             $value = sanitize($_POST[$key], 0);
 847:           } else {
 848:             $value = '';
 849:           }
 850:           break;
 851:         case 'chkbox':
 852:           $value = (int) isset($_POST[$key]);
 853:           break;
 854:         case 'save':
 855:           $customHandlers[] = array('whom' => $key, 'extension' => sanitize($_POST[$postkey]));
 856:           continue;
 857:           break;
 858:         default:
 859:           if (isset($_POST[$key])) {
 860:             $value = sanitize($_POST[$key], 1);
 861:           } else {
 862:             $value = '';
 863:           }
 864:           break;
 865:       }
 866:       if ($themename) {
 867:         setThemeOption($key, $value, $themealbum, $themename);
 868:       } else {
 869:         $creator = NULL;
 870:         if(isset($_GET['single'])) { // single plugin save
 871:           $ext = sanitize($_GET['single'],1);
 872:           $pl = getPlugin($ext . '.php',false,true);
 873:           $creator = str_replace(WEBPATH.'/','',$pl);
 874:         } 
 875:         setOption($key, $value, true, $creator);
 876:       }
 877:     } else {
 878:       if (strpos($postkey, 'show-') === 0) {
 879:         if ($value)
 880:           $returntab .= '&' . $postkey;
 881:       }
 882:     }
 883:   }
 884:   foreach ($customHandlers as $custom) {
 885:     if ($extension = $custom['extension']) {
 886:       require_once(getPlugin($extension . '.php'));
 887:     }
 888:     $whom = new $custom['whom']();
 889:     $returntab = $whom->handleOptionSave($themename, $themealbum) . $returntab;
 890:   }
 891:   return $returntab;
 892: }
 893: 
 894: /**
 895:      *
 896:      * Set defaults for standard theme options incase the theme has not done so
 897:      * @param string $theme
 898:      * @param int $albumid zero or the album "owning" the theme
 899:      */
 900:     function standardThemeOptions($theme, $album) {
 901:         setThemeOption('albums_per_page', 6, $album, $theme, true);
 902:         setThemeOption('albums_per_row', 3, $album, $theme, true);
 903:         setThemeOption('images_per_page', 20, $album, $theme, true);
 904:         setThemeOption('images_per_row', 5, $album, $theme, true);
 905:         setThemeOption('image_size', 595, $album, $theme, true);
 906:         setThemeOption('image_use_side', 'longest', $album, $theme, true);
 907:         setThemeOption('thumb_size', 100, $album, $theme, true);
 908:         setThemeOption('thumb_crop_width', 100, $album, $theme, true);
 909:         setThemeOption('thumb_crop_height', 100, $album, $theme, true);
 910:         setThemeOption('thumb_crop', 1, $album, $theme, true);
 911:         setThemeOption('thumb_transition', 1, $album, $theme, true);
 912:     }
 913: 
 914:     /**
 915:      * Encodes for use as a $_POST index
 916:      *
 917:      * @param string $str
 918:      */
 919:     function postIndexEncode($str) {
 920:         return strtr(urlencode($str), array('.' => '__2E__', '+' => '__20__', '%' => '__25__', '&' => '__26__', "'" => '__27__', '(' => '__28__', ')' => '__29__'));
 921:     }
 922: 
 923:     /**
 924:      * Decodes encoded $_POST index
 925:      *
 926:      * @param string $str
 927:      * @return string
 928:      */
 929:     function postIndexDecode($str) {
 930:         return urldecode(strtr($str, array('__2E__' => '.', '__20__' => '+', '__25__' => '%', '__26__' => '&', '__27__' => "'", '__28__' => '(', '__29__' => ')')));
 931:     }
 932: 
 933:     /**
 934:      * Prints radio buttons from an array
 935:      *
 936:      * @param string $currentvalue The current selected value
 937:      * @param string $list the array of the list items form is localtext => buttonvalue
 938:      * @param string $option the name of the option for the input field name
 939:      * @param bool $behind set true to have the "text" before the button
 940:      */
 941:     function generateRadiobuttonsFromArray($currentvalue, $list, $option, $behind = false, $class = 'checkboxlabel', $disabled = NULL) {
 942:         foreach ($list as $text => $value) {
 943:             $checked = "";
 944:             if ($value == $currentvalue) {
 945:                 $checked = ' checked="checked" '; //the checked() function uses quotes the other way round...
 946:             }
 947:             ?>
 948:             <label<?php if ($class) echo ' class="' . $class . '"'; ?>>
 949:                 <?php if ($behind) echo $text; ?>
 950:                 <input type="radio" name="<?php echo $option; ?>" id="<?php echo $option . '-' . $value; ?>" value="<?php echo $value; ?>"<?php echo $checked; ?><?php echo $disabled; ?> />
 951:                 <?php if (!$behind) echo $text; ?>
 952:             </label>
 953:             <?php
 954:         }
 955:     }
 956: 
 957:     /**
 958:      * Creates the body of an unordered list with checkbox label/input fields (scrollable sortables)
 959:      *
 960:      * @param array $currentValue list of items to be flagged as checked
 961:      * @param array $list the elements of the select list
 962:      * @param string $prefix prefix of the input item
 963:      * @param string $alterrights are the items changable.
 964:      * @param bool $sort true for sorted list
 965:      * @param string $class optional class for items
 966:      * @param bool $localize true if the list local key is text for the item
 967:      */
 968:     function generateUnorderedListFromArray($currentValue, $list, $prefix, $alterrights, $sort, $localize, $class = NULL, $extra = NULL) {
 969:         if (is_null($extra))
 970:             $extra = array();
 971:         if (!empty($class))
 972:             $class = ' class="' . $class . '" ';
 973:         if ($sort) {
 974:             if ($localize) {
 975:                 $list = array_flip($list);
 976:                 natcasesort($list);
 977:                 $list = array_flip($list);
 978:             } else {
 979:                 natcasesort($list);
 980:             }
 981:         }
 982:         $cv = array_flip($currentValue);
 983:         foreach ($list as $key => $item) {
 984:             $listitem = postIndexEncode($prefix . $item);
 985:             if ($localize) {
 986:                 $display = $key;
 987:             } else {
 988:                 $display = $item;
 989:             }
 990:             ?>
 991:             <li id="<?php echo strtolower($listitem); ?>_element">
 992:                 <label class="displayinline">
 993:                     <input id="<?php echo strtolower($listitem); ?>"<?php echo $class; ?> name="<?php echo $listitem; ?>" type="checkbox"
 994:                     <?php
 995:                     if (isset($cv[$item])) {
 996:                         echo ' checked="checked"';
 997:                     }
 998:                     ?> value="1" <?php echo $alterrights; ?> />
 999:                                  <?php echo html_encode($display); ?>
1000:                 </label>
1001:                 <?php
1002:                 if (array_key_exists($item, $extra)) {
1003:                     $unique = '';
1004:                     foreach (array_reverse($extra[$item]) as $box) {
1005:                         if ($box['display']) {
1006:                             if (isset($box['disable'])) {
1007:                                 $disable = ' disabled="disabled"';
1008:                             } else {
1009:                                 $disable = $alterrights;
1010:                             }
1011:                             if (isset($box['type'])) {
1012:                                 $type = $box['type'];
1013:                                 if ($type == 'radio')
1014:                                     $unique++;
1015:                             } else {
1016:                                 $type = 'checkbox';
1017:                             }
1018:                             ?>
1019:                             <label class="displayinlineright">
1020:                                 <input type="<?php echo $type; ?>" id="<?php echo strtolower($listitem) . '_' . $box['name'] . $unique; ?>"<?php echo $class; ?> name="<?php echo $listitem . '_' . $box['name']; ?>"
1021:                                              value="<?php echo html_encode($box['value']); ?>" <?php
1022:                                              if ($box['checked']) {
1023:                                                  echo ' checked="checked"';
1024:                                              }
1025:                                              ?>
1026:                                              <?php echo $disable; ?> /> <?php echo $box['display']; ?>
1027:                             </label>
1028:                             <?php
1029:                         } else {
1030:                             ?>
1031:                             <input type="hidden" id="<?php echo strtolower($listitem . '_' . $box['name']); ?>" name="<?php echo $listitem . '_' . $box['name']; ?>"<?php echo $class; ?>
1032:                                          value="<?php echo html_encode($box['value']); ?>" />
1033:                                          <?php
1034:                                      }
1035:                                  }
1036:                              }
1037:                              ?>
1038:             </li>
1039:             <?php
1040:         }
1041:     }
1042: 
1043:     /**
1044:      * Creates an unordered checklist of the tags
1045:      *
1046:      * @param object $that Object for which to get the tags
1047:      * @param string $postit prefix to prepend for posting
1048:      * @param bool $showCounts set to true to get tag count displayed
1049:      */
1050:     function tagSelector($that, $postit, $showCounts = false, $mostused = false, $addnew = true, $resizeable = false, $class = 'checkTagsAuto') {
1051:         global $_zp_admin_ordered_taglist, $_zp_admin_LC_taglist;
1052:         if (is_null($_zp_admin_ordered_taglist)) {
1053:             if ($mostused || $showCounts) {
1054:                 $counts = getAllTagsCount();
1055:                 if ($mostused)
1056:                     arsort($counts, SORT_NUMERIC);
1057:                 $them = array();
1058:                 foreach ($counts as $tag => $count) {
1059:                     $them[] = $tag;
1060:                 }
1061:             } else {
1062:                 $them = getAllTagsUnique();
1063:             }
1064:             $_zp_admin_ordered_taglist = $them;
1065:             $_zp_admin_LC_taglist = array();
1066:             foreach ($them as $tag) {
1067:                 $_zp_admin_LC_taglist[] = mb_strtolower($tag);
1068:             }
1069:         } else {
1070:             $them = $_zp_admin_ordered_taglist;
1071:         }
1072:         if (is_null($that)) {
1073:             $tags = array();
1074:         } else {
1075:             $tags = $that->getTags();
1076:         }
1077: 
1078:         if (count($tags) > 0) {
1079:             foreach ($tags as $tag) {
1080:                 $tagLC = mb_strtolower($tag);
1081:                 $key = array_search($tagLC, $_zp_admin_LC_taglist);
1082:                 if ($key !== false) {
1083:                     unset($them[$key]);
1084:                 }
1085:             }
1086:         }
1087:         if ($resizeable) {
1088:             $tagclass = 'resizeable_tagchecklist';
1089:             ?>
1090:             <script>
1091:                 $(function() {
1092:                     $("#resizable_<?php echo $postit; ?>").resizable({
1093:         <?php
1094:         if (is_bool($resizeable)) {
1095:             ?>
1096:                         maxWidth: 250,
1097:             <?php
1098:         }
1099:         ?>
1100:                     minWidth: 250,
1101:                                     minHeight: 120,
1102:                                     resize: function(event, ui) {
1103:                                     $('#list_<?php echo $postit; ?>').height($('#resizable_<?php echo $postit; ?>').height());
1104:                                     }
1105:                 });
1106:                 });</script>
1107:             <?php
1108:         } else {
1109:             $tagclass = 'tagchecklist';
1110:         }
1111:         if ($addnew) {
1112:             ?>
1113:             <span class="new_tag displayinline" >
1114:                 <a href="javascript:addNewTag('<?php echo $postit; ?>');" title="<?php echo gettext('add tag'); ?>">
1115:                     <img src="images/add.png" title="<?php echo gettext('add tag'); ?>"/>
1116:                 </a>
1117:                 <span class="tagSuggestContainer">
1118:                     <input class="tagsuggest <?php echo $class; ?> " type="text" value="" name="newtag_<?php echo $postit; ?>" id="newtag_<?php echo $postit; ?>" />
1119:                 </span>
1120:             </span>
1121: 
1122:             <?php
1123:         }
1124:         ?>
1125:         <div id="resizable_<?php echo $postit; ?>" class="tag_div">
1126:             <ul id="list_<?php echo $postit; ?>" class="<?php echo $tagclass; ?>">
1127:                 <?php
1128:                 if ($showCounts) {
1129:                     $displaylist = array();
1130:                     foreach ($them as $tag) {
1131:                         $displaylist[$tag . ' [' . $counts[$tag] . ']'] = $tag;
1132:                     }
1133:                 } else {
1134:                     $displaylist = $them;
1135:                 }
1136:                 if (count($tags) > 0) {
1137:                     generateUnorderedListFromArray($tags, $tags, $postit, false, !$mostused, $showCounts, $class);
1138:                     ?>
1139:                     <li><hr /></li>
1140:                     <?php
1141:                 }
1142:                 generateUnorderedListFromArray(array(), $displaylist, $postit, false, !$mostused, $showCounts, $class);
1143:                 ?>
1144:             </ul>
1145:         </div>
1146:         <?php
1147:     }
1148: 
1149:     /**
1150:      * emits the html for editing album information
1151:      * called in edit album and mass edit
1152:      * @param string $index the index of the entry in mass edit or '0' if single album
1153:      * @param object $album the album object
1154:      * @param bool $buttons set true for "apply" buttons
1155:      * @since 1.1.3
1156:      */
1157:     function printAlbumEditForm($index, $album, $buttons = true) {
1158:         global $_zp_sortby, $_zp_gallery, $mcr_albumlist, $_zp_albumthumb_selector, $_zp_current_admin_obj;
1159:         $isPrimaryAlbum = '';
1160:         if (!zp_loggedin(MANAGE_ALL_ALBUM_RIGHTS)) {
1161:             $myalbum = $_zp_current_admin_obj->getAlbum();
1162:             if ($myalbum && $album->getID() == $myalbum->getID()) {
1163:                 $isPrimaryAlbum = ' disabled="disabled"';
1164:             }
1165:         }
1166:         $tagsort = getTagOrder();
1167:         if ($index == 0) {
1168:             $suffix = $prefix = '';
1169:         } else {
1170:             $prefix = "$index-";
1171:             $suffix = "_$index";
1172:             echo "<p><em><strong>" . $album->name . "</strong></em></p>";
1173:         }
1174:         ?>
1175:         <input type="hidden" name="<?php echo $prefix; ?>folder" value="<?php echo $album->name; ?>" />
1176:         <input type="hidden" name="tagsort" value="<?php echo html_encode($tagsort); ?>" />
1177:         <input  type="hidden" name="password_enabled<?php echo $suffix; ?>" id="password_enabled<?php echo $suffix; ?>" value="0" />
1178:         <?php
1179:         if ($buttons) {
1180:             ?>
1181:             <span class="buttons">
1182:                 <?php
1183:                 $parent = dirname($album->name);
1184:                 if ($parent == '/' || $parent == '.' || empty($parent)) {
1185:                     $parent = '';
1186:                 } else {
1187:                     $parent = '&amp;album=' . $parent . '&tab=subalbuminfo';
1188:                 }
1189:                 ?>
1190:                 <a href="<?php echo WEBPATH . '/' . ZENFOLDER . '/admin-edit.php?page=edit' . $parent; ?>">
1191:                     <img    src="images/arrow_left_blue_round.png" alt="" />
1192:                     <strong><?php echo gettext("Back"); ?></strong>
1193:                 </a>
1194:                 <button type="submit">
1195:                     <img    src="images/pass.png" alt="" />
1196:                     <strong><?php echo gettext("Apply"); ?></strong>
1197:                 </button>
1198:                 <button type="reset" onclick="javascript:$('.deletemsg').hide();" >
1199:                     <img    src="images/fail.png" alt="" />
1200:                     <strong><?php echo gettext("Reset"); ?></strong>
1201:                 </button>
1202:                 <div class="floatright">
1203:                     <?php
1204:                     if (!$album->isDynamic()) {
1205:                         ?>
1206:                         <button type="button" title="<?php echo addslashes(gettext('New subalbum')); ?>" onclick="javascript:newAlbum('<?php echo pathurlencode($album->name); ?>', true);">
1207:                             <img src="images/folder.png" alt="" />
1208:                             <strong><?php echo gettext('New subalbum'); ?></strong>
1209:                         </button>
1210:       <?php if(!$album->isDynamic()) { ?>
1211:          <button type="button" title="<?php echo addslashes(gettext('New dynamic subalbum')); ?>" onclick="javascript:newDynAlbum('<?php echo pathurlencode($album->name); ?>', false);">
1212:            <img src="images/folder.png" alt="" />
1213:                                             <strong><?php echo gettext('New dynamic subalbum'); ?></strong>
1214:                                  </button>
1215:        <?php 
1216:       } 
1217:                     }
1218:                     ?>
1219:                     <a href="<?php echo WEBPATH . "/index.php?album=" . html_encode(pathurlencode($album->getFileName())); ?>">
1220:                         <img src="images/view.png" alt="" />
1221:                         <strong><?php echo gettext('View Album'); ?></strong>
1222:                     </a>
1223:                 </div>
1224:             </span>
1225:             <?php
1226:         }
1227:         ?>
1228:         <br class="clearall" /><br />
1229:         <table class="formlayout">
1230:             <tr>
1231:                 <td valign="top">
1232:                     <table class="width100percent">
1233:                         <tr>
1234:                             <td class="leftcolumn"><?php echo gettext("Owner"); ?></td>
1235:                             <td class="middlecolumn">
1236:                                 <?php
1237:                                 if (zp_loggedin(MANAGE_ALL_ALBUM_RIGHTS)) {
1238:                                     ?>
1239:                                     <select name="<?php echo $prefix; ?>owner">
1240:                                         <?php echo admin_album_list($album->getOwner()); ?>
1241:                                     </select>
1242:                                     <?php
1243:                                 } else {
1244:                                     echo $album->getOwner();
1245:                                 }
1246:                                 ?>
1247:                             </td>
1248:                         </tr>
1249:                         <tr>
1250:                             <td class="leftcolumn">
1251:                                 <?php echo gettext("Album Title"); ?>:
1252:                             </td>
1253:                             <td class="middlecolumn">
1254:                                 <?php print_language_string_list($album->getTitle('all'), $prefix . "albumtitle", false, null, '', '100%'); ?>
1255:                             </td>
1256:                         </tr>
1257: 
1258:                         <tr>
1259:                             <td class="leftcolumn">
1260:                                 <?php echo gettext("Album Description:"); ?>
1261:                             </td>
1262:                             <td>
1263:                                 <?php print_language_string_list($album->getDesc('all'), $prefix . "albumdesc", true, NULL, 'texteditor', '100%'); ?>
1264:                             </td>
1265:                         </tr>
1266:                         <?php
1267:                         if (GALLERY_SECURITY == 'public') {
1268:                             ?>
1269:                             <tr class="password<?php echo $suffix; ?>extrashow">
1270:                                 <td class="leftcolumn">
1271:                                     <p>
1272:                                         <a href="javascript:toggle_passwords('<?php echo $suffix; ?>',true);">
1273:                                             <?php echo gettext("Album password:"); ?>
1274:                                         </a>
1275:                                     </p>
1276:                                 </td>
1277:                                 <td class="middlecolumn">
1278:                                     <p>
1279:                                     <?php
1280:                                     $x = $album->getPassword();
1281:                                     if (empty($x)) {
1282:                                         ?>
1283:                                         <img src="images/lock_open.png" />
1284:                                         <?php
1285:                                     } else {
1286:                                         $x = '          ';
1287:                                         ?>
1288:                                         <a onclick="resetPass('<?php echo $suffix; ?>');" title="<?php echo addslashes(gettext('clear password')); ?>"><img src="images/lock.png" /></a>
1289:                                         <?php
1290:                                     }
1291:                                     ?>
1292:                                     </p>
1293:                                 </td>
1294:                             </tr>
1295:                             <tr class="password<?php echo $suffix; ?>extrahide" style="display:none" >
1296:                                 <td class="leftcolumn">
1297:                                     <p>
1298:                                         <a href="javascript:toggle_passwords('<?php echo $suffix; ?>',false);">
1299:                                             <?php echo gettext("Album guest user:"); ?>
1300:                                         </a>
1301:                                     </p>
1302:                                 </td>
1303:                                 <td>
1304:                                     <p>
1305:                                         <input type="text" size="<?php echo TEXT_INPUT_SIZE; ?>"
1306:                                                  onkeydown="passwordClear('<?php echo $suffix; ?>');"
1307:                                                  id="user_name<?php echo $suffix; ?>" name="user<?php echo $suffix; ?>"
1308:                                                  value="<?php echo $album->getUser(); ?>" />
1309:                                     </p>
1310:                                 </td>
1311:                             </tr>
1312:                             <tr class="password<?php echo $suffix; ?>extrahide" style="display:none" >
1313:                                 <td class="leftcolumn">
1314:                                     <p>
1315:                                         <span id="strength<?php echo $suffix; ?>"><?php echo gettext("Album password:"); ?></span>
1316:                                     </p>
1317:                                     <p>
1318:                                         <span id="match<?php echo $suffix; ?>" class="password_field_<?php echo $suffix; ?>">
1319:                                             <?php echo gettext("Repeat password:"); ?>
1320:                                         </span>
1321:                                     </p>
1322:                                 </td>
1323:                                 <td>
1324:                                     <p> <?php
1325:                                         // Autofill honeypot hack (hidden password input),
1326:                                         // needed to prevent "Are you sure?" from tiggering when autofill is enabled in browsers
1327:                                         // http://benjaminjshore.info/2014/05/chrome-auto-fill-honey-pot-hack.html
1328:                                         ?>
1329:                                         <input class="dirtyignore" type="password" name="pass" style="display:none;" />
1330:                                         <input type="password"
1331:                                                      id="pass<?php echo $suffix; ?>" name="pass<?php echo $suffix; ?>"
1332:                                                      onkeydown="passwordClearZ('<?php echo $suffix; ?>');"
1333:                                                      onkeyup="passwordStrength('<?php echo $suffix; ?>');"
1334:                                                      value="<?php echo $x; ?>" />
1335:                                         <label><input class="dirtyignore" type="checkbox" name="disclose_password<?php echo $suffix; ?>"
1336:                                                                 id="disclose_password<?php echo $suffix; ?>"
1337:                                                                 onclick="passwordClear('<?php echo $suffix; ?>');
1338:                                                                         togglePassword('<?php echo $suffix; ?>');" /><?php echo addslashes(gettext('Show password')); ?></label>
1339:                                         <br />
1340:                                         <span class="password_field_<?php echo $suffix; ?>">
1341:                                             <input class="dirtyignore" type="password"
1342:                                                          id="pass_r<?php echo $suffix; ?>" name="pass_r<?php echo $suffix; ?>" disabled="disabled"
1343:                                                          onkeydown="passwordClear('<?php echo $suffix; ?>');"
1344:                                                          onkeyup="passwordMatch('<?php echo $suffix; ?>');"
1345:                                                          value="<?php echo $x; ?>" />
1346:                                         </span>
1347:                                     </p>
1348:                                 </td>
1349:                             </tr>
1350:                             <tr class="password<?php echo $suffix; ?>extrahide" style="display:none" >
1351:                                 <td>
1352:                                     <p>
1353:                                         <?php echo gettext("Password hint:"); ?>
1354:                                     </p>
1355:                                 </td>
1356:                                 <td>
1357:                                     <p>
1358:                                         <?php print_language_string_list($album->getPasswordHint('all'), "hint" . $suffix, false, NULL, 'hint', '100%'); ?>
1359:                                     </p>
1360:                                 </td>
1361:                             </tr>
1362:                             <?php
1363:                         }
1364:                         $d = $album->getDateTime();
1365:                         if ($d == "0000-00-00 00:00:00") {
1366:                             $d = "";
1367:                         }
1368:                         ?>
1369: 
1370:                         <tr>
1371:                             <td class="leftcolumn"><?php echo gettext("Date:"); ?> </td>
1372:                             <td>
1373:                                 <script type="text/javascript">
1374:                                     // <!-- <![CDATA[
1375:                                     $(function() {
1376:                                         $("#datepicker<?php echo $suffix; ?>").datepicker({
1377:                                             dateFormat: 'yy-mm-dd',
1378:                                             showOn: 'button',
1379:                                             buttonImage: 'images/calendar.png',
1380:                                             buttonText: '<?php echo addslashes(gettext('calendar')); ?>',
1381:                                             buttonImageOnly: true
1382:                                         });
1383:                                     });
1384:                                     // ]]> -->
1385:                                 </script>
1386:                                 <input type="text" id="datepicker<?php echo $suffix; ?>" size="20" name="<?php echo $prefix; ?>albumdate" value="<?php echo $d; ?>" />
1387:                             </td>
1388:                         </tr>
1389:                         <tr>
1390:                             <td class="leftcolumn"><?php echo gettext("Location:"); ?> </td>
1391:                             <td class="middlecolumn">
1392:                                 <?php print_language_string_list($album->getLocation(), $prefix . "albumlocation", false, NULL, 'hint', '100%'); ?>
1393:                             </td>
1394:                         </tr>
1395:                         <?php
1396:                         $custom = zp_apply_filter('edit_album_custom_data', '', $album, $prefix);
1397:                         if (empty($custom)) {
1398:                             ?>
1399:                             <tr>
1400:                                 <td class="leftcolumn"><?php echo gettext("Custom data:"); ?></td>
1401:                                 <td><?php print_language_string_list($album->getCustomData('all'), $prefix . "album_custom_data", true, NULL, 'texteditor_albumcustomdata', '100%'); ?></td>
1402:                             </tr>
1403:                             <?php
1404:                         } else {
1405:                             echo $custom;
1406:                         }
1407:                         $sort = $_zp_sortby;
1408:                         if (!$album->isDynamic()) {
1409:                             $sort[gettext('Manual')] = 'manual';
1410:                         }
1411:                         $sort[gettext('Custom')] = 'custom';
1412:                         /*
1413:                          * not recommended--screws with peoples minds during pagination!
1414:                             $sort[gettext('Random')] = 'random';
1415:                          */
1416:                         ?>
1417:                         <tr>
1418:                             <td class="leftcolumn"><?php echo gettext("Sort subalbums by:"); ?> </td>
1419:                             <td>
1420:                                 <span class="nowrap">
1421:                                     <select id="albumsortselect<?php echo $prefix; ?>" name="<?php echo $prefix; ?>subalbumsortby" onchange="update_direction(this, 'album_direction_div<?php echo $suffix; ?>', 'album_custom_div<?php echo $suffix; ?>');">
1422:                                         <?php
1423:                                         if (is_null($album->getParent())) {
1424:                                             $globalsort = gettext("*gallery album sort order");
1425:                                         } else {
1426:                                             $globalsort = gettext("*parent album subalbum sort order");
1427:                                         }
1428:                                         echo "\n<option value =''>$globalsort</option>";
1429:                                         $cvt = $type = strtolower($album->get('subalbum_sort_type'));
1430:                                         if ($type && !in_array($type, $sort)) {
1431:                                             $cv = array('custom');
1432:                                         } else {
1433:                                             $cv = array($type);
1434:                                         }
1435:                                         generateListFromArray($cv, $sort, false, true);
1436:                                         ?>
1437:                                     </select>
1438:                                     <?php
1439:                                     if (($type == 'manual') || ($type == 'random') || ($type == '')) {
1440:                                         $dsp = 'none';
1441:                                     } else {
1442:                                         $dsp = 'inline';
1443:                                     }
1444:                                     ?>
1445:                                     <label id="album_direction_div<?php echo $suffix; ?>" style="display:<?php echo $dsp; ?>;white-space:nowrap;">
1446:                                         <?php echo gettext("Descending"); ?>
1447:                                         <input type="checkbox" name="<?php echo $prefix; ?>album_sortdirection" value="1" <?php
1448:                                         if ($album->getSortDirection('album')) {
1449:                                             echo "CHECKED";
1450:                                         };
1451:                                         ?> />
1452:                                     </label>
1453:                                 </span>
1454:                                 <?php
1455:                                 $flip = array_flip($sort);
1456:                                 if (empty($type) || isset($flip[$type])) {
1457:                                     $dsp = 'none';
1458:                                 } else {
1459:                                     $dsp = 'block';
1460:                                 }
1461:                                 ?>
1462:                                 <span id="album_custom_div<?php echo $suffix; ?>" class="customText" style="display:<?php echo $dsp; ?>;white-space:nowrap;">
1463:                                     <br />
1464:                                     <?php echo gettext('custom fields:') ?>
1465:                                     <span class="tagSuggestContainer">
1466:                                         <input id="customalbumsort<?php echo $suffix; ?>" class="customalbumsort" name="<?php echo $prefix; ?>customalbumsort" type="text" value="<?php echo html_encode($cvt); ?>" />
1467:                                     </span>
1468:                                 </span>
1469:                             </td>
1470:                         </tr>
1471: 
1472:                         <tr>
1473:                             <td class="leftcolumn"><?php echo gettext("Sort images by"); ?> </td>
1474:                             <td>
1475:                                 <span class="nowrap">
1476:                                     <select id="imagesortselect<?php echo $prefix; ?>" name="<?php echo $prefix; ?>sortby" onchange="update_direction(this, 'image_direction_div<?php echo $suffix; ?>', 'image_custom_div<?php echo $suffix; ?>')">
1477:                                         <?php
1478:                                         if (is_null($album->getParent())) {
1479:                                             $globalsort = gettext("*gallery image sort order");
1480:                                         } else {
1481:                                             $globalsort = gettext("*parent album image sort order");
1482:                                         }
1483:                                         ?>
1484:                                         <option value =""><?php echo $globalsort; ?></option>
1485:                                         <?php
1486:                                         $cvt = $type = strtolower($album->get('sort_type'));
1487:                                         if ($type && !in_array($type, $sort)) {
1488:                                             $cv = array('custom');
1489:                                         } else {
1490:                                             $cv = array($type);
1491:                                         }
1492:                                         generateListFromArray($cv, $sort, false, true);
1493:                                         ?>
1494:                                     </select>
1495:                                     <?php
1496:                                     if (($type == 'manual') || ($type == 'random') || ($type == '')) {
1497:                                         $dsp = 'none';
1498:                                     } else {
1499:                                         $dsp = 'inline';
1500:                                     }
1501:                                     ?>
1502:                                     <label id="image_direction_div<?php echo $suffix; ?>" style="display:<?php echo $dsp; ?>;white-space:nowrap;">
1503:                                         <?php echo gettext("Descending"); ?>
1504:                                         <input type="checkbox" name="<?php echo $prefix; ?>image_sortdirection" value="1"
1505:                                         <?php
1506:                                         if ($album->getSortDirection('image')) {
1507:                                             echo ' checked="checked"';
1508:                                         }
1509:                                         ?> />
1510:                                     </label>
1511:                                 </span>
1512:                                 <?php
1513:                                 $flip = array_flip($sort);
1514:                                 if (empty($type) || isset($flip[$type])) {
1515:                                     $dsp = 'none';
1516:                                 } else {
1517:                                     $dsp = 'block';
1518:                                 }
1519:                                 ?>
1520:                                 <span id="image_custom_div<?php echo $suffix; ?>" class="customText" style="display:<?php echo $dsp; ?>;white-space:nowrap;">
1521:                                     <br />
1522:                                     <?php echo gettext('custom fields:') ?>
1523:                                     <span class="tagSuggestContainer">
1524:                                         <input id="customimagesort<?php echo $suffix; ?>" class="customimagesort" name="<?php echo $prefix; ?>customimagesort" type="text" value="<?php echo html_encode($cvt); ?>" />
1525:                                     </span>
1526:                                 </span>
1527:                             </td>
1528:                         </tr>
1529: 
1530:                         <?php
1531:                         if (is_null($album->getParent())) {
1532:                             ?>
1533:                             <tr>
1534:                                 <td class="leftcolumn"><?php echo gettext("Album theme:"); ?> </td>
1535:                                 <td>
1536:                                     <select id="album_theme" class="album_theme" name="<?php echo $prefix; ?>album_theme"   <?php if (!zp_loggedin(THEMES_RIGHTS)) echo 'disabled="disabled" '; ?>  >
1537:                                         <?php
1538:                                         $themes = $_zp_gallery->getThemes();
1539:                                         $oldtheme = $album->getAlbumTheme();
1540:                                         if (empty($oldtheme)) {
1541:                                             $selected = 'selected="selected"';
1542:                                         } else {
1543:                                             $selected = '';
1544:                                         }
1545:                                         ?>
1546:                                         <option value="" style="background-color:LightGray" <?php echo $selected; ?> ><?php echo gettext('*gallery theme'); ?></option>
1547:                                         <?php
1548:                                         foreach ($themes as $theme => $themeinfo) {
1549:                                             if ($oldtheme == $theme) {
1550:                                                 $selected = 'selected="selected"';
1551:                                             } else {
1552:                                                 $selected = '';
1553:                                             }
1554:                                             ?>
1555:                                             <option value = "<?php echo $theme; ?>" <?php echo $selected; ?> ><?php echo $themeinfo['name']; ?></option>
1556:                                             <?php
1557:                                         }
1558:                                         ?>
1559:                                     </select>
1560:                                 </td>
1561:                             </tr>
1562:                             <?php
1563:                         }
1564:                         if (!$album->isDynamic()) {
1565:                             ?>
1566:                             <tr>
1567:                                 <td class="leftcolumn"><?php echo gettext("Album watermarks:"); ?> </td>
1568:                                 <td>
1569:                                     <?php $current = $album->getWatermark(); ?>
1570:                                     <select id="album_watermark<?php echo $suffix; ?>" name="<?php echo $prefix; ?>album_watermark">
1571:                                         <option value="<?php echo NO_WATERMARK; ?>" <?php if ($current == NO_WATERMARK) echo ' selected="selected"' ?> style="background-color:LightGray"><?php echo gettext('*no watermark'); ?></option>
1572:                                         <option value="" <?php if (empty($current)) echo ' selected="selected"' ?> style="background-color:LightGray"><?php echo gettext('*default'); ?></option>
1573:                                         <?php
1574:                                         $watermarks = getWatermarks();
1575:                                         generateListFromArray(array($current), $watermarks, false, false);
1576:                                         ?>
1577:                                     </select>
1578:                                     <em><?php echo gettext('Images'); ?></em>
1579:                                 </td>
1580:                             </tr>
1581:                             <tr>
1582:                                 <td class="leftcolumn"></td>
1583:                                 <td>
1584:                                     <?php $current = $album->getWatermarkThumb(); ?>
1585:                                     <select id="album_watermark_thumb<?php echo $suffix; ?>" name="<?php echo $prefix; ?>album_watermark_thumb">
1586:                                         <option value="<?php echo NO_WATERMARK; ?>" <?php if ($current == NO_WATERMARK) echo ' selected="selected"' ?> style="background-color:LightGray"><?php echo gettext('*no watermark'); ?></option>
1587:                                         <option value="" <?php if (empty($current)) echo ' selected="selected"' ?> style="background-color:LightGray"><?php echo gettext('*default'); ?></option>
1588:                                         <?php
1589:                                         $watermarks = getWatermarks();
1590:                                         generateListFromArray(array($current), $watermarks, false, false);
1591:                                         ?>
1592:                                     </select>
1593:                                     <em><?php echo gettext('Thumbs'); ?></em>
1594:                                 </td>
1595:                             </tr>
1596:                             <?php
1597:                         }
1598:                         if ($index == 0) { // suppress for mass-edit
1599:                             $showThumb = $_zp_gallery->getThumbSelectImages();
1600:                             $album->getAlbumThumbImage(); //    prime the thumbnail since we will get the field below
1601:                             $thumb = $album->get('thumb');
1602:                             $selections = array();
1603:                             $selected = array();
1604:                             foreach ($_zp_albumthumb_selector as $key => $selection) {
1605:                                 $selections[$selection['desc']] = $key;
1606:                                 if ($key == $thumb) {
1607:                                     $selected[] = $key;
1608:                                 }
1609:                             }
1610:                             ?>
1611:                             <tr>
1612:                                 <td class="leftcolumn"><?php echo gettext("Thumbnail:"); ?> </td>
1613:                                 <td>
1614:                                     <?php
1615:                                     if ($showThumb) {
1616:                                         ?>
1617:                                         <script type="text/javascript">
1618:                                             // <!-- <![CDATA[
1619:                                             updateThumbPreview(document.getElementById('thumbselect'));
1620:                                             // ]]> -->
1621:                                         </script>
1622:                                         <?php
1623:                                     }
1624:                                     ?>
1625:                                     <select style="width:320px" <?php if ($showThumb) { ?>class="thumbselect" onchange="updateThumbPreview(this);" <?php } ?> name="<?php echo $prefix; ?>thumb">
1626:                                         <?php
1627:                                         generateListFromArray($selected, $selections, false, true);
1628:                                         $imagelist = $album->getImages(0);
1629:                                         $subalbums = $album->getAlbums(0);
1630:                                         foreach ($subalbums as $folder) {
1631:                                             $newalbum = newAlbum($folder);
1632:                                             if ($_zp_gallery->getSecondLevelThumbs()) {
1633:                                                 $images = $newalbum->getImages(0);
1634:                                                 foreach ($images as $filename) {
1635:                                                     if (is_array($filename)) {
1636:                                                         $imagelist[] = $filename;
1637:                                                     } else {
1638:                                                         $imagelist[] = '/' . $folder . '/' . $filename;
1639:                                                     }
1640:                                                 }
1641:                                             } else {
1642:                                                 $t = $newalbum->getAlbumThumbImage();
1643:                                                 if (strtolower(get_class($t)) !== 'transientimage' && $t->exists) {
1644:                                                     $imagelist[] = '/' . $t->getAlbumName() . '/' . $t->filename;
1645:                                                 }
1646:                                             }
1647:                                         }
1648: 
1649:                                         if ($thumb && !is_numeric($thumb)) {
1650:                                             // check for current thumb being in the list. If not, add it
1651:                                             $target = $thumb;
1652:                                             $targetA = array('folder' => dirname($thumb), 'filename' => basename($thumb));
1653:                                             if (!in_array($target, $imagelist) && !in_array($targetA, $imagelist)) {
1654:                                                 array_unshift($imagelist, $target);
1655:                                             }
1656:                                         }
1657:                                         if (!empty($imagelist)) {
1658:                                             // there are some images to choose from
1659:                                             foreach ($imagelist as $imagename) {
1660:                                                 if (is_array($imagename)) {
1661:                                                     $image = newImage(NULL, $imagename);
1662:                                                     $imagename = '/' . $imagename['folder'] . '/' . $imagename['filename'];
1663:                                                     $filename = basename($imagename);
1664:                                                 } else {
1665:                                                     $albumname = trim(dirname($imagename), '/');
1666:                                                     if (empty($albumname) || $albumname == '.') {
1667:                                                         $thumbalbum = $album;
1668:                                                     } else {
1669:                                                         $thumbalbum = newAlbum($albumname);
1670:                                                     }
1671:                                                     $filename = basename($imagename);
1672:                                                     $image = newImage($thumbalbum, $filename);
1673:                                                 }
1674:                                                 $selected = ($imagename == $thumb);
1675:                                                 if (Gallery::validImage($filename) || !is_null($image->objectsThumb)) {
1676:                                                     echo "\n<option";
1677:                                                     if ($_zp_gallery->getThumbSelectImages()) {
1678:                                                         echo " class=\"thumboption\"";
1679:                                                         echo " style=\"background-image: url(" . html_encode(pathurlencode(getAdminThumb($image, 'large'))) . "); background-repeat: no-repeat;\"";
1680:                                                     }
1681:                                                     echo " value=\"" . $imagename . "\"";
1682:                                                     if ($selected) {
1683:                                                         echo " selected=\"selected\"";
1684:                                                     }
1685:                                                     echo ">" . $image->getTitle();
1686:                                                     if ($filename != $image->getTitle()) {
1687:                                                         echo " ($filename)";
1688:                                                     }
1689:                                                     echo "</option>";
1690:                                                 }
1691:                                             }
1692:                                         }
1693:                                         ?>
1694:                                     </select>
1695:                                 </td>
1696:                             </tr>
1697:                             <?php
1698:                         }
1699:                         ?>
1700:                         <tr valign="top">
1701:                             <td class="leftcolumn topalign-nopadding"><br /><?php echo gettext("Codeblocks:"); ?></td>
1702:                             <td>
1703:                                 <br />
1704:                                 <?php printCodeblockEdit($album, (int) $suffix); ?>
1705:                             </td>
1706:                         </tr>
1707:                     </table>
1708:                 </td>
1709:                 <?php $bglevels = array('#fff', '#f8f8f8', '#efefef', '#e8e8e8', '#dfdfdf', '#d8d8d8', '#cfcfcf', '#c8c8c8'); ?>
1710:                 <td class="rightcolumn" valign="top">
1711:                     <h2 class="h2_bordered_edit"><?php echo gettext("General"); ?></h2>
1712:                     <div class="box-edit">
1713:                         <label class="checkboxlabel">
1714:                             <input type="checkbox" name="<?php echo $prefix; ?>Published" value="1" <?php if ($album->getShow()) echo ' checked="checked"'; ?> />
1715:                             <?php echo gettext("Published"); ?>
1716:                         </label>
1717:                         <label class="checkboxlabel">
1718:                             <input type="checkbox" name="<?php echo $prefix . 'allowcomments'; ?>" value="1" <?php
1719:                             if ($album->getCommentsAllowed()) {
1720:                                 echo ' checked="checked"';
1721:                             }
1722:                             ?> />
1723:                                          <?php echo gettext("Allow Comments"); ?>
1724:                         </label>
1725:                         <?php
1726:                         if (extensionEnabled('hitcounter')) {
1727:                             $hc = $album->get('hitcounter');
1728:                             if (empty($hc)) {
1729:                                 $hc = '0';
1730:                             }
1731:                             ?>
1732:                             <label class="checkboxlabel">
1733:                                 <input type="checkbox" name="reset_hitcounter<?php echo $prefix; ?>"<?php if (!$hc) echo ' disabled="disabled"'; ?> />
1734:                                 <?php echo sprintf(ngettext("Reset hit counter (%u hit)", "Reset hit counter (%u hits)", $hc), $hc); ?>
1735:                             </label>
1736:                             <?php
1737:                         }
1738:                         if (extensionEnabled('rating')) {
1739:                             $tv = $album->get('total_value');
1740:                             $tc = $album->get('total_votes');
1741: 
1742:                             if ($tc > 0) {
1743:                                 $hc = $tv / $tc;
1744:                                 ?>
1745:                                 <label class="checkboxlabel">
1746:                                     <input type="checkbox" id="reset_rating<?php echo $suffix; ?>" name="<?php echo $prefix; ?>reset_rating" value="1" />
1747:                                     <?php printf(gettext('Reset rating (%u stars)'), $hc); ?>
1748:                                 </label>
1749:                                 <?php
1750:                             } else {
1751:                                 ?>
1752:                                 <label class="checkboxlabel">
1753:                                     <input type="checkbox" name="<?php echo $prefix; ?>reset_rating" value="1" disabled="disabled"/>
1754:                                     <?php echo gettext('Reset rating (unrated)'); ?>
1755:                                 </label>
1756:                                 <?php
1757:                             }
1758:                         }
1759:                         $publishdate = $album->getPublishDate();
1760:                         $expirationdate = $album->getExpireDate();
1761:                         ?>
1762:                         <script type="text/javascript">
1763:                             // <!-- <![CDATA[
1764:                             $(function() {
1765:                                 $("#<?php echo $prefix; ?>publishdate,#<?php echo $prefix; ?>expirationdate").datepicker({
1766:                                     dateFormat: 'yy-mm-dd',
1767:                                     showOn: 'button',
1768:                                     buttonImage: '../zp-core/images/calendar.png',
1769:                                     buttonText: '<?php echo addslashes(gettext("calendar")); ?>',
1770:                                     buttonImageOnly: true
1771:                                 });
1772:                                 $('#<?php echo $prefix; ?>publishdate').change(function() {
1773:                                     var today = new Date();
1774:                                     var pub = $('#<?php echo $prefix; ?>publishdate').datepicker('getDate');
1775:                                     if (pub.getTime() > today.getTime()) {
1776:                                         $(".<?php echo $prefix; ?>scheduledpublishing").html('<br /><?php echo addslashes(gettext('Future publishing date.')); ?>');
1777:                                     } else {
1778:                                         $(".<?php echo $prefix; ?>scheduledpublishing").html('');
1779:                                     }
1780:                                 });
1781:                                 $('#<?php echo $prefix; ?>expirationdate').change(function() {
1782:                                     var today = new Date();
1783:                                     var expiry = $('#<?php echo $prefix; ?>expirationdate').datepicker('getDate');
1784:                                     if (expiry.getTime() > today.getTime()) {
1785:                                         $(".<?php echo $prefix; ?>expire").html('');
1786:                                     } else {
1787:                                         $(".<?php echo $prefix; ?>expire").html('<br /><?php echo addslashes(gettext('Expired!')); ?>');
1788:                                     }
1789:                                 });
1790:                             });
1791:                             // ]]> -->
1792:                         </script>
1793:                         <br class="clearall" />
1794:                         <hr />
1795:                         <p>
1796:                             <label for="<?php echo $prefix; ?>publishdate"><?php echo gettext('Publish date'); ?> <small>(YYYY-MM-DD)</small></label>
1797:                             <br /><input value="<?php echo $publishdate; ?>" type="text" size="20" maxlength="30" name="publishdate-<?php echo $prefix; ?>" id="<?php echo $prefix; ?>publishdate" />
1798:                             <strong class="scheduledpublishing-<?php echo $prefix; ?>" style="color:red">
1799:                                 <?php
1800:                                 if (!empty($publishdate) && ($publishdate > date('Y-m-d H:i:s'))) {
1801:                                     echo '<br />' . gettext('Future publishing date.');
1802:                                 }
1803:                                 ?>
1804:                             </strong>
1805:                             <br /><br />
1806:                             <label for="<?php echo $prefix; ?>expirationdate"><?php echo gettext('Expiration date'); ?> <small>(YYYY-MM-DD)</small></label>
1807:                             <br /><input value="<?php echo $expirationdate; ?>" type="text" size="20" maxlength="30" name="expirationdate-<?php echo $prefix; ?>" id="<?php echo $prefix; ?>expirationdate" />
1808:                             <strong class="<?php echo $prefix; ?>expire" style="color:red">
1809:                                 <?php
1810:                                 if (!empty($expirationdate) && ($expirationdate <= date('Y-m-d H:i:s'))) {
1811:                                     echo '<br />' . gettext('Expired!');
1812:                                 }
1813:                                 ?>
1814:                             </strong>
1815:                         </p>
1816:                     </div>
1817:                     <!-- **************** Move/Copy/Rename ****************** -->
1818:                     <h2 class="h2_bordered_edit"><?php echo gettext("Utilities"); ?></h2>
1819:                     <div class="box-edit">
1820: 
1821:                         <label class="checkboxlabel">
1822:                             <input type="radio" id="a-<?php echo $prefix; ?>move" name="a-<?php echo $prefix; ?>MoveCopyRename" value="move"
1823:                                          onclick="toggleAlbumMCR('<?php echo $prefix; ?>', 'move');"<?php echo $isPrimaryAlbum; ?> />
1824:                                          <?php echo gettext("Move"); ?>
1825:                         </label>
1826: 
1827:                         <label class="checkboxlabel">
1828:                             <input type="radio" id="a-<?php echo $prefix; ?>copy" name="a-<?php echo $prefix; ?>MoveCopyRename" value="copy"
1829:                                          onclick="toggleAlbumMCR('<?php echo $prefix; ?>', 'copy');"/>
1830:                                          <?php echo gettext("Copy"); ?>
1831:                         </label>
1832: 
1833:                         <label class="checkboxlabel">
1834:                             <input type="radio" id="a-<?php echo $prefix; ?>rename" name="a-<?php echo $prefix; ?>MoveCopyRename" value="rename"
1835:                                          onclick="toggleAlbumMCR('<?php echo $prefix; ?>', 'rename');" <?php echo $isPrimaryAlbum; ?> />
1836:                                          <?php echo gettext("Rename Folder"); ?>
1837:                         </label>
1838: 
1839:                         <label class="checkboxlabel">
1840:                             <input type="radio" id="Delete-<?php echo $prefix; ?>" name="a-<?php echo $prefix; ?>MoveCopyRename" value="delete"
1841:                             <?php
1842:                             if ($isPrimaryAlbum) {
1843:                                 ?>
1844:                                              disabled="disabled"
1845:                                              <?php
1846:                                          } else {
1847:                                              ?>
1848:                                              onclick="toggleAlbumMCR('<?php echo $prefix; ?>', '');
1849:                                                      deleteConfirm('Delete-<?php echo $prefix; ?>', '<?php echo $prefix; ?>', deleteAlbum1);"
1850:                                              <?php
1851:                                          }
1852:                                          ?> />
1853:                                          <?php echo gettext("Delete album"); ?>
1854:                         </label>
1855: 
1856:                         <br class="clearall" />
1857:                         <div class="deletemsg" id="deletemsg<?php echo $prefix; ?>" style="padding-top: .5em; padding-left: .5em; color: red; display: none">
1858:                             <?php echo gettext('Album will be deleted when changes are applied.'); ?>
1859:                             <br class="clearall" />
1860:                             <p class="buttons">
1861:                                 <a  href="javascript:toggleAlbumMCR('<?php echo $prefix; ?>', '');"><img src="images/reset.png" alt="" /><?php echo addslashes(gettext("Cancel")); ?></a>
1862:                             </p>
1863:                         </div>
1864:                         <div id="a-<?php echo $prefix; ?>movecopydiv" style="padding-top: .5em; padding-left: .5em; display: none;">
1865:                             <?php echo gettext("to:"); ?>
1866:                             <select id="a-<?php echo $prefix; ?>albumselectmenu" name="a-<?php echo $prefix; ?>albumselect" onchange="">
1867:                                 <?php
1868:                                 $exclude = $album->name;
1869:                                 if (count(explode('/', $exclude)) > 1 && zp_loggedin(MANAGE_ALL_ALBUM_RIGHTS)) {
1870:                                     ?>
1871:                                     <option value="" selected="selected">/</option>
1872:                                     <?php
1873:                                 }
1874:                                 foreach ($mcr_albumlist as $fullfolder => $albumtitle) {
1875:                                     // don't allow copy in place or to subalbums
1876:                                     if ($fullfolder == dirname($exclude) || $fullfolder == $exclude || strpos($fullfolder, $exclude . '/') === 0) {
1877:                                         $disabled = ' disabled="disabled"';
1878:                                     } else {
1879:                                         $disabled = '';
1880:                                     }
1881:                                     // Get rid of the slashes in the subalbum, while also making a subalbum prefix for the menu.
1882:                                     $singlefolder = $fullfolder;
1883:                                     $saprefix = '';
1884:                                     $salevel = 0;
1885: 
1886:                                     while (strstr($singlefolder, '/') !== false) {
1887:                                         $singlefolder = substr(strstr($singlefolder, '/'), 1);
1888:                                         $saprefix = "&nbsp; &nbsp;&nbsp;" . $saprefix;
1889:                                         $salevel = ($salevel + 1) % 8;
1890:                                     }
1891:                                     echo '<option value="' . $fullfolder . '"' . ($salevel > 0 ? ' style="background-color: ' . $bglevels[$salevel] . ';"' : '')
1892:                                     . "$disabled>" . $saprefix . $singlefolder . "</option>\n";
1893:                                 }
1894:                                 ?>
1895:                             </select>
1896:                             <br class="clearall" /><br />
1897:                             <p class="buttons">
1898:                                 <a href="javascript:toggleAlbumMCR('<?php echo $prefix; ?>', '');"><img src="images/reset.png" alt="" /><?php echo addslashes(gettext("Cancel")); ?></a>
1899:                             </p>
1900:                         </div>
1901:                         <div id="a-<?php echo $prefix; ?>renamediv" style="padding-top: .5em; padding-left: .5em; display: none;">
1902:                             <?php echo gettext("to:"); ?>
1903:                             <input name="a-<?php echo $prefix; ?>renameto" type="text" value="<?php echo basename($album->name); ?>"/><br />
1904:                             <br class="clearall" />
1905:                             <p class="buttons">
1906:                                 <a href="javascript:toggleAlbumMCR('<?php echo $prefix; ?>', '');"><img src="images/reset.png" alt="" /><?php echo addslashes(gettext("Cancel")); ?></a>
1907:                             </p>
1908:                         </div>
1909:                         <span class="clearall" ></span>
1910:                         <?php
1911:                         echo zp_apply_filter('edit_album_utilities', '', $album, $prefix);
1912:                         printAlbumButtons($album);
1913:                         ?>
1914:                         <span class="clearall" ></span>
1915:                     </div>
1916:                     <h2 class="h2_bordered_edit"><?php echo gettext("Tags"); ?></h2>
1917:                     <div class="box-edit-unpadded">
1918:                         <?php
1919:                         $tagsort = getTagOrder();
1920:                         tagSelector($album, 'tags_' . $prefix, false, $tagsort, true, true);
1921:                         ?>
1922:                     </div>
1923:                 </td>
1924:             </tr>
1925:         </table>
1926:         <?php
1927:         if ($album->isDynamic()) {
1928:             ?>
1929:             <table>
1930:                 <tr>
1931:                     <td align="left" valign="top" width="150"><?php echo gettext("Dynamic album search:"); ?></td>
1932:                     <td>
1933:                         <table class="noinput">
1934:                             <tr>
1935:                                 <td><?php echo html_encode(urldecode($album->getSearchParams())); ?></td>
1936:                             </tr>
1937:                         </table>
1938:                     </td>
1939:                 </tr>
1940:             </table>
1941:             <?php
1942:         }
1943:         ?>
1944: 
1945:         <br class="clearall" />
1946:         <?php
1947:         if ($buttons) {
1948:             ?>
1949:             <span class="buttons">
1950:                 <a href="<?php echo WEBPATH . '/' . ZENFOLDER . '/admin-edit.php?page=edit' . $parent; ?>">
1951:                     <img    src="images/arrow_left_blue_round.png" alt="" />
1952:                     <strong><?php echo gettext("Back"); ?></strong>
1953:                 </a>
1954:                 <button type="submit">
1955:                     <img    src="images/pass.png" alt="" />
1956:                     <strong><?php echo gettext("Apply"); ?></strong>
1957:                 </button>
1958:                 <button type="reset" onclick="javascript:$('.deletemsg').hide();">
1959:                     <img    src="images/fail.png" alt="" />
1960:                     <strong><?php echo gettext("Reset"); ?></strong>
1961:                 </button>
1962:                 <div class="floatright">
1963:                     <?php
1964:                     if (!$album->isDynamic()) {
1965:                         ?>
1966:                         <button type="button" title="<?php echo addslashes(gettext('New subalbum')); ?>" onclick="javascript:newAlbum('<?php echo pathurlencode($album->name); ?>', true);">
1967:                             <img src="images/folder.png" alt="" />
1968:                             <strong><?php echo gettext('New subalbum'); ?></strong>
1969:                         </button>
1970:                     <?php if(!$album->isDynamic()) { ?>
1971:          <button type="button" title="<?php echo addslashes(gettext('New dynamic subalbum')); ?>" onclick="javascript:newDynAlbum('<?php echo pathurlencode($album->name); ?>', false);">
1972:            <img src="images/folder.png" alt="" />
1973:                                             <strong><?php echo gettext('New dynamic subalbum'); ?></strong>
1974:                                  </button>
1975:        <?php 
1976:       } 
1977:                     }
1978:                     ?>
1979:                     <a href="<?php echo WEBPATH . "/index.php?album=" . html_encode(pathurlencode($album->getFileName())); ?>">
1980:                         <img src="images/view.png" alt="" />
1981:                         <strong><?php echo gettext('View Album'); ?></strong>
1982:                     </a>
1983:                 </div>
1984:             </span>
1985:             <?php
1986:         }
1987:         ?>
1988:         <br class="clearall" />
1989:         <?php
1990:     }
1991: 
1992:     /**
1993:      * puts out the maintenance buttons for an album
1994:      *
1995:      * @param object $album is the album being emitted
1996:      */
1997:     function printAlbumButtons($album) {
1998:         if ($imagcount = $album->getNumImages() > 0) {
1999:             ?>
2000:             <div class="button buttons tooltip" title="<?php echo addslashes(gettext("Clears the s cached images.")); ?>">
2001:                 <a href="<?php echo WEBPATH . '/' . ZENFOLDER . '/admin-edit.php?action=clear_cache&amp;album=' . html_encode($album->name); ?>&amp;XSRFToken=<?php echo getXSRFToken('clear_cache'); ?>">
2002:                     <img src="images/edit-delete.png" /><?php echo gettext('Clear album image cache'); ?></a>
2003:                 <br class="clearall" />
2004:             </div>
2005:             <div class="button buttons tooltip" title="<?php echo gettext("Resets s hit counters."); ?>">
2006:                 <a href="<?php echo WEBPATH . '/' . ZENFOLDER . '/admin-edit.php?action=reset_hitcounters&amp;album=' . html_encode($album->name) . '&amp;albumid=' . $album->getID(); ?>&amp;XSRFToken=<?php echo getXSRFToken('hitcounter'); ?>">
2007:                     <img src="images/reset.png" /><?php echo gettext('Reset album hit counters'); ?></a>
2008:                 <br class="clearall" />
2009:             </div>
2010:             <?php
2011:         }
2012:         if ($imagcount || (!$album->isDynamic() && $album->getNumAlbums())) {
2013:             ?>
2014:             <div class="button buttons tooltip" title="<?php echo gettext("Refreshes the metadata for the album."); ?>">
2015:                 <a href="<?php echo WEBPATH . '/' . ZENFOLDER . '/admin-refresh-metadata.php?album=' . html_encode($album->name) . '&amp;return=' . html_encode($album->name); ?>&amp;XSRFToken=<?php echo getXSRFToken('refresh'); ?>">
2016:                     <img src="images/cache.png" /><?php echo gettext('Refresh album metadata'); ?></a>
2017:                 <br class="clearall" />
2018:             </div>
2019:             <?php
2020:         }
2021:     }
2022: 
2023:     function printAlbumLegend() {
2024:         ?>
2025:         <ul class="iconlegend-l">
2026:             <li><img src="images/folder_picture.png" alt="" /><?php echo gettext("Albums"); ?></li>
2027:             <li><img src="images/pictures.png" alt="" /><?php echo gettext("Images"); ?></li>
2028:             <li><img src="images/folder_picture_dn.png" alt="" /><?php echo gettext("Albums (dynamic)"); ?></li>
2029:             <li><img src="images/pictures_dn.png" alt="I" /><?php echo gettext("Images (dynamic)"); ?></li>
2030:         </ul>
2031:         <ul class="iconlegend">
2032:             <?php
2033:             if (GALLERY_SECURITY == 'public') {
2034:                 ?>
2035:                 <li><img src="images/lock.png" alt="" /><?php echo gettext("Has Password"); ?></li>
2036:                 <?php
2037:             }
2038:             ?>
2039:             <li><img src="images/pass.png" alt="Published" /><img src="images/action.png" alt="" /><?php echo gettext("Published/Un-published"); ?></li>
2040:             <li><img src="images/comments-on.png" alt="" /><img src="images/comments-off.png" alt="" /><?php echo gettext("Comments on/off"); ?></li>
2041:             <li><img src="images/view.png" alt="" /><?php echo gettext("View the album"); ?></li>
2042:             <li><img src="images/refresh.png" alt="" /><?php echo gettext("Refresh metadata"); ?></li>
2043:             <?php
2044:             if (extensionEnabled('hitcounter')) {
2045:                 ?>
2046:                 <li><img src="images/reset.png" alt="" /><?php echo gettext("Reset hit counters"); ?></li>
2047:                 <?php
2048:             }
2049:             ?>
2050:             <li><img src="images/fail.png" alt="" /><?php echo gettext("Delete"); ?></li>
2051:         </ul>
2052:         <?php
2053:     }
2054: 
2055:     /**
2056:      * puts out a row in the edit album table
2057:      *
2058:      * @param object $album is the album being emitted
2059:      * @param bool $show_thumb set to false to show thumb standin image rather than album thumb
2060:      * @param object $owner the parent album (or NULL for gallery)
2061:      *
2062:      * */
2063:     function printAlbumEditRow($album, $show_thumb, $owner) {
2064:         global $_zp_current_admin_obj;
2065:         $enableEdit = $album->albumSubRights() & MANAGED_OBJECT_RIGHTS_EDIT;
2066:         if (is_object($owner)) {
2067:             $owner = $owner->name;
2068:         }
2069:         ?>
2070:         <div class='page-list_row'>
2071: 
2072:             <div class="page-list_albumthumb">
2073:                 <?php
2074:                 if ($show_thumb) {
2075:                     $thumbimage = $album->getAlbumThumbImage();
2076:                     $thumb = getAdminThumb($thumbimage, 'small');
2077:                 } else {
2078:                     $thumb = 'images/thumb_standin.png';
2079:                 }
2080:                 if ($enableEdit) {
2081:                     ?>
2082:                     <a href="?page=edit&amp;album=<?php echo html_encode(pathurlencode($album->name)); ?>" title="<?php echo sprintf(gettext('Edit this album: %s'), $album->name); ?>">
2083:                         <?php
2084:                     }
2085:                     ?>
2086:                     <img src="<?php echo html_encode(pathurlencode($thumb)); ?>" width="40" height="40" alt="" title="album thumb" />
2087:                     <?php
2088:                     if ($enableEdit) {
2089:                         ?>
2090:                     </a>
2091:                     <?php
2092:                 }
2093:                 ?>
2094:             </div>
2095:             <div class="page-list_albumtitle">
2096:                 <?php
2097:                 if ($enableEdit) {
2098:                     ?>
2099:                     <a href="?page=edit&amp;album=<?php echo html_encode(pathurlencode($album->name)); ?>" title="<?php echo sprintf(gettext('Edit this album: %s'), $album->name); ?>">
2100:                         <?php
2101:                     }
2102:                     echo getBare($album->getTitle());
2103:                     if ($enableEdit) {
2104:                         ?>
2105:                     </a>
2106:                     <?php
2107:                 }
2108:                 ?>
2109:             </div>
2110:             <?php
2111:             if ($album->isDynamic()) {
2112:                 $imgi = '<img src="images/pictures_dn.png" alt="" title="' . gettext('images') . '" />';
2113:                 $imga = '<img src="images/folder_picture_dn.png" alt="" title="' . gettext('albums') . '" />';
2114:             } else {
2115:                 $imgi = '<img src="images/pictures.png" alt="" title="' . gettext('images') . '" />';
2116:                 $imga = '<img src="images/folder_picture.png" alt="" title="' . gettext('albums') . '" />';
2117:             }
2118:             $ci = count($album->getImages());
2119:             $si = sprintf('%1$s <span>(%2$u)</span>', $imgi, $ci);
2120:             if ($ci > 0 && !$album->isDynamic()) {
2121:                 $si = '<a href="?page=edit&amp;album=' . html_encode(pathurlencode($album->name)) . '&amp;tab=imageinfo" title="' . gettext('Subalbum List') . '">' . $si . '</a>';
2122:             }
2123:             $ca = $album->getNumAlbums();
2124:             $sa = sprintf('%1$s <span>(%2$u)</span>', $imga, $ca);
2125:             if ($ca > 0 && !$album->isDynamic()) {
2126:                 $sa = '<a href="?page=edit&amp;album=' . html_encode(pathurlencode($album->name)) . '&amp;tab=subalbuminfo" title="' . gettext('Subalbum List') . '">' . $sa . '</a>';
2127:             }
2128:             ?>
2129:             <div class="page-list_extra">
2130:                 <?php echo $sa; ?>
2131:             </div>
2132:             <div class="page-list_extra">
2133:                 <?php echo $si; ?>
2134:             </div>
2135:             <?php $wide = '40px'; ?>
2136:             <div class="page-list_iconwrapperalbum">
2137:                 <div class="page-list_icon">
2138:                     <?php
2139:                     $pwd = $album->getPassword();
2140:                     if (!empty($pwd)) {
2141:                         echo '<a title="' . gettext('Password protected') . '"><img src="images/lock.png" style="border: 0px;" alt="" title="' . gettext('Password protected') . '" /></a>';
2142:                     }
2143:                     ?>
2144:                 </div>
2145:                 <div class="page-list_icon">
2146:                     <?php
2147:                     if ($album->getShow()) {
2148:                         if ($enableEdit) {
2149:                             ?>
2150:                             <a href="?action=publish&amp;value=0&amp;album=<?php echo html_encode(pathurlencode($album->name)); ?>&amp;return=*<?php echo html_encode(pathurlencode($owner)); ?>&amp;XSRFToken=<?php echo getXSRFToken('albumedit') ?>" title="<?php echo sprintf(gettext('Un-publish the album %s'), $album->name); ?>" >
2151:                                 <?php
2152:                             }
2153:                             ?>
2154:                             <img src="images/pass.png" style="border: 0px;" alt="" title="<?php echo gettext('Published'); ?>" />
2155:                             <?php
2156:                             if ($enableEdit) {
2157:                                 ?>
2158:                             </a>
2159:                             <?php
2160:                         }
2161:                     } else {
2162:                         if ($enableEdit) {
2163:                             ?>
2164:                             <a href="?action=publish&amp;value=1&amp;album=<?php echo html_encode(pathurlencode($album->name)); ?>&amp;return=*<?php echo html_encode(pathurlencode($owner)); ?>&amp;XSRFToken=<?php echo getXSRFToken('albumedit') ?>" title="<?php echo sprintf(gettext('Publish the album %s'), $album->name); ?>">
2165:                                 <?php
2166:                             }
2167:                             ?>
2168:                             <img src="images/action.png" style="border: 0px;" alt="" title="<?php echo sprintf(gettext('Unpublished'), $album->name); ?>" />
2169:                             <?php
2170:                             if ($enableEdit) {
2171:                                 ?>
2172:                             </a>
2173:                             <?php
2174:                         }
2175:                     }
2176:                     ?>
2177:                 </div>
2178:                 <div class="page-list_icon">
2179:                     <?php
2180:                     if ($album->getCommentsAllowed()) {
2181:                         if ($enableEdit) {
2182:                             ?>
2183:                             <a href="?action=comments&amp;commentson=0&amp;album=<?php echo html_encode($album->getFileName()); ?>&amp;return=*<?php echo html_encode(pathurlencode($owner)); ?>&amp;XSRFToken=<?php echo getXSRFToken('albumedit') ?>" title="<?php echo gettext('Disable comments'); ?>">
2184:                                 <?php
2185:                             }
2186:                             ?>
2187:                             <img src="images/comments-on.png" alt="" title="<?php echo gettext("Comments on"); ?>" style="border: 0px;"/>
2188:                             <?php
2189:                             if ($enableEdit) {
2190:                                 ?>
2191:                             </a>
2192:                             <?php
2193:                         }
2194:                     } else {
2195:                         if ($enableEdit) {
2196:                             ?>
2197:                             <a href="?action=comments&amp;commentson=1&amp;album=<?php echo html_encode($album->getFileName()); ?>&amp;return=*<?php echo html_encode(pathurlencode($owner)); ?>&amp;XSRFToken=<?php echo getXSRFToken('albumedit') ?>" title="<?php echo gettext('Enable comments'); ?>">
2198:                                 <?php
2199:                             }
2200:                             ?>
2201:                             <img src="images/comments-off.png" alt="" title="<?php echo gettext("Comments off"); ?>" style="border: 0px;"/>
2202:                             <?php
2203:                             if ($enableEdit) {
2204:                                 ?>
2205:                             </a>
2206:                             <?php
2207:                         }
2208:                     }
2209:                     ?>
2210:                 </div>
2211:                 <div class="page-list_icon">
2212:                     <a href="<?php echo WEBPATH; ?>/index.php?album=<?php echo html_encode(pathurlencode($album->name)); ?>" title="<?php echo gettext("View album"); ?>">
2213:                         <img src="images/view.png" style="border: 0px;" alt="" title="<?php echo sprintf(gettext('View album %s'), $album->name); ?>" />
2214:                     </a>
2215:                 </div>
2216:                 <div class="page-list_icon">
2217:                     <?php
2218:                     if ($album->isDynamic() || !$enableEdit) {
2219:                         ?>
2220:                         <img src="images/icon_inactive.png" style="border: 0px;" alt="" title="<?php echo gettext('unavailable'); ?>" />
2221:                         <?php
2222:                     } else {
2223:                         ?>
2224:                         <a class="warn" href="admin-refresh-metadata.php?page=edit&amp;album=<?php echo html_encode(pathurlencode($album->name)); ?>&amp;return=*<?php echo html_encode(pathurlencode($owner)); ?>&amp;XSRFToken=<?php echo getXSRFToken('refresh') ?>" title="<?php echo sprintf(gettext('Refresh metadata for the album %s'), $album->name); ?>">
2225:                             <img src="images/refresh.png" style="border: 0px;" alt="" title="<?php echo sprintf(gettext('Refresh metadata in the album %s'), $album->name); ?>" />
2226:                         </a>
2227:                         <?php
2228:                     }
2229:                     ?>
2230:                 </div>
2231:                 <?php
2232:                 if (extensionEnabled('hitcounter')) {
2233:                     ?>
2234:                     <div class="page-list_icon">
2235:                         <?php
2236:                         if (!$enableEdit) {
2237:                             ?>
2238:                             <img src="images/icon_inactive.png" style="border: 0px;" alt="" title="<?php echo gettext('unavailable'); ?>" />
2239:                             <?php
2240:                         } else {
2241:                             ?>
2242:                             <a class="reset" href="?action=reset_hitcounters&amp;albumid=<?php echo $album->getID(); ?>&amp;album=<?php echo html_encode(pathurlencode($album->name)); ?>&amp;subalbum=true&amp;return=*<?php echo html_encode(pathurlencode($owner)); ?>&amp;XSRFToken=<?php echo getXSRFToken('hitcounter') ?>" title="<?php echo sprintf(gettext('Reset hit counters for album %s'), $album->name); ?>">
2243:                                 <img src="images/reset.png" style="border: 0px;" alt="" title="<?php echo sprintf(gettext('Reset hit counters for the album %s'), $album->name); ?>" />
2244:                             </a>
2245:                             <?php
2246:                         }
2247:                         ?>
2248:                     </div>
2249:                     <?php
2250:                 }
2251:                 ?>
2252:                 <div class="page-list_icon">
2253:                     <?php
2254:                     $myalbum = $_zp_current_admin_obj->getAlbum();
2255:                     $supress = !zp_loggedin(MANAGE_ALL_ALBUM_RIGHTS) && $myalbum && $album->getID() == $myalbum->getID();
2256:                     if (!$enableEdit || $supress) {
2257:                         ?>
2258:                         <img src="images/icon_inactive.png" style="border: 0px;" alt="" title="<?php echo gettext('unavailable'); ?>" />
2259:                         <?php
2260:                     } else {
2261:                         ?>
2262:                         <a class="delete" href="javascript:confirmDeleteAlbum('?page=edit&amp;action=deletealbum&amp;album=<?php echo urlencode(pathurlencode($album->name)); ?>&amp;return=<?php echo html_encode(pathurlencode(dirname($album->name))); ?>&amp;XSRFToken=<?php echo getXSRFToken('delete') ?>');" title="<?php echo sprintf(gettext("Delete the album %s"), js_encode($album->name)); ?>">
2263:                             <img src="images/fail.png" style="border: 0px;" alt="" title="<?php echo sprintf(gettext('Delete the album %s'), js_encode($album->name)); ?>" />
2264:                         </a>
2265:                         <?php
2266:                     }
2267:                     ?>
2268:                 </div>
2269:                 <?php
2270:                 if ($enableEdit) {
2271:                     ?>
2272:                     <div class="page-list_icon">
2273:                         <input class="checkbox" type="checkbox" name="ids[]" value="<?php echo $album->getFileName(); ?>" onclick="triggerAllBox(this.form, 'ids[]', this.form.allbox);" <?php if ($supress) echo ' disabled="disabled"'; ?> />
2274:                     </div>
2275:                     <?php
2276:                 }
2277:                 ?>
2278:             </div>
2279:         </div>
2280:         <?php
2281:     }
2282: 
2283:     /**
2284:      * processes the post from the above
2285:      * @param int $index the index of the entry in mass edit or 0 if single album
2286:      * @param object $album the album object
2287:      * @param string $redirectto used to redirect page refresh on move/copy/rename
2288:      * @return string error flag if passwords don't match
2289:      * @since 1.1.3
2290:      */
2291:     function processAlbumEdit($index, $album, &$redirectto) {
2292:         $redirectto = NULL; // no redirection required
2293:         if ($index == 0) {
2294:             $prefix = $suffix = '';
2295:         } else {
2296:             $prefix = "$index-";
2297:             $suffix = "_$index";
2298:         }
2299:         $tagsprefix = 'tags_' . $prefix;
2300:         $notify = '';
2301:         $album->setTitle(process_language_string_save($prefix . 'albumtitle', 2));
2302:         $album->setDesc(process_language_string_save($prefix . 'albumdesc', EDITOR_SANITIZE_LEVEL));
2303:         $tags = array();
2304:         $l = strlen($tagsprefix);
2305:         foreach ($_POST as $key => $value) {
2306:             $key = postIndexDecode($key);
2307:             if (substr($key, 0, $l) == $tagsprefix) {
2308:                 if ($value) {
2309:                     $tags[] = sanitize(substr($key, $l));
2310:                 }
2311:             }
2312:         }
2313:         $tags = array_unique($tags);
2314:         $album->setTags($tags);
2315:         $album->setDateTime(sanitize($_POST[$prefix . "albumdate"]));
2316:         $album->setLocation(process_language_string_save($prefix . 'albumlocation', 3));
2317:         if (isset($_POST[$prefix . 'thumb']))
2318:             $album->setThumb(sanitize($_POST[$prefix . 'thumb']));
2319:         $album->setShow((int) isset($_POST[$prefix . 'Published']));
2320:         $album->setCommentsAllowed(isset($_POST[$prefix . 'allowcomments']));
2321:         $sorttype = strtolower(sanitize($_POST[$prefix . 'sortby'], 3));
2322:         if ($sorttype == 'custom') {
2323:             $sorttype = unquote(strtolower(sanitize($_POST[$prefix . 'customimagesort'], 3)));
2324:         }
2325:         $album->setSortType($sorttype);
2326:         if (($sorttype == 'manual') || ($sorttype == 'random')) {
2327:             $album->setSortDirection(false, 'image');
2328:         } else {
2329:             if (empty($sorttype)) {
2330:                 $direction = false;
2331:             } else {
2332:                 $direction = isset($_POST[$prefix . 'image_sortdirection']);
2333:             }
2334:             $album->setSortDirection($direction, 'image');
2335:         }
2336:         $sorttype = strtolower(sanitize($_POST[$prefix . 'subalbumsortby'], 3));
2337:         if ($sorttype == 'custom')
2338:             $sorttype = strtolower(sanitize($_POST[$prefix . 'customalbumsort'], 3));
2339:         $album->setSortType($sorttype, 'album');
2340:         if (($sorttype == 'manual') || ($sorttype == 'random')) {
2341:             $album->setSortDirection(false, 'album');
2342:         } else {
2343:             $album->setSortDirection(isset($_POST[$prefix . 'album_sortdirection']), 'album');
2344:         }
2345:         if (isset($_POST['reset_hitcounter' . $prefix])) {
2346:             $album->set('hitcounter', 0);
2347:         }
2348:         if (isset($_POST[$prefix . 'reset_rating'])) {
2349:             $album->set('total_value', 0);
2350:             $album->set('total_votes', 0);
2351:             $album->set('used_ips', 0);
2352:         }
2353:         $album->setPublishDate(sanitize($_POST['publishdate-' . $prefix]));
2354:         $album->setExpireDate(sanitize($_POST['expirationdate-' . $prefix]));
2355:         $fail = '';
2356:         processCredentials($album, $suffix);
2357:         $oldtheme = $album->getAlbumTheme();
2358:         if (isset($_POST[$prefix . 'album_theme'])) {
2359:             $newtheme = sanitize($_POST[$prefix . 'album_theme']);
2360:             if ($oldtheme != $newtheme) {
2361:                 $album->setAlbumTheme($newtheme);
2362:             }
2363:         }
2364:         if (isset($_POST[$prefix . 'album_watermark'])) {
2365:             $album->setWatermark(sanitize($_POST[$prefix . 'album_watermark'], 3));
2366:             $album->setWatermarkThumb(sanitize($_POST[$prefix . 'album_watermark_thumb'], 3));
2367:         }
2368:         if (zp_loggedin(CODEBLOCK_RIGHTS)) {
2369:             $album->setCodeblock(processCodeblockSave((int) $prefix));
2370:         }
2371:         if (isset($_POST[$prefix . 'owner']))
2372:             $album->setOwner(sanitize($_POST[$prefix . 'owner']));
2373: 
2374:         $custom = process_language_string_save($prefix . 'album_custom_data', 1);
2375:         $album->setCustomData(zp_apply_filter('save_album_custom_data', $custom, $prefix));
2376:         zp_apply_filter('save_album_utilities_data', $album, $prefix);
2377:         $album->save();
2378: 
2379:         // Move/Copy/Rename the album after saving.
2380:         $movecopyrename_action = '';
2381:         if (isset($_POST['a-' . $prefix . 'MoveCopyRename'])) {
2382:             $movecopyrename_action = sanitize($_POST['a-' . $prefix . 'MoveCopyRename'], 3);
2383:         }
2384: 
2385:         if ($movecopyrename_action == 'delete') {
2386:             $dest = dirname($album->name);
2387:             if ($album->remove()) {
2388:                 if ($dest == '/' || $dest == '.')
2389:                     $dest = '';
2390:                 $redirectto = $dest;
2391:             } else {
2392:                 $notify = "&mcrerr=7";
2393:             }
2394:         }
2395:         if ($movecopyrename_action == 'move') {
2396:             $dest = sanitize_path($_POST['a' . $prefix . '-albumselect']);
2397:             // Append the album name.
2398:             $dest = ($dest ? $dest . '/' : '') . (strpos($album->name, '/') === FALSE ? $album->name : basename($album->name));
2399:             if ($dest && $dest != $album->name) {
2400:                 if ($suffix = $album->isDynamic()) { // be sure there is a .alb suffix
2401:                     if (substr($dest, -4) != '.' . $suffix) {
2402:                         $dest .= '.' . suffix;
2403:                     }
2404:                 }
2405:                 if ($e = $album->move($dest)) {
2406:                     $notify = "&mcrerr=" . $e;
2407:                     SearchEngine::clearSearchCache();
2408:                 } else {
2409:                     $redirectto = $dest;
2410:                 }
2411:             } else {
2412:                 // Cannot move album to same album.
2413:                 $notify = "&mcrerr=3";
2414:             }
2415:         } else if ($movecopyrename_action == 'copy') {
2416:             $dest = sanitize_path($_POST['a' . $prefix . '-albumselect']);
2417:             if ($dest && $dest != $album->name) {
2418:                 if ($e = $album->copy($dest)) {
2419:                     $notify = "&mcrerr=" . $e;
2420:                 }
2421:             } else {
2422:                 // Cannot copy album to existing album.
2423:                 // Or, copy with rename?
2424:                 $notify = '&mcrerr=3';
2425:             }
2426:         } else if ($movecopyrename_action == 'rename') {
2427:             $renameto = sanitize_path($_POST['a' . $prefix . '-renameto']);
2428:             $renameto = str_replace(array('/', '\\'), '', $renameto);
2429:             if (dirname($album->name) != '.') {
2430:                 $renameto = dirname($album->name) . '/' . $renameto;
2431:             }
2432:             if ($renameto != $album->name) {
2433:                 if ($suffix = $album->isDynamic()) { // be sure there is a .alb suffix
2434:                     if (substr($renameto, -4) != '.' . $suffix) {
2435:                         $renameto .= '.' . $suffix;
2436:                     }
2437:                 }
2438:                 if ($e = $album->rename($renameto)) {
2439:                     $notify = "&mcrerr=" . $e;
2440:                 } else {
2441:                     $redirectto = $renameto;
2442:                 }
2443:             } else {
2444:                 $notify = "&mcrerr=3";
2445:             }
2446:         }
2447:         return $notify;
2448:     }
2449: 
2450:  /**
2451:   * Process the image edit form posted
2452:   * @param obj $image Image object
2453:   * @param type $index Index of the image if within the images list or 0 if single image edit
2454:   * @param boolean $massedit Whether editing single image (false) or multiple images at once (true). Note: to determine whether to process additional fields in single image edit mode.
2455:   */
2456:  function processImageEdit($image, $index, $massedit=true) {
2457: 
2458:   $notify = '';
2459:   if (isset($_POST[$index . '-MoveCopyRename'])) {
2460:     $movecopyrename_action = sanitize($_POST[$index . '-MoveCopyRename'], 3);
2461:   } else {
2462:     $movecopyrename_action = '';
2463:   }
2464:   if ($movecopyrename_action == 'delete') {
2465:     $image->remove();
2466:   } else {
2467:     if ($thumbnail = sanitize($_POST['album_thumb-' . $index])) { //selected as an album thumb
2468:       $talbum = newAlbum($thumbnail);
2469:       if ($image->imagefolder == $thumbnail) {
2470:         $talbum->setThumb($image->filename);
2471:       } else {
2472:         $talbum->setThumb('/' . $image->imagefolder . '/' . $image->filename);
2473:       }
2474:       $talbum->save();
2475:     }
2476:     if (isset($_POST[$index . '-reset_rating'])) {
2477:       $image->set('total_value', 0);
2478:       $image->set('total_votes', 0);
2479:       $image->set('used_ips', 0);
2480:     }
2481:     $image->setPublishDate(sanitize($_POST['publishdate-' . $index]));
2482:     $image->setExpireDate(sanitize($_POST['expirationdate-' . $index]));
2483:     $image->setTitle(process_language_string_save("$index-title", 2));
2484:     $image->setDesc(process_language_string_save("$index-desc", EDITOR_SANITIZE_LEVEL));
2485:     if (isset($_POST[$index . '-oldrotation']) && isset($_POST[$index . '-rotation'])) {
2486:       $oldrotation = (int) $_POST[$index . '-oldrotation'];
2487:       $rotation = (int) $_POST[$index . '-rotation'];
2488:       if ($rotation != $oldrotation) {
2489:         $image->set('EXIFOrientation', $rotation);
2490:         $image->updateDimensions();
2491:         $album = $image->getAlbum();
2492:         Gallery::clearCache(SERVERCACHE . '/' . $album->name);
2493:       }
2494:     }
2495:     if (!$massedit) {
2496:         $image->setLocation(process_language_string_save("$index-location", 3));
2497:         $image->setCity(process_language_string_save("$index-city", 3));
2498:         $image->setState(process_language_string_save("$index-state", 3));
2499:         $image->setCountry(process_language_string_save("$index-country", 3));
2500:         $image->setCredit(process_language_string_save("$index-credit", 1));
2501:         $image->setCopyright(process_language_string_save("$index-copyright", 1));
2502:         $tagsprefix = 'tags_' . $index . '-';
2503:         $tags = array();
2504:         $l = strlen($tagsprefix);
2505:         foreach ($_POST as $key => $value) {
2506:             $key = postIndexDecode($key);
2507:             if (substr($key, 0, $l) == $tagsprefix) {
2508:                 if ($value) {
2509:                     $tags[] = sanitize(substr($key, $l));
2510:                 }
2511:             }
2512:         }
2513:         $tags = array_unique($tags);
2514:         $image->setTags($tags);
2515:         if (zp_loggedin(CODEBLOCK_RIGHTS)) {
2516:             $image->setCodeblock(processCodeblockSave($index));
2517:         }
2518:         $custom = process_language_string_save("$index-custom_data", 1);
2519:         $image->setCustomData(zp_apply_filter('save_image_custom_data', $custom, $index));
2520:     }
2521:     $image->setDateTime(sanitize($_POST["$index-date"]));
2522:     $image->setShow(isset($_POST["$index-Visible"]));
2523:     $image->setCommentsAllowed(isset($_POST["$index-allowcomments"]));
2524:     if (isset($_POST["reset_hitcounter$index"])) {
2525:       $image->set('hitcounter', 0);
2526:     }
2527:     $wmt = sanitize($_POST["$index-image_watermark"], 3);
2528:     $image->setWatermark($wmt);
2529:     $wmuse = 0;
2530:     if (isset($_POST['wm_image-' . $index]))
2531:       $wmuse = $wmuse | WATERMARK_IMAGE;
2532:     if (isset($_POST['wm_thumb-' . $index]))
2533:       $wmuse = $wmuse | WATERMARK_THUMB;
2534:     if (isset($_POST['wm_full-' . $index]))
2535:       $wmuse = $wmuse | WATERMARK_FULL;
2536:     $image->setWMUse($wmuse);
2537:     
2538:     if (isset($_POST[$index . '-owner']))
2539:       $image->setOwner(sanitize($_POST[$index . '-owner']));
2540:     $image->set('filesize', filesize($image->localpath));
2541: 
2542:     zp_apply_filter('save_image_utilities_data', $image, $index);
2543:     $image->save();
2544: 
2545:     // Process move/copy/rename
2546:     $folder = $image->getAlbumName();
2547:     if ($movecopyrename_action == 'move') {
2548:       $dest = sanitize_path($_POST[$index . '-albumselect']);
2549:       if ($dest && $dest != $folder) {
2550:         if ($e = $image->move($dest)) {
2551:                     SearchEngine::clearSearchCache();
2552:           $notify = "&mcrerr=" . $e;
2553:         }
2554:       } else {
2555:         // Cannot move image to same album.
2556:         $notify = "&mcrerr=2";
2557:       }
2558:     } else if ($movecopyrename_action == 'copy') {
2559:       $dest = sanitize_path($_POST[$index . '-albumselect']);
2560:       if ($dest && $dest != $folder) {
2561:         if ($e = $image->copy($dest)) {
2562:           $notify = "&mcrerr=" . $e;
2563:         }
2564:       } else {
2565:         // Cannot copy image to existing album.
2566:         // Or, copy with rename?
2567:         $notify = "&mcrerr=2";
2568:       }
2569:     } else if ($movecopyrename_action == 'rename') {
2570:       $renameto = sanitize_path($_POST[$index . '-renameto']);
2571:       if ($e = $image->rename($renameto)) {
2572:                 SearchEngine::clearSearchCache();
2573:         $notify = "&mcrerr=" . $e;
2574:       }
2575:     }
2576:   }
2577:   return $notify;
2578: }
2579: 
2580: function adminPageNav($pagenum, $totalpages, $adminpage, $parms, $tab = '') {
2581:         if (empty($parms)) {
2582:             $url = '?';
2583:         } else {
2584:             $url = $parms . '&amp;';
2585:         }
2586:         echo '<ul class="pagelist"><li class="prev">';
2587:         if ($pagenum > 1) {
2588:             echo '<a href="' . $url . 'subpage=' . ($p = $pagenum - 1) . $tab . '" title="' . sprintf(gettext('page %u'), $p) . '">' . '&laquo; ' . gettext("Previous page") . '</a>';
2589:         } else {
2590:             echo '<span class="disabledlink">&laquo; ' . gettext("Previous page") . '</span>';
2591:         }
2592:         echo "</li>";
2593:         $start = max(1, $pagenum - 7);
2594:         $total = min($start + 15, $totalpages + 1);
2595:         if ($start != 1) {
2596:             echo "\n <li><a href=" . $url . 'subpage=' . ($p = max($start - 8, 1)) . $tab . ' title="' . sprintf(gettext('page %u'), $p) . '">. . .</a></li>';
2597:         }
2598:         for ($i = $start; $i < $total; $i++) {
2599:             if ($i == $pagenum) {
2600:                 echo "<li class=\"current\">" . $i . '</li>';
2601:             } else {
2602:                 echo '<li><a href="' . $url . 'subpage=' . $i . $tab . '" title="' . sprintf(gettext('page %u'), $i) . '">' . $i . '</a></li>';
2603:             }
2604:         }
2605:         if ($i < $totalpages) {
2606:             echo "\n <li><a href=" . $url . 'subpage=' . ($p = min($pagenum + 22, $totalpages + 1)) . $tab . ' title="' . sprintf(gettext('page %u'), $p) . '">. . .</a></li>';
2607:         }
2608:         echo "<li class=\"next\">";
2609:         if ($pagenum < $totalpages) {
2610:             echo '<a href="' . $url . 'subpage=' . ($p = $pagenum + 1) . $tab . '" title="' . sprintf(gettext('page %u'), $p) . '">' . gettext("Next page") . ' &raquo;' . '</a>';
2611:         } else {
2612:             echo '<span class="disabledlink">' . gettext("Next page") . ' &raquo;</span>';
2613:         }
2614:         echo '</li></ul>';
2615:     }
2616: 
2617:     $_zp_current_locale = NULL;
2618: 
2619:     /**
2620:      * Generates an editable list of language strings
2621:      *
2622:      * @param string $dbstring either a serialized languag string array or a single string
2623:      * @param string $name the prefix for the label, id, and name tags
2624:      * @param bool $textbox set to true for a textbox rather than a text field
2625:      * @param string $locale optional locale of the translation desired
2626:      * @param string $edit optional class
2627:      * @param int $wide column size. true or false for the standard or short sizes. Or pass a column size
2628:      * @param string $ulclass set to the class for the UL element
2629:      * @param int $rows set to the number of rows to show.
2630:      */
2631:     function print_language_string_list($dbstring, $name, $textbox = false, $locale = NULL, $edit = '', $wide = TEXT_INPUT_SIZE, $ulclass = 'language_string_list', $rows = 6) {
2632:         global $_zp_active_languages, $_zp_current_locale;
2633:         $dbstring = zpFunctions::unTagURLs($dbstring);
2634:         if (!empty($edit))
2635:             $edit = ' class="' . $edit . '"';
2636:         if (is_null($locale)) {
2637:             $locale = getUserLocale();
2638:         }
2639:         $strings = getSerializedArray($dbstring);
2640:         if (count($strings) == 1) {
2641:             $keys = array_keys($strings);
2642:             $lang = array_shift($keys);
2643:             if (!is_string($lang)) {
2644:                 $strings = array($locale => array_shift($strings));
2645:             }
2646:         }
2647:         $activelang = generateLanguageList();
2648: 
2649:         if (getOption('multi_lingual') && !empty($activelang)) {
2650:             if ($textbox) {
2651:                 if (strpos($wide, '%') === false) {
2652:                     $width = ' cols="' . $wide . '"';
2653:                 } else {
2654:                     $width = ' style="width:' . ((int) $wide - 1) . '%;"';
2655:                 }
2656:             } else {
2657:                 if (strpos($wide, '%') === false) {
2658:                     $width = ' size="' . $wide . '"';
2659:                 } else {
2660:                     $width = ' style="width:' . ((int) $wide - 2) . '%;"';
2661:                 }
2662:             }
2663: 
2664:             // put the language list in perferred order
2665:             $preferred = array($_zp_current_locale);
2666:             foreach (parseHttpAcceptLanguage() as $lang) {
2667:                 $preferred[] = str_replace('-', '_', $lang['fullcode']);
2668:             }
2669:             $preferred = array_unique($preferred);
2670:             $emptylang = array();
2671: 
2672:             foreach ($preferred as $lang) {
2673:                 foreach ($activelang as $key => $active) {
2674:                     if ($active == $lang) {
2675:                         $emptylang[$active] = $key;
2676:                         unset($activelang[$key]);
2677:                         continue 2;
2678:                     }
2679:                 }
2680:                 if (strlen($lang) == 2) { //    "wild card language"
2681:                     foreach ($activelang as $key => $active) {
2682:                         if (substr($active, 0, 2) == $lang) {
2683:                             $emptylang[$active] = $key;
2684:                         }
2685:                     }
2686:                 }
2687:             }
2688:             foreach ($activelang as $key => $active) {
2689:                 $emptylang[$active] = $key;
2690:             }
2691: 
2692:             if ($textbox) {
2693:                 $class = 'box';
2694:             } else {
2695:                 $class = '';
2696:             }
2697:             echo '<ul class="' . $ulclass . $class . '"' . ">\n";
2698:             $empty = true;
2699: 
2700:             foreach ($emptylang as $key => $lang) {
2701:                 if (isset($strings[$key])) {
2702:                     $string = $strings[$key];
2703:                     if (!empty($string)) {
2704:                         unset($emptylang[$key]);
2705:                         $empty = false;
2706:                         ?>
2707:                         <li>
2708:                             <label for="<?php echo $name . '_' . $key; ?>"><?php echo $lang; ?></label>
2709:                             <?php
2710:                             if ($textbox) {
2711:                                 echo "\n" . '<textarea name="' . $name . '_' . $key . '"' . $edit . $width . '  rows="' . $rows . '">' . html_encode($string) . '</textarea>';
2712:                             } else {
2713:                                 echo '<br /><input id="' . $name . '_' . $key . '" name="' . $name . '_' . $key . '"' . $edit . ' type="text" value="' . html_encode($string) . '"' . $width . ' />';
2714:                             }
2715:                             ?>
2716:                         </li>
2717:                         <?php
2718:                     }
2719:                 }
2720:             }
2721:             foreach ($emptylang as $key => $lang) {
2722:                 ?>
2723:                 <li>
2724:                     <label for="<?php echo $name . '_' . $key; ?>"><?php echo $lang; ?></label>
2725:                     <?php
2726:                     if ($textbox) {
2727:                         echo "\n" . '<textarea name="' . $name . '_' . $key . '"' . $edit . $width . '  rows="' . $rows . '"></textarea>';
2728:                     } else {
2729:                         echo '<br /><input id="' . $name . '_' . $key . '" name="' . $name . '_' . $key . '"' . $edit . ' type="text" value=""' . $width . ' />';
2730:                     }
2731:                     ?>
2732:                 </li>
2733:                 <?php
2734:             }
2735:             echo "</ul>\n";
2736:         } else {
2737:             if ($textbox) {
2738:                 if (strpos($wide, '%') === false) {
2739:                     $width = ' cols="' . $wide . '"';
2740:                 } else {
2741:                     $width = ' style="width:' . $wide . ';"';
2742:                 }
2743:             } else {
2744:                 if (strpos($wide, '%') === false) {
2745:                     $width = ' size="' . $wide . '"';
2746:                 } else {
2747:                     $width = ' style="width:' . $wide . ';"';
2748:                 }
2749:             }
2750:             if (empty($locale))
2751:                 $locale = 'en_US';
2752:             if (isset($strings[$locale])) {
2753:                 $dbstring = $strings[$locale];
2754:             } else {
2755:                 $dbstring = array_shift($strings);
2756:             }
2757:             if ($textbox) {
2758:                 echo '<textarea name="' . $name . '_' . $locale . '"' . $edit . $width . '  rows="' . $rows . '">' . html_encode($dbstring) . '</textarea>';
2759:             } else {
2760:                 echo '<input name="' . $name . '_' . $locale . '"' . $edit . ' type="text" value="' . html_encode($dbstring) . '"' . $width . ' />';
2761:             }
2762:         }
2763:     }
2764: 
2765:     /**
2766:      * process the post of a language string form
2767:      *
2768:      * @param string $name the prefix for the label, id, and name tags
2769:      * @param $sanitize_level the type of sanitization required
2770:      * @return string
2771:      */
2772:     function process_language_string_save($name, $sanitize_level = 3) {
2773:         $languages = generateLanguageList();
2774:         $l = strlen($name) + 1;
2775:         $strings = array();
2776:         foreach ($_POST as $key => $value) {
2777:             if ($value && preg_match('/^' . $name . '_[a-z]{2}_[A-Z]{2}$/', $key)) {
2778:                 $key = substr($key, $l);
2779:                 if (in_array($key, $languages)) {
2780:                     $strings[$key] = sanitize($value, $sanitize_level);
2781:                 }
2782:             }
2783:         }
2784:         switch (count($strings)) {
2785:             case 0:
2786:                 if (isset($_POST[$name])) {
2787:                     return sanitize($_POST[$name], $sanitize_level);
2788:                 } else {
2789:                     return '';
2790:                 }
2791:             default:
2792:                 return serialize($strings);
2793:         }
2794:     }
2795: 
2796:     /**
2797:      * Returns the desired tagsort order (0 for alphabetic, 1 for most used)
2798:      *
2799:      * @return int
2800:      */
2801:     function getTagOrder() {
2802:         if (isset($_REQUEST['tagsort'])) {
2803:             $tagsort = sanitize($_REQUEST['tagsort']);
2804:             setOption('tagsort', (int) ($tagsort && true));
2805:         } else {
2806:             $tagsort = getOption('tagsort');
2807:         }
2808:         return $tagsort;
2809:     }
2810: 
2811:     /**
2812:      * Unzips an image archive
2813:      *
2814:      * @param file $file the archive
2815:      * @param string $dir where the images go
2816:      */
2817:     function unzip($file, $dir) { //check if zziplib is installed
2818:         if (function_exists('zip_open')) {
2819:             $zip = zip_open($file);
2820:             if ($zip) {
2821:                 while ($zip_entry = zip_read($zip)) { // Skip non-images in the zip file.
2822:                     $fname = zip_entry_name($zip_entry);
2823:                     $seoname = internalToFilesystem(seoFriendly($fname));
2824:                     if (Gallery::validImage($seoname) || Gallery::validImageAlt($seoname)) {
2825:                         if (zip_entry_open($zip, $zip_entry, "r")) {
2826:                             $buf = zip_entry_read($zip_entry, zip_entry_filesize($zip_entry));
2827:                             $path_file = str_replace("/", DIRECTORY_SEPARATOR, $dir . '/' . $seoname);
2828:                             $fp = fopen($path_file, "w");
2829:                             fwrite($fp, $buf);
2830:                             fclose($fp);
2831:                             clearstatcache();
2832:                             zip_entry_close($zip_entry);
2833:                             $albumname = substr($dir, strlen(ALBUM_FOLDER_SERVERPATH));
2834:                             $album = newAlbum($albumname);
2835:                             $image = newImage($album, $seoname);
2836:                             if ($fname != $seoname) {
2837:                                 $image->setTitle($fname);
2838:                                 $image->save();
2839:                             }
2840:                         }
2841:                     }
2842:                 }
2843:                 zip_close($zip);
2844:             }
2845:         } else {
2846:             require_once(dirname(__FILE__) . '/lib-pclzip.php');
2847:             $zip = new PclZip($file);
2848:             if ($zip->extract(PCLZIP_OPT_PATH, $dir, PCLZIP_OPT_REMOVE_ALL_PATH) == 0) {
2849:                 return false;
2850:             }
2851:         }
2852:         return true;
2853:     }
2854: 
2855:     /**
2856:      * Checks for a zip file
2857:      *
2858:      * @param string $filename name of the file
2859:      * @return bool
2860:      */
2861:     function is_zip($filename) {
2862:         $ext = getSuffix($filename);
2863:         return ($ext == "zip");
2864:     }
2865: 
2866:     /**
2867:      * Extracts and returns a 'statement' from a PHP script so that it may be 'evaled'
2868:      *
2869:      * @param string $target the assignment variable to match on
2870:      * @param string $str the PHP script
2871:      * @return string
2872:      */
2873:     function isolate($target, $str) {
2874:         if (preg_match('|' . preg_quote($target) . '\s*?=(.+?);[ \f\v\t]*[\n\r]|s', $str, $matches)) {
2875:             return $matches[0];
2876:         }
2877:         return false;
2878:     }
2879: 
2880:     /**
2881:      * Return an array of files from a directory and sub directories
2882:      *
2883:      * This is a non recursive function that digs through a directory. More info here:
2884:      * @link http://planetozh.com/blog/2005/12/php-non-recursive-function-through-directories/
2885:      *
2886:      * @param string $dir directory
2887:      * @return array
2888:      * @author Ozh
2889:      * @since 1.3
2890:      */
2891:     function listDirectoryFiles($dir) {
2892:         $file_list = array();
2893:         $stack[] = $dir;
2894:         while ($stack) {
2895:             $current_dir = array_pop($stack);
2896:             if ($dh = @opendir($current_dir)) {
2897:                 while (($file = @readdir($dh)) !== false) {
2898:                     if ($file !== '.' AND $file !== '..') {
2899:                         $current_file = "{$current_dir}/{$file}";
2900:                         if (is_file($current_file) && is_readable($current_file)) {
2901:                             $file_list[] = "{$current_dir}/{$file}";
2902:                         } elseif (is_dir($current_file)) {
2903:                             $stack[] = $current_file;
2904:                         }
2905:                     }
2906:                 }
2907:             }
2908:         }
2909:         return $file_list;
2910:     }
2911: 
2912:     /**
2913:      * Check if a theme is editable (ie not a bundled theme)
2914:      *
2915:      * @param $theme theme to check
2916:      * @return bool
2917:      * @since 1.3
2918:      */
2919:     function themeIsEditable($theme) {
2920:         if (function_exists('readlink')) {
2921:             $link = @readlink(SERVERPATH . '/' . THEMEFOLDER . '/' . $theme);
2922:         } else {
2923:             $link = '';
2924:         }
2925:         if (empty($link) || str_replace('\\', '/', $link) == SERVERPATH . '/' . THEMEFOLDER . '/' . $theme) {
2926:             $zplist = getSerializedArray(getOption('Zenphoto_theme_list'));
2927:             return (!in_array($theme, $zplist));
2928:         } else {
2929:             return false;
2930:         }
2931:     }
2932: 
2933:     function zenPhotoTheme($theme) {
2934:         $zplist = getSerializedArray(getOption('Zenphoto_theme_list'));
2935:         return (in_array($theme, $zplist));
2936:     }
2937: 
2938:     /**
2939:      * Copy a theme directory to create a new custom theme
2940:      *
2941:      * @param $source source directory
2942:      * @param $target target directory
2943:      * @return bool|string either true or an error message
2944:      * @author Ozh
2945:      * @since 1.3
2946:      */
2947:     function copyThemeDirectory($source, $target, $newname) {
2948:         global $_zp_current_admin_obj;
2949:         $message = true;
2950:         $source = SERVERPATH . '/themes/' . internalToFilesystem($source);
2951:         $target = SERVERPATH . '/themes/' . internalToFilesystem($target);
2952: 
2953:         // If the target theme already exists, nothing to do.
2954:         if (is_dir($target)) {
2955:             return gettext('Cannot create new theme.') . ' ' . sprintf(gettext('Directory “%s” already exists!'), basename($target));
2956:         }
2957: 
2958:         // If source dir is missing, exit too
2959:         if (!is_dir($source)) {
2960:             return gettext('Cannot create new theme.') . ' ' . sprintf(gettext('Cannot find theme directory “%s” to copy!'), basename($source));
2961:         }
2962: 
2963:         // We must be able to write to the themes dir.
2964:         if (!is_writable(dirname($target))) {
2965:             return gettext('Cannot create new theme.') . ' ' . gettext('The <tt>/themes</tt> directory is not writable!');
2966:         }
2967: 
2968:         // We must be able to create the directory
2969:         if (!mkdir($target, FOLDER_MOD)) {
2970:             return gettext('Cannot create new theme.') . ' ' . gettext('Could not create directory for the new theme');
2971:         }
2972:         @chmod($target, FOLDER_MOD);
2973: 
2974:         // Get a list of files to copy: get all files from the directory, remove those containing '/.svn/'
2975:         $source_files = array_filter(listDirectoryFiles($source), create_function('$str', 'return strpos($str, "/.svn/") === false;'));
2976: 
2977:         // Determine nested (sub)directories structure to create: go through each file, explode path on "/"
2978:         // and collect every unique directory
2979:         $dirs_to_create = array();
2980:         foreach ($source_files as $path) {
2981:             $path = explode('/', dirname(str_replace($source . '/', '', $path)));
2982:             $dirs = '';
2983:             foreach ($path as $subdir) {
2984:                 if ($subdir == '.svn' or $subdir == '.') {
2985:                     continue 2;
2986:                 }
2987:                 $dirs = "$dirs/$subdir";
2988:                 $dirs_to_create[$dirs] = $dirs;
2989:             }
2990:         }
2991: 
2992:         // Create new directory structure
2993:         foreach ($dirs_to_create as $dir) {
2994:             mkdir("$target/$dir", FOLDER_MOD);
2995:             @chmod("$target/$dir", FOLDER_MOD);
2996:         }
2997: 
2998:         // Now copy every file
2999:         foreach ($source_files as $file) {
3000:             $newfile = str_replace($source, $target, $file);
3001:             if (!copy("$file", "$newfile"))
3002:                 return sprintf(gettext("An error occurred while copying files. Please delete manually the new theme directory “%s” and retry or copy files manually."), basename($target));
3003:             @chmod("$newfile", FOLDER_MOD);
3004:         }
3005: 
3006:         // Rewrite the theme header.
3007:         if (file_exists($target . '/theme_description.php')) {
3008:             $theme_description = array();
3009:             require($target . '/theme_description.php');
3010:             $theme_description['desc'] = sprintf(gettext('Your theme, based on theme %s'), $theme_description['name']);
3011:         } else {
3012:             $theme_description['desc'] = gettext('Your theme');
3013:         }
3014:         $theme_description['name'] = $newname;
3015:         $theme_description['author'] = $_zp_current_admin_obj->getUser();
3016:         $theme_description['version'] = '1.0';
3017:         $theme_description['date'] = date('Y-m-d H:m:s', time());
3018: 
3019:         $description = sprintf('<' . '?php
3020:                 // Zenphoto theme definition file
3021:                 $theme_description["name"] = "%s";
3022:                 $theme_description["author"] = "%s";
3023:                 $theme_description["version"] = "%s";
3024:                 $theme_description["date"] = "%s";
3025:                 $theme_description["desc"] = "%s";
3026:                 ?' . '>', html_encode($theme_description['name']), html_encode($theme_description['author']), html_encode($theme_description['version']), html_encode($theme_description['date']), html_encode($theme_description['desc']));
3027: 
3028:         $f = fopen($target . '/theme_description.php', 'w');
3029:         if ($f !== FALSE) {
3030:             @fwrite($f, $description);
3031:             fclose($f);
3032:             $message = gettext('New custom theme created successfully!');
3033:         } else {
3034:             $message = gettext('New custom theme created, but its description could not be updated');
3035:         }
3036: 
3037:         // Make a slightly custom theme image
3038:         if (file_exists("$target/theme.png"))
3039:             $themeimage = "$target/theme.png";
3040:         else if (file_exists("$target/theme.gif"))
3041:             $themeimage = "$target/theme.gif";
3042:         else if (file_exists("$target/theme.jpg"))
3043:             $themeimage = "$target/theme.jpg";
3044:         else
3045:             $themeimage = false;
3046:         if ($themeimage) {
3047:             if ($im = zp_imageGet($themeimage)) {
3048:                 $x = zp_imageWidth($im) / 2 - 45;
3049:                 $y = zp_imageHeight($im) / 2 - 10;
3050:                 $text = "CUSTOM COPY";
3051:                 $font = zp_imageLoadFont();
3052:                 $ink = zp_colorAllocate($im, 0x0ff, 0x0ff, 0x0ff);
3053:                 // create a blueish overlay
3054:                 $overlay = zp_createImage(zp_imageWidth($im), zp_imageHeight($im));
3055:                 $back = zp_colorAllocate($overlay, 0x060, 0x060, 0x090);
3056:                 zp_imageFill($overlay, 0, 0, $back);
3057:                 // Merge theme image and overlay
3058:                 zp_imageMerge($im, $overlay, 0, 0, 0, 0, zp_imageWidth($im), zp_imageHeight($im), 45);
3059:                 // Add text
3060:                 zp_writeString($im, $font, $x - 1, $y - 1, $text, $ink);
3061:                 zp_writeString($im, $font, $x + 1, $y + 1, $text, $ink);
3062:                 zp_writeString($im, $font, $x, $y, $text, $ink);
3063:                 // Save new theme image
3064:                 zp_imageOutput($im, 'png', $themeimage);
3065:             }
3066:         }
3067: 
3068:         return $message;
3069:     }
3070: 
3071:     function deleteThemeDirectory($source) {
3072:         if (is_dir($source)) {
3073:             $result = true;
3074:             $handle = opendir($source);
3075:             while (false !== ($filename = readdir($handle))) {
3076:                 $fullname = $source . '/' . $filename;
3077:                 if (is_dir($fullname)) {
3078:                     if (($filename != '.') && ($filename != '..')) {
3079:                         $result = $result && deleteThemeDirectory($fullname);
3080:                     }
3081:                 } else {
3082:                     if (file_exists($fullname)) {
3083:                         @chmod($fullname, 0777);
3084:                         $result = $result && unlink($fullname);
3085:                     }
3086:                 }
3087:             }
3088:             closedir($handle);
3089:             $result = $result && rmdir($source);
3090:             return $result;
3091:         }
3092:         return false;
3093:     }
3094: 
3095:     /**
3096:      * Return URL of current admin page
3097:      *
3098:      * @return string current URL
3099:      * @author Ozh
3100:      * @since 1.3
3101:      *
3102:      * @param string $source the script file
3103:      */
3104:     function currentRelativeURL() {
3105:         $source = str_replace(SERVERPATH, WEBPATH, str_replace('\\', '/', $_SERVER['SCRIPT_FILENAME']));
3106:         if (empty($_GET)) {
3107:             $q = '';
3108:         } else {
3109:             $q = '?' . http_build_query($_GET);
3110:         }
3111:         return pathurlencode($source) . $q;
3112:     }
3113: 
3114:     /**
3115:      * Returns an array of the names of the parents of the current album.
3116:      *
3117:      * @param object $album optional album object to use inseted of the current album
3118:      * @return array
3119:      */
3120:     function getParentAlbumsAdmin($album) {
3121:         $parents = array();
3122:         while (!is_null($album = $album->getParent())) {
3123:             array_unshift($parents, $album);
3124:         }
3125:         return $parents;
3126:     }
3127: 
3128:     function getAlbumBreadcrumbAdmin($album) {
3129:         $link = '';
3130:         $parents = getParentAlbumsAdmin($album);
3131:         foreach ($parents as $parent) {
3132:             $link .= "<a href='" . WEBPATH . '/' . ZENFOLDER . "/admin-edit.php?page=edit&amp;album=" . html_encode(pathurlencode($parent->name)) . "'>" . removeParentAlbumNames($parent) . "</a>/";
3133:         }
3134:         return $link;
3135:     }
3136: 
3137:     /**
3138:      * Removes the parent album name so that we can print a album breadcrumb with them
3139:      *
3140:      * @param object $album Object of the album
3141:      * @return string
3142:      */
3143:     function removeParentAlbumNames($album) {
3144:         $slash = stristr($album->name, "/");
3145:         if ($slash) {
3146:             $array = array_reverse(explode("/", $album->name));
3147:             $albumname = $array[0];
3148:         } else {
3149:             $albumname = $album->name;
3150:         }
3151:         return $albumname;
3152:     }
3153: 
3154:     /**
3155:      * Outputs the rights checkbox table for admin
3156:      *
3157:      * @param $id int record id for the save
3158:      * @param string $background background color
3159:      * @param string $alterrights are the items changable
3160:      * @param bit $rights rights of the admin
3161:      */
3162:     function printAdminRightsTable($id, $background, $alterrights, $rights) {
3163:         $rightslist = sortMultiArray(Zenphoto_Authority::getRights(), array('set', 'value'));
3164:         ?>
3165:         <div class="box-rights">
3166:             <strong><?php echo gettext("Rights:"); ?></strong>
3167:             <?php
3168:             $element = 3;
3169:             $activeset = false;
3170:             foreach ($rightslist as $rightselement => $right) {
3171:                 if ($right['display']) {
3172:                     if (($right['set'] != gettext('Pages') && $right['set'] != gettext('News')) || extensionEnabled('zenpage')) {
3173:                         if ($activeset != $right['set']) {
3174:                             if ($activeset) {
3175:                                 ?>
3176:                             </fieldset>
3177:                             <?php
3178:                         }
3179:                         $activeset = $right['set'];
3180:                         ?>
3181:                         <fieldset><legend><?php echo $activeset; ?></legend>
3182:                             <?php
3183:                         }
3184:                         ?>
3185:                         <label title="<?php echo html_encode(get_language_string($right['hint'])); ?>">
3186:                             <input type="checkbox" name="<?php echo $id . '-' . $rightselement; ?>" id="<?php echo $rightselement . '-' . $id; ?>" class="user-<?php echo $id; ?>"
3187:                                          value="<?php echo $right['value']; ?>"<?php
3188:                                          if ($rights & $right['value'])
3189:                                              echo ' checked="checked"';
3190:                                          echo $alterrights;
3191:                                          ?> /> <?php echo $right['name']; ?>
3192:                         </label>
3193:                         <?php
3194:                     } else {
3195:                         ?>
3196:                         <input type="hidden" name="<?php echo $id . '-' . $rightselement; ?>" id="<?php echo $rightselement . '-' . $id; ?>" value="<?php echo $right['value']; ?>" />
3197:                         <?php
3198:                     }
3199:                 }
3200:             }
3201:             ?>
3202:         </fieldset>
3203:     </div>
3204:     <?php
3205: }
3206: 
3207: /**
3208:  * Creates the managed album table for Admin
3209:  *
3210:  * @param string $type the kind of list
3211:  * @param array $objlist list of objects
3212:  * @param string $alterrights are the items changable
3213:  * @param object $userobj the user
3214:  * @param int $prefix the admin row
3215:  * @param string $kind user, group, or template
3216:  * @param array $flat items to be flagged with an asterix
3217:  */
3218: function printManagedObjects($type, $objlist, $alterrights, $userobj, $prefix_id, $kind, $flag) {
3219:     $rest = $extra = $extra2 = array();
3220:     $rights = $userobj->getRights();
3221:     $legend = '';
3222:     switch ($type) {
3223:         case 'albums':
3224:             if ($rights & (MANAGE_ALL_ALBUM_RIGHTS | ADMIN_RIGHTS)) {
3225:                 $cv = $objlist;
3226:                 $alterrights = ' disabled="disabled"';
3227:             } else {
3228:                 $full = $userobj->getObjects();
3229:                 $cv = $extra = array();
3230:                 $icon_edit_album = '<img src="' . WEBPATH . '/' . ZENFOLDER . '/images/options.png" class="icon-position-top3" alt="" title="' . gettext('edit rights') . '" />';
3231:                 $icon_view_image = '<img src="' . WEBPATH . '/' . ZENFOLDER . '/images/action.png" class="icon-position-top3" alt="" title="' . gettext('view unpublished items') . '" />';
3232:                 $icon_upload = '<img src="' . WEBPATH . '/' . ZENFOLDER . '/images/arrow_up.png" class="icon-position-top3"  alt="" title="' . gettext('upload rights') . '"/>';
3233:                 $icon_upload_disabled = '<img src="' . WEBPATH . '/' . ZENFOLDER . '/images/arrow_up.png" class="icon-position-top3"  alt="" title="' . gettext('the album is dynamic') . '"/>';
3234:                 if (!empty($flag)) {
3235:                     $legend .= '* ' . gettext('Primary album') . ' ';
3236:                 }
3237:                 $legend .= $icon_edit_album . ' ' . gettext('edit') . ' ';
3238:                 if ($rights & UPLOAD_RIGHTS)
3239:                     $legend .= $icon_upload . ' ' . gettext('upload') . ' ';
3240:                 if (!($rights & VIEW_UNPUBLISHED_RIGHTS))
3241:                     $legend .= $icon_view_image . ' ' . gettext('view unpublished') . ' ';
3242:                 foreach ($full as $item) {
3243:                     if ($item['type'] == 'album') {
3244:                         if (in_array($item['data'], $flag)) {
3245:                             $note = '*';
3246:                         } else {
3247:                             $note = '';
3248:                         }
3249:                         $cv[$item['name'] . $note] = $item['data'];
3250:                         $extra[$item['data']][] = array('name' => 'name', 'value' => $item['name'], 'display' => '', 'checked' => 0);
3251:                         $extra[$item['data']][] = array('name' => 'edit', 'value' => MANAGED_OBJECT_RIGHTS_EDIT, 'display' => $icon_edit_album, 'checked' => $item['edit'] & MANAGED_OBJECT_RIGHTS_EDIT);
3252:                         if (($rights & UPLOAD_RIGHTS)) {
3253:                             if (hasDynamicAlbumSuffix($item['data']) && !is_dir(ALBUM_FOLDER_SERVERPATH . $item['data'])) {
3254:                                 $extra[$item['data']][] = array('name' => 'upload', 'value' => MANAGED_OBJECT_RIGHTS_UPLOAD, 'display' => $icon_upload_disabled, 'checked' => 0, 'disable' => true);
3255:                             } else {
3256:                                 $extra[$item['data']][] = array('name' => 'upload', 'value' => MANAGED_OBJECT_RIGHTS_UPLOAD, 'display' => $icon_upload, 'checked' => $item['edit'] & MANAGED_OBJECT_RIGHTS_UPLOAD);
3257:                             }
3258:                         }
3259:                         if (!($rights & VIEW_UNPUBLISHED_RIGHTS)) {
3260:                             $extra[$item['data']][] = array('name' => 'view', 'value' => MANAGED_OBJECT_RIGHTS_VIEW, 'display' => $icon_view_image, 'checked' => $item['edit'] & MANAGED_OBJECT_RIGHTS_VIEW);
3261:                         }
3262:                     }
3263:                 }
3264:                 $rest = array_diff($objlist, $cv);
3265:                 foreach ($rest as $unmanaged) {
3266:                     $extra2[$unmanaged][] = array('name' => 'name', 'value' => $unmanaged, 'display' => '', 'checked' => 0);
3267:                     $extra2[$unmanaged][] = array('name' => 'edit', 'value' => MANAGED_OBJECT_RIGHTS_EDIT, 'display' => $icon_edit_album, 'checked' => 1);
3268:                     if (($rights & UPLOAD_RIGHTS)) {
3269:                         if (hasDynamicAlbumSuffix($unmanaged) && !is_dir(ALBUM_FOLDER_SERVERPATH . $unmanaged)) {
3270:                             $extra2[$unmanaged][] = array('name' => 'upload', 'value' => MANAGED_OBJECT_RIGHTS_UPLOAD, 'display' => $icon_upload_disabled, 'checked' => 0, 'disable' => true);
3271:                         } else {
3272:                             $extra2[$unmanaged][] = array('name' => 'upload', 'value' => MANAGED_OBJECT_RIGHTS_UPLOAD, 'display' => $icon_upload, 'checked' => 1);
3273:                         }
3274:                     }
3275:                     if (!($rights & VIEW_UNPUBLISHED_RIGHTS)) {
3276:                         $extra2[$unmanaged][] = array('name' => 'view', 'value' => MANAGED_OBJECT_RIGHTS_VIEW, 'display' => $icon_view_image, 'checked' => 1);
3277:                     }
3278:                 }
3279:             }
3280:             $text = gettext("Managed albums:");
3281:             $simplename = $objectname = gettext('Albums');
3282:             $prefix = 'managed_albums_list_' . $prefix_id . '_';
3283:             break;
3284:         case 'news':
3285:             if ($rights & (MANAGE_ALL_NEWS_RIGHTS | ADMIN_RIGHTS)) {
3286:                 $cv = $objlist;
3287:                 $rest = array();
3288:                 $alterrights = ' disabled="disabled"';
3289:             } else {
3290:                 $cv = $userobj->getObjects('news');
3291:                 $rest = array_diff($objlist, $cv);
3292:             }
3293:             $text = gettext("Managed news categories:");
3294:             $simplename = gettext('News');
3295:             $objectname = gettext('News categories');
3296:             $prefix = 'managed_news_list_' . $prefix_id . '_';
3297:             break;
3298:         case 'pages':
3299:             if ($rights & (MANAGE_ALL_PAGES_RIGHTS | ADMIN_RIGHTS)) {
3300:                 $cv = $objlist;
3301:                 $rest = array();
3302:                 $alterrights = ' disabled="disabled"';
3303:             } else {
3304:                 $cv = $userobj->getObjects('pages');
3305:                 $rest = array_diff($objlist, $cv);
3306:             }
3307:             $text = gettext("Managed pages:");
3308:             $simplename = $objectname = gettext('Pages');
3309:             $prefix = 'managed_pages_list_' . $prefix_id . '_';
3310:             break;
3311:     }
3312:     if (empty($alterrights)) {
3313:         $hint = sprintf(gettext('Select one or more %1$s for the %2$s to manage.'), $simplename, $kind) . ' ';
3314:         if ($kind == gettext('user')) {
3315:             $hint .= sprintf(gettext('Users with "Admin" or "Manage all %1$s" rights can manage all %2$s. All others may manage only those that are selected.'), $type, $objectname);
3316:         }
3317:     } else {
3318:         $hint = sprintf(gettext('You may manage these %s subject to the above rights.'), $simplename);
3319:     }
3320:     if (count($cv) > 0) {
3321:         $itemcount = ' (' . count($cv) . ')';
3322:     } else {
3323:         $itemcount = '';
3324:     }
3325:     ?>
3326: 
3327:     <div class="box-albums-unpadded">
3328:         <h2 class="h2_bordered_albums">
3329:             <a href="javascript:toggle('<?php echo $prefix ?>');" title="<?php echo html_encode($hint); ?>" ><?php echo $text . $itemcount; ?></a>
3330:         </h2>
3331:         <div id="<?php echo $prefix ?>" style="display:none;">
3332:             <ul class="albumchecklist">
3333:                 <?php
3334:                 generateUnorderedListFromArray($cv, $cv, $prefix, $alterrights, true, true, 'user-' . $prefix_id, $extra);
3335:                 generateUnorderedListFromArray(array(), $rest, $prefix, $alterrights, true, true, 'user-' . $prefix_id, $extra2);
3336:                 ?>
3337:             </ul>
3338:             <span class="floatright"><?php echo $legend; ?>&nbsp;&nbsp;&nbsp;&nbsp;</span>
3339:             <br class="clearall" />
3340:         </div>
3341:     </div>
3342:     <?php
3343: }
3344: 
3345: /**
3346:  * processes the post of administrator rights
3347:  *
3348:  * @param int $i the admin row number
3349:  * @return bit
3350:  */
3351: function processRights($i) {
3352:     if (isset($_POST[$i . '-confirmed'])) {
3353:         $rights = NO_RIGHTS;
3354:     } else {
3355:         $rights = 0;
3356:     }
3357:     foreach (Zenphoto_Authority::getRights() as $name => $right) {
3358:         if (isset($_POST[$i . '-' . $name])) {
3359:             $rights = $rights | $right['value'] | NO_RIGHTS;
3360:         }
3361:     }
3362:     if ($rights & MANAGE_ALL_ALBUM_RIGHTS) { // these are lock-step linked!
3363:         $rights = $rights | ALL_ALBUMS_RIGHTS | ALBUM_RIGHTS;
3364:     }
3365:     if ($rights & MANAGE_ALL_NEWS_RIGHTS) { // these are lock-step linked!
3366:         $rights = $rights | ALL_NEWS_RIGHTS | ZENPAGE_NEWS_RIGHTS;
3367:     }
3368:     if ($rights & MANAGE_ALL_PAGES_RIGHTS) { // these are lock-step linked!
3369:         $rights = $rights | ALL_PAGES_RIGHTS | ZENPAGE_PAGES_RIGHTS;
3370:     }
3371:     return $rights;
3372: }
3373: 
3374: function processManagedObjects($i, &$rights) {
3375:     $objects = array();
3376:     $albums = array();
3377:     $pages = array();
3378:     $news = array();
3379:     $l_a = strlen($prefix_a = 'managed_albums_list_' . $i . '_');
3380:     $l_p = strlen($prefix_p = 'managed_pages_list_' . $i . '_');
3381:     $l_n = strlen($prefix_n = 'managed_news_list_' . $i . '_');
3382:     foreach ($_POST as $key => $value) {
3383:         $key = postIndexDecode($key);
3384:         if (substr($key, 0, $l_a) == $prefix_a) {
3385:             $key = substr($key, $l_a);
3386:             if (preg_match('/(.*)(_edit|_view|_upload|_name)$/', $key, $matches)) {
3387:                 $key = $matches[1];
3388:                 if (array_key_exists($key, $albums)) {
3389:                     switch ($matches[2]) {
3390:                         case '_edit':
3391:                             $albums[$key]['edit'] = $albums[$key]['edit'] | MANAGED_OBJECT_RIGHTS_EDIT;
3392:                             break;
3393:                         case '_upload':
3394:                             $albums[$key]['edit'] = $albums[$key]['edit'] | MANAGED_OBJECT_RIGHTS_UPLOAD;
3395:                             break;
3396:                         case '_view':
3397:                             $albums[$key]['edit'] = $albums[$key]['edit'] | MANAGED_OBJECT_RIGHTS_VIEW;
3398:                             break;
3399:                         case '_name':
3400:                             $albums[$key]['name'] = $value;
3401:                             break;
3402:                     }
3403:                 }
3404:             } else if ($value) {
3405:                 $albums[$key] = array('data' => $key, 'name' => '', 'type' => 'album', 'edit' => 32767 & ~(MANAGED_OBJECT_RIGHTS_EDIT | MANAGED_OBJECT_RIGHTS_UPLOAD | MANAGED_OBJECT_RIGHTS_VIEW));
3406:             }
3407:         }
3408:         if (substr($key, 0, $l_p) == $prefix_p) {
3409:             if ($value) {
3410:                 $pages[] = array('data' => substr($key, $l_p), 'type' => 'pages');
3411:             }
3412:         }
3413:         if (substr($key, 0, $l_n) == $prefix_n) {
3414:             if ($value) {
3415:                 $news[] = array('data' => substr($key, $l_n), 'type' => 'news');
3416:             }
3417:         }
3418:     }
3419:     foreach ($albums as $key => $analbum) {
3420:         unset($albums[$key]);
3421:         $albums[] = $analbum;
3422:     }
3423:     if (empty($albums)) {
3424:         if (!($rights & MANAGE_ALL_ALBUM_RIGHTS)) {
3425:             $rights = $rights & ~ALBUM_RIGHTS;
3426:         }
3427:     } else {
3428:         $rights = $rights | ALBUM_RIGHTS;
3429:         if ($rights & (MANAGE_ALL_ALBUM_RIGHTS | ADMIN_RIGHTS)) {
3430:             $albums = array();
3431:         }
3432:     }
3433:     if (empty($pages)) {
3434:         if (!($rights & MANAGE_ALL_PAGES_RIGHTS)) {
3435:             $rights = $rights & ~ZENPAGE_PAGES_RIGHTS;
3436:         }
3437:     } else {
3438:         $rights = $rights | ZENPAGE_PAGES_RIGHTS;
3439:         if ($rights & (MANAGE_ALL_PAGES_RIGHTS | ADMIN_RIGHTS)) {
3440:             $pages = array();
3441:         }
3442:     }
3443:     if (empty($news)) {
3444:         if (!($rights & MANAGE_ALL_NEWS_RIGHTS)) {
3445:             $rights = $rights & ~ZENPAGE_NEWS_RIGHTS;
3446:         }
3447:     } else {
3448:         $rights = $rights | ZENPAGE_NEWS_RIGHTS;
3449:         if ($rights & (MANAGE_ALL_NEWS_RIGHTS | ADMIN_RIGHTS)) {
3450:             $news = array();
3451:         }
3452:     }
3453:     $objects = array_merge($albums, $pages, $news);
3454:     return $objects;
3455: }
3456: 
3457: /**
3458:  * Returns the value of a checkbox form item
3459:  *
3460:  * @param string $id the $_REQUEST index
3461:  * @return int (0 or 1)
3462:  */
3463: function getCheckboxState($id) {
3464:     if (isset($_REQUEST[$id]))
3465:         return 1;
3466:     else
3467:         return 0;
3468: }
3469: 
3470: /**
3471:  * Returns an array of "standard" theme scripts. This list is
3472:  * normally used to exclude these scripts form various option seletors.
3473:  *
3474:  * @return array
3475:  */
3476: function standardScripts() {
3477:     $standardlist = array('themeoptions', 'password', 'theme_description', '404', 'slideshow', 'search', 'image', 'index', 'album', 'customfunctions', 'functions');
3478:     if (extensionEnabled('zenpage'))
3479:         $standardlist = array_merge($standardlist, array('news', 'pages'));
3480:     return $standardlist;
3481: }
3482: 
3483: /**
3484:  * Returns a merged list of available watermarks
3485:  *
3486:  * @return array
3487:  */
3488: function getWatermarks() {
3489:     $list = array();
3490:     $curdir = getcwd();
3491:     chdir($basepath = SERVERPATH . "/" . ZENFOLDER . '/watermarks/');
3492:     $filelist = safe_glob('*.png');
3493:     foreach ($filelist as $file) {
3494:         $list[filesystemToInternal(substr(basename($file), 0, -4))] = $basepath . $file;
3495:     }
3496:     $basepath = SERVERPATH . "/" . USER_PLUGIN_FOLDER . '/watermarks/';
3497:     if (is_dir($basepath)) {
3498:         chdir($basepath);
3499:         $filelist = safe_glob('*.png');
3500:         foreach ($filelist as $file) {
3501:             $list[filesystemToInternal(substr(basename($file), 0, -4))] = $basepath . $file;
3502:         }
3503:     }
3504:     chdir($curdir);
3505:     $watermarks = array_keys($list);
3506:     return $watermarks;
3507: }
3508: 
3509: /**
3510:  * Processes the serialized array from tree sort.
3511:  * Returns an array in the form [$id=>array(sort orders), $id=>array(sort orders),...]
3512:  *
3513:  * @param $orderstr the serialzied tree sort order
3514:  * @return array
3515:  */
3516: function processOrder($orderstr) {
3517:     $order = $result = array();
3518:     parse_str($orderstr, $order);
3519:     $order = array_shift($order);
3520: 
3521:     $parents = $curorder = array();
3522:     $curowner = '';
3523:     foreach ($order as $id => $parent) { // get the root elements
3524:         if ($parent != $curowner) {
3525:             if (($key = array_search($parent, $parents)) === false) { //    a child
3526:                 array_push($parents, $parent);
3527:                 array_push($curorder, -1);
3528:             } else { // roll back to parent
3529:                 $parents = array_slice($parents, 0, $key + 1);
3530:                 $curorder = array_slice($curorder, 0, $key + 1);
3531:             }
3532:         }
3533:         $l = count($curorder) - 1;
3534:         $curorder[$l] = sprintf('%03u', $curorder[$l] + 1);
3535:         $result[$id] = $curorder;
3536:     }
3537:     return $result;
3538: }
3539: 
3540: /**
3541:  * POST handler for album tree sorts
3542:  *
3543:  * @param int $parentid id of owning album
3544:  *
3545:  */
3546: function postAlbumSort($parentid) {
3547:   if (isset($_POST['order']) && !empty($_POST['order'])) {
3548:     $order = processOrder(sanitize($_POST['order']));
3549:     $sortToID = array();
3550:     foreach ($order as $id => $orderlist) {
3551:       $id = str_replace('id_', '', $id);
3552:       $sortToID[implode('-', $orderlist)] = $id;
3553:     }
3554:     foreach ($order as $item => $orderlist) {
3555:       $item = str_replace('id_', '', $item);
3556:       $currentalbum = query_single_row('SELECT * FROM ' . prefix('albums') . ' WHERE `id`=' . $item);
3557:       $sortorder = array_pop($orderlist);
3558:       if (count($orderlist) > 0) {
3559:         $newparent = $sortToID[implode('-', $orderlist)];
3560:       } else {
3561:         $newparent = $parentid;
3562:       }
3563:       if ($newparent == $currentalbum['parentid']) {
3564:         $sql = 'UPDATE ' . prefix('albums') . ' SET `sort_order`=' . db_quote($sortorder) . ' WHERE `id`=' . $item;
3565:         query($sql);
3566:       } else { // have to do a move
3567:         $albumname = $currentalbum['folder'];
3568:         $album = newAlbum($albumname);
3569:         if (strpos($albumname, '/') !== false) {
3570:           $albumname = basename($albumname);
3571:         }
3572:         if (is_null($newparent)) {
3573:           $dest = $albumname;
3574:         } else {
3575:           $parent = query_single_row('SELECT * FROM ' . prefix('albums') . ' WHERE `id`=' . $newparent);
3576:           if ($parent['dynamic']) {
3577:             return "&mcrerr=5";
3578:           } else {
3579:             $dest = $parent['folder'] . '/' . $albumname;
3580:           }
3581:         }
3582:         if ($e = $album->move($dest)) {
3583:           return "&mcrerr=" . $e;
3584:         } else {
3585:           $album->setSortOrder($sortorder);
3586:           $album->save();
3587:         }
3588:       }
3589:     }
3590:     return true;
3591:   }
3592:   return false;
3593: }
3594: 
3595: /**
3596:  * Prints the sortable nested albums list
3597:  * returns true if nesting levels exceede the database container
3598:  *
3599:  * @param array $pages The array containing all pages
3600:  * @param bool $show_thumb set false to use thumb standin image.
3601:  * @param object $owner the album object of the owner or NULL for the gallery
3602:  *
3603:  * @return bool
3604:  */
3605: function printNestedAlbumsList($albums, $show_thumb, $owner) {
3606:     $indent = 1;
3607:     $open = array(1 => 0);
3608:     $rslt = false;
3609:     foreach ($albums as $album) {
3610:         $order = $album['sort_order'];
3611:         $level = max(1, count($order));
3612:         if ($toodeep = $level > 1 && $order[$level - 1] === '') {
3613:             $rslt = true;
3614:         }
3615:         if ($level > $indent) {
3616:             echo "\n" . str_pad("\t", $indent, "\t") . "<ul class=\"page-list\">\n";
3617:             $indent++;
3618:             $open[$indent] = 0;
3619:         } else if ($level < $indent) {
3620:             while ($indent > $level) {
3621:                 $open[$indent] --;
3622:                 $indent--;
3623:                 echo "</li>\n" . str_pad("\t", $indent, "\t") . "</ul>\n";
3624:             }
3625:         } else { // indent == level
3626:             if ($open[$indent]) {
3627:                 echo str_pad("\t", $indent, "\t") . "</li>\n";
3628:                 $open[$indent] --;
3629:             } else {
3630:                 echo "\n";
3631:             }
3632:         }
3633:         if ($open[$indent]) {
3634:             echo str_pad("\t", $indent, "\t") . "</li>\n";
3635:             $open[$indent] --;
3636:         }
3637:         $albumobj = newAlbum($album['name']);
3638:         if ($albumobj->isDynamic()) {
3639:             $nonest = ' class="no-nest"';
3640:         } else {
3641:             $nonest = '';
3642:         }
3643:         echo str_pad("\t", $indent - 1, "\t") . "<li id=\"id_" . $albumobj->getID() . "\"$nonest >";
3644:         printAlbumEditRow($albumobj, $show_thumb, $owner);
3645:         $open[$indent] ++;
3646:     }
3647:     while ($indent > 1) {
3648:         echo "</li>\n";
3649:         $open[$indent] --;
3650:         $indent--;
3651:         echo str_pad("\t", $indent, "\t") . "</ul>";
3652:     }
3653:     if ($open[$indent]) {
3654:         echo "</li>\n";
3655:     } else {
3656:         echo "\n";
3657:     }
3658:     return $rslt;
3659: }
3660: 
3661: /**
3662:  * Prints the dropdown menu for the nesting level depth for the album sorting
3663:  *
3664:  */
3665: function printEditDropdown($subtab, $nestinglevels, $nesting) {
3666:     switch ($subtab) {
3667:         case '':
3668:             $link = '?selection=';
3669:             break;
3670:         case 'subalbuminfo':
3671:             $link = '?page=edit&amp;album=' . html_encode($_GET['album']) . '&amp;tab=subalbuminfo&amp;selection=';
3672:             break;
3673:         case 'imageinfo':
3674:             if (isset($_GET['tagsort'])) {
3675:                 $tagsort = '&tagsort=' . sanitize($_GET['tagsort']);
3676:             } else {
3677:                 $tagsort = '';
3678:             }
3679:             $link = '?page=edit&amp;album=' . html_encode($_GET['album']) . '&amp;tab=imageinfo' . html_encode($tagsort) . '&amp;selection=';
3680:             break;
3681:     }
3682:     ?>
3683:     <form name="AutoListBox2" style="float: right;" action="#" >
3684:         <select name="ListBoxURL" size="1" onchange="gotoLink(this.form);">
3685:             <?php
3686:             foreach ($nestinglevels as $nestinglevel) {
3687:                 if ($nesting == $nestinglevel) {
3688:                     $selected = 'selected="selected"';
3689:                 } else {
3690:                     $selected = "";
3691:                 }
3692:                 echo '<option ' . $selected . ' value="admin-edit.php' . $link . $nestinglevel . '">';
3693:                 switch ($subtab) {
3694:                     case '':
3695:                     case 'subalbuminfo':
3696:                         printf(ngettext('Show %u album level', 'Show %u album levels', $nestinglevel), $nestinglevel);
3697:                         break;
3698:                     case 'imageinfo':
3699:                         printf(ngettext('%u image per page', '%u images per page', $nestinglevel), $nestinglevel);
3700:                         break;
3701:                 }
3702:                 echo '</option>';
3703:             }
3704:             ?>
3705:         </select>
3706:         <script type="text/javascript" >
3707:             // <!-- <![CDATA[
3708:             function gotoLink(form) {
3709:                 var OptionIndex = form.ListBoxURL.selectedIndex;
3710:                 parent.location = form.ListBoxURL.options[OptionIndex].value;
3711:             }
3712:             // ]]> -->
3713:         </script>
3714:     </form>
3715:     <?php
3716: }
3717: 
3718: function processEditSelection($subtab) {
3719:     global $subalbum_nesting, $album_nesting, $imagesTab_imageCount;
3720:     if (isset($_GET['selection'])) {
3721:         switch ($subtab) {
3722:             case '':
3723:                 $album_nesting = max(1, sanitize_numeric($_GET['selection']));
3724:                 zp_setCookie('gallery_nesting', $album_nesting);
3725:                 break;
3726:             case 'subalbuminfo':
3727:                 $subalbum_nesting = max(1, sanitize_numeric($_GET['selection']));
3728:                 zp_setCookie('subalbum_nesting', $subalbum_nesting);
3729:                 break;
3730:             case 'imageinfo':
3731:                 $imagesTab_imageCount = max(ADMIN_IMAGES_STEP, sanitize_numeric($_GET['selection']));
3732:                 zp_setCookie('imagesTab_imageCount', $imagesTab_imageCount);
3733:                 break;
3734:         }
3735:     } else {
3736:         switch ($subtab) {
3737:             case '':
3738:                 $album_nesting = zp_getCookie('gallery_nesting');
3739:                 break;
3740:             case 'subalbuminfo':
3741:                 $subalbum_nesting = zp_getCookie('subalbum_nesting');
3742:                 break;
3743:             case 'imageinfo':
3744:                 $count = zp_getCookie('imagesTab_imageCount');
3745:                 if ($count)
3746:                     $imagesTab_imageCount = $count;
3747:                 break;
3748:         }
3749:     }
3750: }
3751: 
3752: /**
3753:  * Edit tab bulk actions drop-down
3754:  * @param array $checkarray the list of actions
3755:  * @param bool $checkAll set true to include check all box
3756:  */
3757: function printBulkActions($checkarray, $checkAll = false) {
3758:     $tags = in_array('addtags', $checkarray) || in_array('alltags', $checkarray);
3759:     $movecopy = in_array('moveimages', $checkarray) || in_array('copyimages', $checkarray);
3760:     $categories = in_array('addcats', $checkarray) || in_array('clearcats', $checkarray);
3761:     $changeowner = in_array('changeowner', $checkarray);
3762:     if ($tags || $movecopy || $categories || $changeowner) {
3763:         ?>
3764:         <script type="text/javascript">
3765:             //<!-- <![CDATA[
3766:             function checkFor(obj) {
3767:                 var sel = obj.options[obj.selectedIndex].value;
3768:         <?php
3769:         if ($tags) {
3770:             ?>
3771:                     if (sel == 'addtags' || sel == 'alltags') {
3772:                         $.colorbox({
3773:                             href: "#mass_tags_data",
3774:                             inline: true,
3775:                             open: true,
3776:                             close: '<?php echo gettext("ok"); ?>'
3777:                         });
3778:                     }
3779:             <?php
3780:         }
3781:         if ($movecopy) {
3782:             ?>
3783:                     if (sel == 'moveimages' || sel == 'copyimages') {
3784:                         $.colorbox({
3785:                             href: "#mass_movecopy_data",
3786:                             inline: true,
3787:                             open: true,
3788:                             close: '<?php echo gettext("ok"); ?>'
3789:                         });
3790:                     }
3791:             <?php
3792:         }
3793:         if ($categories) {
3794:             ?>
3795:                     if (sel == 'addcats') {
3796:                         $.colorbox({
3797:                             href: "#mass_cats_data",
3798:                             inline: true,
3799:                             open: true,
3800:                             close: '<?php echo gettext("ok"); ?>'
3801:                         });
3802:                     }
3803:             <?php
3804:         }
3805:         if ($changeowner) {
3806:             ?>
3807:                     if (sel == 'changeowner') {
3808:                         $.colorbox({
3809:                             href: "#mass_owner_data",
3810:                             inline: true,
3811:                             open: true,
3812:                             close: '<?php echo gettext("ok"); ?>'
3813:                         });
3814:                     }
3815:             <?php
3816:         }
3817:         ?>
3818:             }
3819:             // ]]> -->
3820:         </script>
3821:         <?php
3822:     }
3823:     ?>
3824:     <span style="float:right">
3825:         <select class="dirtyignore" name="checkallaction" id="checkallaction" size="1" onchange="checkFor(this);" >
3826:             <?php generateListFromArray(array('noaction'), $checkarray, false, true); ?>
3827:         </select>
3828:         <?php
3829:         if ($checkAll) {
3830:             ?>
3831:             <br />
3832:             <?php
3833:             echo gettext("Check All");
3834:             ?>
3835:             <input class="dirtyignore" type="checkbox" name="allbox" id="allbox" onclick="checkAll(this.form, 'ids[]', this.checked);" />
3836:             <?php
3837:         }
3838:         ?>
3839:     </span>
3840:     <?php
3841:     if ($tags) {
3842:         ?>
3843:         <div id="mass_tags" style="display:none;">
3844:             <div id="mass_tags_data">
3845:                 <?php
3846:                 tagSelector(NULL, 'mass_tags_', false, false, true, false, 'checkTagsAuto dirtyignore');
3847:                 ?>
3848:             </div>
3849:         </div>
3850:         <?php
3851:     }
3852:     if ($categories) {
3853:         ?>
3854:         <div id="mass_cats" style="display:none;">
3855:             <ul id="mass_cats_data">
3856:                 <?php
3857:                 printNestedItemsList('cats-checkboxlist', '', 'all', 'dirtyignore');
3858:                 ?>
3859:             </ul>
3860:         </div>
3861:         <?php
3862:     }
3863:     if ($changeowner) {
3864:         ?>
3865:         <div id="mass_owner" style="display:none;">
3866:             <ul id="mass_owner_data">
3867:                 <select class="dirtyignore" id="massownermenu" name="massownerselect" onchange="">
3868:                     <?php
3869:                     echo admin_album_list(NULL);
3870:                     ?>
3871:                 </select>
3872:             </ul>
3873:         </div>
3874:         <?php
3875:     }
3876:     if ($movecopy) {
3877:         global $mcr_albumlist, $album, $bglevels;
3878:         ?>
3879:         <div id="mass_movecopy_copy" style="display:none;">
3880:             <div id="mass_movecopy_data">
3881:                 <input type="hidden" name="massfolder" value="<?php echo $album->name; ?>" />
3882:                 <?php
3883:                 echo gettext('Destination');
3884:                 ?>
3885:                 <select class="dirtyignore" id="massalbumselectmenu" name="massalbumselect" onchange="">
3886:                     <?php
3887:                     foreach ($mcr_albumlist as $fullfolder => $albumtitle) {
3888:                         $singlefolder = $fullfolder;
3889:                         $saprefix = "";
3890:                         $salevel = 0;
3891:                         $selected = "";
3892:                         if ($album->name == $fullfolder) {
3893:                             $selected = " selected=\"selected\" ";
3894:                         }
3895:                         // Get rid of the slashes in the subalbum, while also making a subalbum prefix for the menu.
3896:                         while (strstr($singlefolder, '/') !== false) {
3897:                             $singlefolder = substr(strstr($singlefolder, '/'), 1);
3898:                             $saprefix = "&nbsp; &nbsp;&nbsp;" . $saprefix;
3899:                             $salevel++;
3900:                         }
3901:                         echo '<option value="' . $fullfolder . '"' . ($salevel > 0 ? ' style="background-color: ' . $bglevels[$salevel] . ';"' : '')
3902:                         . "$selected>" . $saprefix . $singlefolder . "</option>\n";
3903:                     }
3904:                     ?>
3905:                 </select>
3906:             </div>
3907:         </div>
3908:         <?php
3909:     }
3910: }
3911: 
3912: /**
3913:  *
3914:  * common redirector for bulk action handling return
3915:  * @param string $action
3916:  */
3917: function bulkActionRedirect($action) {
3918:     $uri = getRequestURI();
3919:     if (strpos($uri, '?')) {
3920:         $uri .= '&bulkaction=' . $action;
3921:     } else {
3922:         $uri .= '?bulkaction=' . $action;
3923:     }
3924:     header('Location: ' . $uri);
3925:     exitZP();
3926: }
3927: 
3928: /**
3929:  * Process the bulk tags
3930:  *
3931:  * @return array
3932:  */
3933: function bulkTags() {
3934:     $tags = array();
3935:     foreach ($_POST as $key => $value) {
3936:         $key = postIndexDecode($key);
3937:         if ($value && substr($key, 0, 10) == 'mass_tags_') {
3938:             $tags[] = sanitize(substr($key, 10));
3939:         }
3940:     }
3941:     return $tags;
3942: }
3943: 
3944: /**
3945:  * Processes the check box bulk actions for albums
3946:  *
3947:  */
3948: function processAlbumBulkActions() {
3949:     if (isset($_POST['ids'])) {
3950:         $ids = sanitize($_POST['ids']);
3951:         $action = sanitize($_POST['checkallaction']);
3952:         $total = count($ids);
3953:         if ($action != 'noaction' && $total > 0) {
3954:             if ($action == 'addtags' || $action == 'alltags') {
3955:                 $tags = bulkTags();
3956:             }
3957:             if ($action == 'changeowner') {
3958:                 $newowner = sanitize($_POST['massownerselect']);
3959:             }
3960:             $n = 0;
3961:             foreach ($ids as $albumname) {
3962:                 $n++;
3963:                 $albumobj = newAlbum($albumname);
3964:                 switch ($action) {
3965:                     case 'deleteallalbum':
3966:                         $albumobj->remove();
3967:                         SearchEngine::clearSearchCache();
3968:                         break;
3969:                     case 'showall':
3970:                         $albumobj->setShow(1);
3971:                         break;
3972:                     case 'hideall':
3973:                         $albumobj->setShow(0);
3974:                         break;
3975:                     case 'commentson':
3976:                         $albumobj->setCommentsAllowed(1);
3977:                         break;
3978:                     case 'commentsoff':
3979:                         $albumobj->setCommentsAllowed(0);
3980:                         break;
3981:                     case 'resethitcounter':
3982:                         $albumobj->set('hitcounter', 0);
3983:                         break;
3984:                     case 'addtags':
3985:                         $mytags = array_unique(array_merge($tags, $albumobj->getTags()));
3986:                         $albumobj->setTags($mytags);
3987:                         break;
3988:                     case 'cleartags':
3989:                         $albumobj->setTags(array());
3990:                         break;
3991:                     case 'alltags':
3992:                         $images = $albumobj->getImages();
3993:                         foreach ($images as $imagename) {
3994:                             $imageobj = newImage($albumobj, $imagename);
3995:                             $mytags = array_unique(array_merge($tags, $imageobj->getTags()));
3996:                             $imageobj->setTags($mytags);
3997:                             $imageobj->save();
3998:                         }
3999:                         break;
4000:                     case 'clearalltags':
4001:                         $images = $albumobj->getImages();
4002:                         foreach ($images as $imagename) {
4003:                             $imageobj = newImage($albumobj, $imagename);
4004:                             $imageobj->setTags(array());
4005:                             $imageobj->save();
4006:                         }
4007:                         break;
4008:                     case 'changeowner':
4009:                         $albumobj->setOwner($newowner);
4010:                         break;
4011:                     default:
4012:                         $action = call_user_func($action, $albumobj);
4013:                         break;
4014:                 }
4015:                 $albumobj->save();
4016:             }
4017:             return $action;
4018:         }
4019:     }
4020:     return false;
4021: }
4022: 
4023: /**
4024:  * Handles Image bulk actions
4025:  * @param $album
4026:  */
4027: function processImageBulkActions($album) {
4028:     $action = sanitize($_POST['checkallaction']);
4029:     $ids = sanitize($_POST['ids']);
4030:     $total = count($ids);
4031:     if ($action != 'noaction') {
4032:         if ($total > 0) {
4033:             if ($action == 'addtags') {
4034:                 $tags = bulkTags();
4035:             }
4036:             if ($action == 'moveimages' || $action == 'copyimages') {
4037:                 $dest = sanitize($_POST['massalbumselect']);
4038:                 $folder = sanitize($_POST['massfolder']);
4039:                 if (!$dest || $dest == $folder) {
4040:                     return "&mcrerr=2";
4041:                 }
4042:             }
4043:             if ($action == 'changeowner') {
4044:                 $newowner = sanitize($_POST['massownerselect']);
4045:             }
4046:             $n = 0;
4047:             foreach ($ids as $filename) {
4048:                 $n++;
4049:                 $imageobj = newImage($album, $filename);
4050:                 switch ($action) {
4051:                     case 'deleteall':
4052:                         $imageobj->remove();
4053:                         SearchEngine::clearSearchCache();
4054:                         break;
4055:                     case 'showall':
4056:                         $imageobj->set('show', 1);
4057:                         break;
4058:                     case 'hideall':
4059:                         $imageobj->set('show', 0);
4060:                         break;
4061:                     case 'commentson':
4062:                         $imageobj->set('commentson', 1);
4063:                         break;
4064:                     case 'commentsoff':
4065:                         $imageobj->set('commentson', 0);
4066:                         break;
4067:                     case 'resethitcounter':
4068:                         $imageobj->set('hitcounter', 0);
4069:                         break;
4070:                     case 'addtags':
4071:                         $mytags = array_unique(array_merge($tags, $imageobj->getTags()));
4072:                         $imageobj->setTags($mytags);
4073:                         break;
4074:                     case 'cleartags':
4075:                         $imageobj->setTags(array());
4076:                         break;
4077:                     case 'copyimages':
4078:                         if ($e = $imageobj->copy($dest)) {
4079:                             return "&mcrerr=" . $e;
4080:                         }
4081:                         break;
4082:                     case 'moveimages':
4083:                         if ($e = $imageobj->move($dest)) {
4084:                             SearchEngine::clearSearchCache();
4085:                             return "&mcrerr=" . $e;
4086:                         }
4087:                         break;
4088:                     case 'changeowner':
4089:                         $imageobj->setOwner($newowner);
4090:                         break;
4091:                     default:
4092:                         $action = call_user_func($action, $imageobj);
4093:                         break;
4094:                 }
4095:                 $imageobj->save();
4096:             }
4097:         }
4098:         return $action;
4099:     }
4100: }
4101: 
4102: /**
4103:  * Processes the check box bulk actions for comments
4104:  *
4105:  */
4106: function processCommentBulkActions() {
4107:     if (isset($_POST['ids'])) { // these is actually the folder name here!
4108:         $action = sanitize($_POST['checkallaction']);
4109:         if ($action != 'noaction') {
4110:             $ids = sanitize($_POST['ids']);
4111:             if (count($ids) > 0) {
4112:                 foreach ($ids as $id) {
4113:                     $comment = new Comment(sanitize_numeric($id));
4114:                     switch ($action) {
4115:                         case 'deleteall':
4116:                             $comment->remove();
4117:                             break;
4118:                         case 'spam':
4119:                             if (!$comment->getInModeration()) {
4120:                                 $comment->setInModeration(1);
4121:                                 zp_apply_filter('comment_disapprove', $comment);
4122:                             }
4123:                             break;
4124:                         case 'approve':
4125:                             if ($comment->getInModeration()) {
4126:                                 $comment->setInModeration(0);
4127:                                 zp_apply_filter('comment_approve', $comment);
4128:                             }
4129:                             break;
4130:                     }
4131:                     $comment->save();
4132:                 }
4133:             }
4134:         }
4135:     }
4136:     return $action;
4137: }
4138: 
4139: /**
4140:  * Codeblock tabs JavaScript code
4141:  *
4142:  */
4143: function codeblocktabsJS() {
4144:     ?>
4145:     <script type="text/javascript" charset="utf-8">
4146:         // <!-- <![CDATA[
4147:         $(function() {
4148:             var tabContainers = $('div.tabs > div');
4149:             $('.first').addClass('selected');
4150:         });
4151: 
4152:         function cbclick(num, id) {
4153:             $('.cbx-' + id).hide();
4154:             $('#cb' + num + '-' + id).show();
4155:             $('.cbt-' + id).removeClass('selected');
4156:             $('#cbt' + num + '-' + id).addClass('selected');
4157:         }
4158: 
4159:         function cbadd(id, offset) {
4160:             var num = $('#cbu-' + id + ' li').size() - offset;
4161:             $('li:last', $('#cbu-' + id)).remove();
4162:             $('#cbu-' + id).append('<li><a class="cbt-' + id + '" id="cbt' + num + '-' + id + '" href="javascript:cbclick(' + num + ',' + id + ');" title="' + '<?php echo gettext('codeblock %u'); ?>'.replace(/%u/, num) + '">&nbsp;&nbsp;' + num + '&nbsp;&nbsp;</a></li>');
4163:             $('#cbu-' + id).append('<li><a id="cbp-' + id + '" href="javascript:cbadd(' + id + ',' + offset + ');" title="<?php echo gettext('add codeblock'); ?>">&nbsp;&nbsp;+&nbsp;&nbsp;</a></li>');
4164:             $('#cbd-' + id).append('<div class="cbx-' + id + '" id="cb' + num + '-' + id + '" style="display:none">' +
4165:                             '<textarea name="codeblock' + num + '-' + id + '" class="codeblock" id="codeblock' + num + '-' + id + '" rows="40" cols="60"></textarea>' +
4166:                             '</div>');
4167:             cbclick(num, id);
4168:         }
4169:         // ]]> -->
4170:     </script>
4171:     <?php
4172: }
4173: 
4174: /**
4175:  *
4176:  * prints codeblock edit boxes
4177:  * @param object $obj
4178:  * @param int $id
4179:  */
4180: function printCodeblockEdit($obj, $id) {
4181:     $codeblock = getSerializedArray($obj->getCodeblock());
4182:     $keys = array_keys($codeblock);
4183:     array_push($keys, 1);
4184:     $codeblockCount = max($keys) + 1;
4185: 
4186:     if (array_key_exists(0, $codeblock) && !empty($codeblock)) {
4187:         $start = 0;
4188:     } else {
4189:         $start = (int) getOption('codeblock_first_tab');
4190:     }
4191:     ?>
4192:     <div id="cbd-<?php echo $id; ?>" class="tabs">
4193:         <ul id="<?php echo 'cbu' . '-' . $id; ?>" class="tabNavigation">
4194:             <?php
4195:             for ($i = $start; $i < $codeblockCount; $i++) {
4196:                 ?>
4197:                 <li><a class="<?php if ($i == 1) echo 'first '; ?>cbt-<?php echo $id; ?>" id="<?php echo 'cbt' . $i . '-' . $id; ?>" href="javascript:cbclick(<?php echo $i . ',' . $id; ?>);" title="<?php printf(gettext('codeblock %u'), $i); ?>">&nbsp;&nbsp;<?php echo $i; ?>&nbsp;&nbsp;</a></li>
4198:                 <?php
4199:             }
4200:             if (zp_loggedin(CODEBLOCK_RIGHTS)) {
4201:                 $disabled = '';
4202:                 ?>
4203:                 <li><a id="<?php echo 'cbp' . '-' . $id; ?>" href="javascript:cbadd(<?php echo $id; ?>,<?php echo 1 - $start; ?>);" title="<?php echo gettext('add codeblock'); ?>">&nbsp;&nbsp;+&nbsp;&nbsp;</a></li>
4204:                 <?php
4205:             } else {
4206:                 $disabled = ' disabled="disabled"';
4207:             }
4208:             ?>
4209:         </ul>
4210: 
4211:         <?php
4212:         for ($i = $start; $i < $codeblockCount; $i++) {
4213:             ?>
4214:             <div class="cbx-<?php echo $id; ?>" id="cb<?php echo $i . '-' . $id; ?>"<?php if ($i != 1) echo ' style="display:none"'; ?>>
4215:                 <?php
4216:                 if (!$i) {
4217:                     ?>
4218:                     <span class="notebox"><?php echo gettext('Codeblock 0 is deprecated.') ?></span>
4219:                     <?php
4220:                 }
4221:                 ?>
4222:                 <textarea name="codeblock<?php echo $i; ?>-<?php echo $id; ?>" class="codeblock" id="codeblock<?php echo $i; ?>-<?php echo $id; ?>" rows="40" cols="60"<?php echo $disabled; ?>><?php echo html_encode(@$codeblock[$i]); ?></textarea>
4223:             </div>
4224:             <?php
4225:         }
4226:         ?>
4227:     </div>
4228:     <?php
4229: }
4230: 
4231: /**
4232:  *
4233:  * handles saveing of codeblock edits
4234:  * @param object $object
4235:  * @param int $id
4236:  * @return string
4237:  */
4238: function processCodeblockSave($id) {
4239:     $codeblock = array();
4240:     $i = (int) !isset($_POST['codeblock0-' . $id]);
4241:     while (isset($_POST['codeblock' . $i . '-' . $id])) {
4242:         $v = sanitize($_POST['codeblock' . $i . '-' . $id], 0);
4243:         if ($v) {
4244:             $codeblock[$i] = $v;
4245:         }
4246:         $i++;
4247:     }
4248:     return serialize($codeblock);
4249: }
4250: 
4251: /**
4252:  * Standard admin pages checks
4253:  * @param bit $rights
4254:  * @param string $return--where to go after login
4255:  */
4256: function admin_securityChecks($rights, $return) {
4257:     global $_zp_current_admin_obj, $_zp_loggedin;
4258:     checkInstall();
4259:     httpsRedirect();
4260: 
4261:     if ($_zp_current_admin_obj && $_zp_current_admin_obj->reset) {
4262:         $_zp_loggedin = USER_RIGHTS;
4263:     }
4264:     if (!zp_loggedin($rights)) {
4265:         // prevent nefarious access to this page.
4266:         $returnurl = urldecode($return);
4267:         if (!zp_apply_filter('admin_allow_access', false, $returnurl)) {
4268:             $uri = explode('?', $returnurl);
4269:             header("HTTP/1.0 302 Found");
4270:             header("Status: 302 Found");
4271:             header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin.php?from=' . $uri[0]);
4272:             exitZP();
4273:         }
4274:     }
4275: }
4276: 
4277: /**
4278:  *
4279:  * Checks if protocol not https and redirects if https required
4280:  */
4281: function httpsRedirect() {
4282:     if (SERVER_PROTOCOL == 'https_admin') {
4283:         // force https login
4284:         if (!isset($_SERVER["HTTPS"])) {
4285:             $redirect = "https://" . $_SERVER['HTTP_HOST'] . getRequestURI();
4286:             header("Location:$redirect");
4287:             exitZP();
4288:         }
4289:     }
4290: }
4291: 
4292: /**
4293:  * Checks for Cross Site Request Forgeries
4294:  * @param string $action
4295:  */
4296: function XSRFdefender($action) {
4297:     $token = getXSRFToken($action);
4298:     if (!isset($_REQUEST['XSRFToken']) || $_REQUEST['XSRFToken'] != $token) {
4299:         zp_apply_filter('admin_XSRF_access', false, $action);
4300:         header("HTTP/1.0 302 Found");
4301:         header("Status: 302 Found");
4302:         header('Location: ' . FULLWEBPATH . '/' . ZENFOLDER . '/admin.php?action=external&error&msg=' . sprintf(gettext('“%s” Cross Site Request Forgery blocked.'), $action));
4303:         exitZP();
4304:     }
4305:     unset($_REQUEST['XSRFToken']);
4306:     unset($_POST['XSRFToken']);
4307:     unset($_GET['XSRFToken']);
4308: }
4309: 
4310: /**
4311:  * getPageSelector "diff" function
4312:  *
4313:  * returns the shortest string difference
4314:  * @param string $string1
4315:  * @param string2 $string2
4316:  */
4317: function minDiff($string1, $string2) {
4318:     if ($string1 == $string2) {
4319:         return $string2;
4320:     }
4321:     if (empty($string1)) {
4322:         return substr($string2, 0, 10);
4323:     }
4324:     if (empty($string2)) {
4325:         return substr($string1, 0, 10);
4326:     }
4327:     if (strlen($string2) > strlen($string1)) {
4328:         $base = $string2;
4329:     } else {
4330:         $base = $string1;
4331:     }
4332:     for ($i = 0; $i < min(strlen($string1), strlen($string2)); $i++) {
4333:         if ($string1[$i] != $string2[$i]) {
4334:             $base = substr($string2, 0, max($i + 1, 10));
4335:             break;
4336:         }
4337:     }
4338:     return rtrim($base, '-_');
4339: }
4340: 
4341: /**
4342:  * getPageSelector "diff" function
4343:  *
4344:  * Used when you want getPgeSelector to show the full text of the items
4345:  * @param string $string1
4346:  * @param string $string2
4347:  * @return string
4348:  */
4349: function fullText($string1, $string2) {
4350:     return $string2;
4351: }
4352: 
4353: /**
4354:  * getPageSelector "diff" function
4355:  *
4356:  * returns the shortest "date" difference
4357:  * @param string $date1
4358:  * @param string $date2
4359:  * @return string
4360:  */
4361: function dateDiff($date1, $date2) {
4362:     $separators = array('', '-', '-', ' ', ':', ':');
4363:     preg_match('/(.*)-(.*)-(.*) (.*):(.*):(.*)/', $date1, $matches1);
4364:     preg_match('/(.*)-(.*)-(.*) (.*):(.*):(.*)/', $date2, $matches2);
4365:     if (empty($matches1)) {
4366:         $matches1 = array(0, 0, 0, 0, 0, 0, 0);
4367:     }
4368:     if (empty($matches2)) {
4369:         $matches2 = array(0, 0, 0, 0, 0, 0, 0);
4370:     }
4371: 
4372:     $date = '';
4373:     for ($i = 1; $i <= 6; $i++) {
4374:         if (@$matches1[$i] != @$matches2[$i]) {
4375:             break;
4376:         }
4377:     }
4378:     switch ($i) {
4379:         case 7:
4380:         case 6:
4381:             $date = ':' . $matches2[6];
4382:         case 5:
4383:         case 4:
4384:             $date = ' ' . $matches2[4] . ':' . $matches2[5] . $date;
4385:         default:
4386:             $date = $matches2[1] . '-' . $matches2[2] . '-' . $matches2[3] . $date;
4387:     }
4388:     return rtrim($date, ':-');
4389: }
4390: 
4391: /**
4392:  * returns a selector list based on the "names" of the list items
4393:  *
4394:  *
4395:  * @param array $list
4396:  * @param int $itmes_per_page
4397:  * @param string $diff
4398:  *                                  "fullText" for the complete names
4399:  *                                  "minDiff" for a truncated string showing just the unique characters of the names
4400:  *                                  "dateDiff" it the "names" are really dates.
4401:  * @return array
4402:  */
4403: function getPageSelector($list, $itmes_per_page, $diff = 'fullText') {
4404:     $rangeset = array();
4405:     $pages = round(ceil(count($list) / (int) $itmes_per_page));
4406:     $list = array_values($list);
4407:     if ($pages > 1) {
4408:         $ranges = array();
4409:         for ($page = 0; $page < $pages; $page++) {
4410:             $ranges[$page]['start'] = strtolower(get_language_string($list[$page * $itmes_per_page]));
4411:             $last = (int) ($page * $itmes_per_page + $itmes_per_page - 1);
4412:             if (array_key_exists($last, $list)) {
4413:                 $ranges[$page]['end'] = strtolower(get_language_string($list[$last]));
4414:             } else {
4415:                 $ranges[$page]['end'] = strtolower(get_language_string(@array_pop($list)));
4416:             }
4417:         }
4418:         $last = '';
4419:         foreach ($ranges as $page => $range) {
4420:             $next = @$ranges[$page + 1]['start'];
4421:             $rangeset[$page] = $diff($last, $range['start']) . ' » ' . $diff($next, $range['end']);
4422:             $last = $range['end'];
4423:         }
4424:     }
4425:     return $rangeset;
4426: }
4427: 
4428: function printPageSelector($subpage, $rangeset, $script, $queryParams) {
4429:     global $instances;
4430:     $pages = count($rangeset);
4431:     $jump = $query = '';
4432:     foreach ($queryParams as $param => $value) {
4433:         $query .= html_encode($param) . '=' . html_encode($value) . '&amp;';
4434:         $jump .= "'" . html_encode($param) . "=" . html_encode($value) . "',";
4435:     }
4436:     $query = '?' . $query;
4437:     if ($subpage > 0) {
4438:         ?>
4439:         <a href="<?php echo WEBPATH . '/' . ZENFOLDER . '/' . $script . $query; ?>subpage=<?php echo ($subpage - 1); ?>" >« <?php echo gettext('prev'); ?></a>
4440:         <?php
4441:     }
4442:     if ($pages > 2) {
4443:         if ($subpage > 0) {
4444:             ?>
4445:             |
4446:             <?php
4447:         }
4448:         ?>
4449:         <select name="subpage" class="dirtyignore" id="subpage<?php echo $instances; ?>" onchange="launchScript('<?php echo WEBPATH . '/' . ZENFOLDER . '/' . $script; ?>',
4450:                                 [<?php echo $jump; ?>'subpage=' + $('#subpage<?php echo $instances; ?>').val()]);" >
4451:                             <?php
4452:                             foreach ($rangeset as $page => $range) {
4453:                                 ?>
4454:                 <option value="<?php echo $page; ?>" <?php if ($page == $subpage) echo ' selected="selected"'; ?>><?php echo $range; ?></option>
4455:                 <?php
4456:             }
4457:             ?>
4458:         </select>
4459:         <?php
4460:     }
4461:     if ($pages > $subpage + 1) {
4462:         if ($pages > 2) {
4463:             ?>
4464:             |
4465:         <?php }
4466:         ?>
4467:         <a href="<?php echo WEBPATH . '/' . ZENFOLDER . '/' . $script . $query; ?>subpage=<?php echo ($subpage + 1); ?>" ><?php echo gettext('next'); ?> »</a>
4468:         <?php
4469:     }
4470:     $instances++;
4471: }
4472: 
4473: /**
4474:  * Strips off quotes from the strng
4475:  * @param $string
4476:  */
4477: function unQuote($string) {
4478:     $string = trim($string);
4479:     $q = $string{0};
4480:     if ($q == '"' || $q == "'") {
4481:         $string = trim($string, $q);
4482:     }
4483:     return $string;
4484: }
4485: 
4486: /**
4487:  * Returns an option list of administrators who can own albums or images
4488:  * @param string $owner
4489:  * @return string
4490:  */
4491: function admin_album_list($owner) {
4492:     global $_zp_authority;
4493:     $adminlist = '';
4494:     $admins = $_zp_authority->getAdministrators();
4495:     foreach ($admins as $user) {
4496:         if (($user['rights'] & (UPLOAD_RIGHTS | ADMIN_RIGHTS | MANAGE_ALL_ALBUM_RIGHTS))) {
4497:             $adminlist .= '<option value="' . $user['user'] . '"';
4498:             if ($owner == $user['user']) {
4499:                 $adminlist .= ' SELECTED="SELECTED"';
4500:             }
4501:             $adminlist .= '>' . $user['user'] . "</option>\n";
4502:         }
4503:     }
4504:     return $adminlist;
4505: }
4506: 
4507: /**
4508:  * Figures out which log tabs to display
4509:  */
4510: function getLogTabs() {
4511:     $subtabs = array();
4512:     $default = NULL;
4513:     $localizer = array('setup' => gettext('setup'), 'security' => gettext('security'), 'debug' => gettext('debug'));
4514:     $filelist = safe_glob(SERVERPATH . "/" . DATA_FOLDER . '/*.log');
4515:     if (count($filelist) > 0) {
4516:         $tab = sanitize(@$_GET['tab'], 3);
4517:         foreach ($filelist as $logfile) {
4518:             $log = substr(basename($logfile), 0, -4);
4519:             if ($log == $tab) {
4520:                 $default = $tab;
4521:             }
4522:             if (array_key_exists($log, $localizer)) {
4523:                 $logfiletext = $localizer[$log];
4524:             } else {
4525:                 $logfiletext = str_replace('_', ' ', $log);
4526:             }
4527:             $subtabs = array_merge($subtabs, array($logfiletext => 'admin-logs.php?page=logs&tab=' . $log));
4528:             if (filesize($logfile) > 0 && empty($default)) {
4529:                 $default = $log;
4530:             }
4531:         }
4532:     }
4533: 
4534:     $names = array_flip($subtabs);
4535:     natcasesort($names);
4536:     $subtabs = array_flip($names);
4537: 
4538:     return array($subtabs, $default);
4539: }
4540: 
4541: /**
4542:  * Figures out which plugin tabs to display
4543:  */
4544: function getPluginTabs() {
4545:     if (isset($_GET['tab'])) {
4546:         $default = sanitize($_GET['tab']);
4547:     } else {
4548:         $default = 'all';
4549:     }
4550:     $paths = getPluginFiles('*.php');
4551: 
4552:     $classXlate = array(
4553:                     'all'                    => gettext('all'),
4554:                     'admin'              => gettext('admin'),
4555:                     'demo'               => gettext('demo'),
4556:                     'development'    => gettext('development'),
4557:                     'feed'               => gettext('feed'),
4558:                     'mail'               => gettext('mail'),
4559:                     'media'              => gettext('media'),
4560:                     'misc'               => gettext('misc'),
4561:                     'spam'               => gettext('spam'),
4562:                     'seo'                    => gettext('seo'),
4563:                     'uploader'       => gettext('uploader'),
4564:                     'users'              => gettext('users')
4565:     );
4566:     zp_apply_filter('plugin_tabs', $classXlate);
4567: 
4568:     $currentlist = $classes = $member = array();
4569:     foreach ($paths as $plugin => $path) {
4570:         $p = file_get_contents($path);
4571:         $i = strpos($p, '* @subpackage');
4572:         if (($key = $i) !== false) {
4573:             $key = strtolower(trim(substr($p, $i + 13, strpos($p, "\n", $i) - $i - 13)));
4574:         }
4575:         if (empty($key)) {
4576:             $key = 'misc';
4577:         }
4578:         $classes[$key]['list'][] = $plugin;
4579:         if (array_key_exists($key, $classXlate)) {
4580:             $local = $classXlate[$key];
4581:         } else {
4582:             $local = $classXlate[$key] = $key;
4583:         }
4584:         $member[$plugin] = $local;
4585:     }
4586: 
4587:     ksort($classes);
4588:     $tabs[$classXlate['all']] = 'admin-plugins.php?page=plugins&tab=all';
4589:     $currentlist = array_keys($paths);
4590: 
4591: 
4592:     foreach ($classes as $class => $list) {
4593:         $tabs[$classXlate[$class]] = 'admin-plugins.php?page=plugins&tab=' . $class;
4594:         if ($class == $default) {
4595:             $currentlist = $list['list'];
4596:         }
4597:     }
4598:     return array($tabs, $default, $currentlist, $paths, $member);
4599: }
4600: 
4601: function getAdminThumb($image, $size) {
4602:     switch ($size) {
4603:         case 'large':
4604:             return $image->getCustomImage(80, NULL, NULL, 80, 80, NULL, NULL, -1);
4605:         default:
4606:             return $image->getCustomImage(40, NULL, NULL, 40, 40, NULL, NULL, -1);
4607:     }
4608: }
4609: 
4610: /**
4611:  *
4612:  * handles save of user/password
4613:  * @param object $object
4614:  */
4615: function processCredentials($object, $suffix = '') {
4616:     $notify = '';
4617:     if (isset($_POST['password_enabled' . $suffix]) && $_POST['password_enabled' . $suffix]) {
4618:         if (is_object($object)) {
4619:             $olduser = $object->getUser();
4620:         } else {
4621:             $olduser = getOption($object . '_user');
4622:         }
4623:         $newuser = trim(sanitize($_POST['user' . $suffix], 3));
4624:         $pwd = trim(sanitize($_POST['pass' . $suffix]));
4625:         if (isset($_POST['disclose_password' . $suffix])) {
4626:             $pass2 = $pwd;
4627:         } else {
4628:             if (isset($_POST['pass_r' . $suffix])) {
4629:                 $pass2 = trim(sanitize($_POST['pass_r' . $suffix]));
4630:             } else {
4631:                 $pass2 = '';
4632:             }
4633:         }
4634:         $fail = '';
4635:         if ($olduser != $newuser) {
4636:             if (!empty($newuser) && strlen($_POST['pass' . $suffix]) == 0) {
4637:                 $fail = '?mismatch=user';
4638:             }
4639:         }
4640:         if (!$fail && $pwd == $pass2) {
4641:             if (is_object($object)) {
4642:                 $object->setUser($newuser);
4643:             } else {
4644:                 setOption($object . '_user', $newuser);
4645:             }
4646:             if (empty($pwd)) {
4647:                 if (strlen($_POST['pass' . $suffix]) == 0) {
4648:                     // clear the  password
4649:                     if (is_object($object)) {
4650:                         $object->setPassword(NULL);
4651:                     } else {
4652:                         setOption($object . '_password', NULL);
4653:                     }
4654:                 }
4655:             } else {
4656:                 if (is_object($object)) {
4657:                     $object->setPassword(Zenphoto_Authority::passwordHash($newuser, $pwd));
4658:                 } else {
4659:                     setOption($object . '_password', Zenphoto_Authority::passwordHash($newuser, $pwd));
4660:                 }
4661:             }
4662:         } else {
4663:             if (empty($fail)) {
4664:                 $notify = '?mismatch';
4665:             } else {
4666:                 $notify = $fail;
4667:             }
4668:         }
4669:         $hint = process_language_string_save('hint' . $suffix, 3);
4670:         if (is_object($object)) {
4671:             $object->setPasswordHint($hint);
4672:         } else {
4673:             setOption($object . '_hint', $hint);
4674:         }
4675:     }
4676:     return $notify;
4677: }
4678: 
4679: function consolidatedEditMessages($subtab) {
4680:     zp_apply_filter('admin_note', 'albums', $subtab);
4681:     $messagebox = $errorbox = $notebox = array();
4682:     if (isset($_GET['ndeleted'])) {
4683:         $ntdel = sanitize_numeric($_GET['ndeleted']);
4684:         if ($ntdel <= 2) {
4685:             $msg = gettext("Image");
4686:         } else {
4687:             $msg = gettext("Album");
4688:             $ntdel = $ntdel - 2;
4689:         }
4690:         if ($ntdel == 2) {
4691:             $errorbox[] = sprintf(gettext("%s failed to delete."), $msg);
4692:         } else {
4693:             $messagebox[] = sprintf(gettext("%s deleted successfully."), $msg);
4694:         }
4695:     }
4696:     if (isset($_GET['mismatch'])) {
4697:         if ($_GET['mismatch'] == 'user') {
4698:             $errorbox[] = gettext("You must supply a password.");
4699:         } else {
4700:             $errorbox[] = gettext("Your passwords did not match.");
4701:         }
4702:     }
4703:     if (isset($_GET['edit_error'])) {
4704:         $errorbox[] = html_encode(sanitize($_GET['edit_error']));
4705:     }
4706:     if (isset($_GET['post_error'])) {
4707:         $messagebox[] = gettext('The image edit form submission has been truncated. Try displaying fewer images on a page.');
4708:     }
4709:     if (isset($_GET['counters_reset'])) {
4710:         $messagebox[] = gettext("Hit counters have been reset.");
4711:     }
4712:     if (isset($_GET['cleared']) || isset($_GET['action']) && $_GET['action'] == 'clear_cache') {
4713:         $messagebox[] = gettext("Cache has been purged.");
4714:     }
4715:     if (isset($_GET['uploaded'])) {
4716:         $messagebox[] = gettext('Your files have been uploaded.');
4717:     }
4718:     if (isset($_GET['exists'])) {
4719:         $errorbox[] = sprintf(gettext("<em>%s</em> already exists."), sanitize($_GET['exists']));
4720:     }
4721:     if (isset($_GET['saved'])) {
4722:         $messagebox[] = gettext("Changes applied");
4723:     }
4724:     if (isset($_GET['noaction'])) {
4725:         $notebox[] = gettext("Nothing changed");
4726:     }
4727:     if (isset($_GET['bulkmessage'])) {
4728:         $action = sanitize($_GET['bulkmessage']);
4729:         switch ($action) {
4730:             case 'deleteallalbum':
4731:             case 'deleteall':
4732:                 $messagebox[] = gettext('Selected items deleted');
4733:                 break;
4734:             case 'showall':
4735:                 $messagebox[] = gettext('Selected items published');
4736:                 break;
4737:             case 'hideall':
4738:                 $messagebox[] = gettext('Selected items unpublished');
4739:                 break;
4740:             case 'commentson':
4741:                 $messagebox[] = gettext('Comments enabled for selected items');
4742:                 break;
4743:             case 'commentsoff':
4744:                 $messagebox[] = gettext('Comments disabled for selected items');
4745:                 break;
4746:             case 'resethitcounter':
4747:                 $messagebox[] = gettext('Hitcounter for selected items');
4748:                 break;
4749:             case 'addtags':
4750:                 $messagebox[] = gettext('Tags added for selected items');
4751:                 break;
4752:             case 'cleartags':
4753:                 $messagebox[] = gettext('Tags cleared for selected items');
4754:                 break;
4755:             case 'alltags':
4756:                 $messagebox[] = gettext('Tags added for images of selected items');
4757:                 break;
4758:             case 'clearalltags':
4759:                 $messagebox[] = gettext('Tags cleared for images of selected items');
4760:                 break;
4761:             default:
4762:                 $messagebox[] = $action;
4763:                 break;
4764:         }
4765:     }
4766:     if (isset($_GET['mcrerr'])) {
4767:         switch (sanitize_numeric($_GET['mcrerr'])) {
4768:             case 2:
4769:                 $errorbox[] = gettext("Image already exists.");
4770:                 break;
4771:             case 3:
4772:                 $errorbox[] = gettext("Album already exists.");
4773:                 break;
4774:             case 4:
4775:                 $errorbox[] = gettext("Cannot move, copy, or rename to a subalbum of this album.");
4776:                 break;
4777:             case 5:
4778:                 $errorbox[] = gettext("Cannot move, copy, or rename to a dynamic album.");
4779:                 break;
4780:             case 6:
4781:                 $errorbox[] = gettext('Cannot rename an image to a different suffix');
4782:                 break;
4783:             case 7:
4784:                 $errorbox[] = gettext('Album delete failed');
4785:                 break;
4786:             default:
4787:                 $errorbox[] = sprintf(gettext("There was an error #%d with a move, copy, or rename operation."), sanitize_numeric($_GET['mcrerr']));
4788:                 break;
4789:         }
4790:     }
4791:     if (!empty($errorbox)) {
4792:         ?>
4793:         <div class="errorbox fade-message">
4794:             <?php echo implode('<br />', $errorbox); ?>
4795:         </div>
4796:         <?php
4797:     }
4798:     if (!empty($notebox)) {
4799:         ?>
4800:         <div class="notebox fade-message">
4801:             <?php echo implode('<br />', $notebox); ?>
4802:         </div>
4803:         <?php
4804:     }
4805:     if (!empty($messagebox)) {
4806:         ?>
4807:         <div class="messagebox fade-message">
4808:             <?php echo implode('<br />', $messagebox); ?>
4809:         </div>
4810:         <?php
4811:     }
4812: }
4813: 
4814: /**
4815:  * returns an array of the theme scripts not in the exclude array
4816:  * @param array $exclude those scripts to ignore
4817:  * @return array
4818:  */
4819: function getThemeFiles($exclude) {
4820:     global $_zp_gallery;
4821:     $files = array();
4822:     foreach (array_keys($_zp_gallery->getThemes()) as $theme) {
4823:         $curdir = getcwd();
4824:         $root = SERVERPATH . '/' . THEMEFOLDER . '/' . $theme . '/';
4825:         chdir($root);
4826:         $filelist = safe_glob('*.php');
4827:         $list = array();
4828:         foreach ($filelist as $file) {
4829:             if (!in_array($file, $exclude)) {
4830:                 $files[$theme][] = filesystemToInternal($file);
4831:             }
4832:         }
4833:         chdir($curdir);
4834:     }
4835:     return $files;
4836: }
4837: 
4838: /**
4839:  *
4840:  * Checks for bad parentIDs from old move/copy bug
4841:  * @param unknown_type $albumname
4842:  * @param unknown_type $id
4843:  */
4844: function checkAlbumParentid($albumname, $id, $recorder) {
4845:     $album = newAlbum($albumname);
4846:     $oldid = $album->getParentID();
4847:     if ($oldid != $id) {
4848:         $album->set('parentid', $id);
4849:         $album->save();
4850:         if (is_null($oldid))
4851:             $oldid = '<em>NULL</em>';
4852:         if (is_null($id))
4853:             $id = '<em>NULL</em>';
4854:         $msg = sprintf('Fixed album <strong>%1$s</strong>: parentid was %2$s should have been %3$s<br />', $albumname, $oldid, $id);
4855:         $recorder($msg, true);
4856:         echo $msg;
4857:     }
4858:     $id = $album->getID();
4859:     if (!$album->isDynamic()) {
4860:         $albums = $album->getAlbums();
4861:         foreach ($albums as $albumname) {
4862:             checkAlbumParentid($albumname, $id, $recorder);
4863:         }
4864:     }
4865: }
4866: 
4867: function clonedFrom() {
4868:     if (PRIMARY_INSTALLATION) {
4869:         return false;
4870:     } else {
4871:         $zen = str_replace('\\', '/', @readlink(SERVERPATH . '/' . ZENFOLDER));
4872:         return dirname($zen);
4873:     }
4874: }
4875: 
4876: /**
4877:  * Make sure the albumimagesort is only an allowed value. Otherwise returns nothing.
4878:  * @global array $_zp_sortby
4879:  * @param string $val
4880:  * @return string
4881:  */
4882: function checkAlbumimagesort($val) {
4883:   global $_zp_sortby;
4884:     $sortcheck = $_zp_sortby;
4885:     $sortcheck[gettext('Manual')] = 'manual';
4886:   foreach ($sortcheck as $sort) {
4887:     if ($val == $sort || $val == $sort . '_desc') {
4888:       return $val;
4889:     }
4890:   }
4891: }
4892: 
4893: ?>
4894: 
Zenphoto doc API documentation generated by ApiGen