Overview

Classes

  • _zp_captcha
  • _zp_HTML_cache
  • admin_approval
  • Album
  • AlbumBase
  • AlbumZip
  • AMFReader
  • AMFStream
  • AnyFile
  • AnyFile_Options
  • auto_backup
  • AVCSequenceParameterSetReader
  • bxslider
  • cacheManager
  • cachemanager_internal_deprecations
  • cacheManagerFeed
  • CI_jsmin
  • CI_load
  • cloneZenphoto
  • codeIgniter_kludge
  • colorbox
  • Combi
  • Comment
  • comment_form
  • contactformOptions
  • cookieConsent
  • crop_image
  • cycle
  • defaultCodeblocks
  • deprecated_functions
  • DownloadList
  • dynamic_locale
  • dynamicAlbum
  • elFinder
  • elFinder_options
  • elFinderConnector
  • elFinderEditor
  • elFinderEditorOnlineConvert
  • elFinderEditorZipArchive
  • elFinderEditorZohoOffice
  • elFinderLibGdBmp
  • elFinderPlugin
  • elFinderPluginAutoResize
  • elFinderPluginAutoRotate
  • elFinderPluginNormalizer
  • elFinderPluginSanitizer
  • elFinderPluginWatermark
  • elFinderSession
  • elFinderVolumeBox
  • elFinderVolumeDriver
  • elFinderVolumeDropbox
  • elFinderVolumeDropbox2
  • elFinderVolumeFlysystemGoogleDriveCache
  • elFinderVolumeFlysystemGoogleDriveNetmount
  • elFinderVolumeFTP
  • elFinderVolumeGoogleDrive
  • elFinderVolumeGroup
  • elFinderVolumeLocalFileSystem
  • elFinderVolumeMySQL
  • elFinderVolumeOneDrive
  • elFinderVolumeTrash
  • elFinderVolumeTrashMySQL
  • email_new_user
  • exampleMacros
  • external_auth
  • favorites
  • favoritesOptions
  • 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
  • hitcounter
  • htmlmetatags
  • Image
  • internal_deprecations
  • ipBlocker
  • jPlayer
  • jplayer_options
  • jquery_rating
  • JSMin
  • lazyload
  • lib_GD_Options
  • lib_Imagick_Options
  • lib_NoGraphics
  • matomoStats
  • 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
  • openStreetMap
  • openStreetMapOptions
  • pagedThumbsNav
  • pagedthumbsOptions
  • PersistentObject
  • PHPMailer\PHPMailer\PHPMailer
  • PHPMailer\PHPMailer\POP3
  • PHPMailer\PHPMailer\SMTP
  • print_album_menu
  • pseudoPlayer
  • publishContent
  • quota_manager
  • reCaptcha
  • RecursiveCallbackFilterIterator
  • redirector
  • redirectorOptions
  • register_user
  • rewriteRules
  • rewriteTokens
  • RSS
  • rss_options
  • scriptlessSocialsharing
  • scriptlessSocialsharingOptions
  • search_statistics
  • SearchEngine
  • security_logger
  • securityHeaders
  • securityheadersOptions
  • seo_locale
  • Services_JSON
  • Services_JSON_Error
  • setup
  • setupMutex
  • setupRSS
  • show_not_loggedin
  • sitemap
  • sitemapOptions
  • static_html_cache
  • staticHTMLCacheOptions
  • tagsuggest
  • TextObject
  • TextObject_Options
  • ThemeObject
  • themeSwitcher
  • tinymce4Options
  • tinyURL
  • Transientimage
  • UploadHandler
  • user_expiry
  • user_groups
  • user_logout_options
  • userAddressFields
  • userDataExport
  • utf8
  • Video
  • VideoObject_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
  • zpFunctions
  • zpMutex
  • zpSimpleSpam
  • zpTrivialSpam

Interfaces

  • elFinderSessionInterface

Exceptions

  • elFinderAbortException
  • elFinderTriggerException
  • getid3_exception
  • JSMin_UnterminatedCommentException
  • JSMin_UnterminatedRegExpException
  • JSMin_UnterminatedStringException
  • OAuthExcept
  • PHPMailer\PHPMailer\Exception

Functions

  • access
  • accessAlbums
  • accessAllAlbums
  • accessImage
  • add_context
  • addalbumsToDatabase
  • addCategoriesToDatabase
  • addDateToTitlelink
  • addGeoCoord
  • addItem
  • addMissingDefaultRewriteTokens
  • addPagesToDatabase
  • addReconfigureNote
  • addSubalbumMenus
  • addWatermark
  • admin_album_list
  • admin_securityChecks
  • admin_showupdate
  • adminPageNav
  • adminToolbox
  • albumNumber
  • applyMacros
  • authorSelector
  • bind_textdomain_codeset
  • bindtextdomain
  • build_query
  • build_url
  • bulkActionRedirect
  • bulkTags
  • byteConvert
  • cacheImage
  • checkAccess
  • checkAlbumForImages
  • checkAlbumimagesort
  • checkAlbumParentid
  • checkAlbumPassword
  • checkChosenItemStatus
  • checkChosenMenuset
  • checked
  • checkFolder
  • checkForEmptyTitle
  • checkForGuest
  • checkForPage
  • checkForUpdate
  • checkHitcounterDisplay
  • checkIfChecked
  • checkIfLockedNews
  • checkIfLockedPage
  • checkIfNew
  • checkInstall
  • checkLayoutUseForImages
  • checkObjectsThumb
  • checkPageValidity
  • checkParentLayouts
  • checkPublishDates
  • checkRequiredField
  • checkSchedulePublishingNotes
  • checkSelectedAlbum
  • checkSignature
  • checkTitlelinkDuplicate
  • cleanAlbum
  • cleanHTML
  • clonedFrom
  • codeblocktabsJS
  • comment_form_addComment
  • comment_form_handle_comment
  • comment_form_PaginationJS
  • comment_form_postcomment
  • comment_form_print10Most
  • comment_form_visualEditor
  • commentFormUseCaptcha
  • commentReply
  • commentsAllowed
  • compressRow
  • consolidatedEditMessages
  • copyLayoutSelection
  • copyThemeDirectory
  • createMenuIfNotExists
  • createRelatedItemsResultArray
  • createTitlelink
  • cron_starter
  • curlRequest
  • 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_getClientInfo
  • db_getServerInfo
  • db_getSQLmode
  • db_getVersion
  • db_insert_id
  • db_isMariaDB
  • 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
  • debuglogReconfigureNote
  • debugLogVar
  • decompressField
  • decompressRow
  • defaultCodeblocks_codebox
  • deleteArticle
  • deleteCategory
  • deleteItem
  • deleteLayoutSelection
  • deletePage
  • deleteThemeDirectory
  • dircopy
  • disableExtension
  • elFinder_admin_tabs
  • elFinder_tinymce
  • elFinderAutoloader
  • enableExtension
  • executeRSS
  • exitZP
  • exposeZenPhotoInformations
  • extendExecution
  • extensionEnabled
  • fetchComments
  • filesystemToInternal
  • fillbuffer
  • filterImageQuery
  • fix_path_redirect
  • formatList
  • fullText
  • galleryAlbumsPerPage
  • gallerystats_filesize_r
  • genAlbumList
  • generateAttributesFromArray
  • generateImageCacheFile
  • generateLanguageList
  • generateListFromArray
  • generateListFromFiles
  • generateRadiobuttonsFromArray
  • generateUnorderedListFromArray
  • get_AnyFile_suffixes
  • get_context
  • get_filterScript
  • get_instance
  • get_language_string
  • getAdminstratorsOptionsArray
  • getAdminThumb
  • getAdminThumbHTML
  • getAlbumArray
  • getAlbumBreadcrumb
  • getAlbumBreadcrumbAdmin
  • getAlbumCustomData
  • getAlbumData
  • getAlbumDate
  • getAlbumDesc
  • getAlbumFolder
  • getAlbumGeodata
  • getAlbumInherited
  • getAlbumLocation
  • getAlbumPage
  • getAlbumStatistic
  • getAlbumThumb
  • getAlbumTitle
  • getAlbumURL
  • getAllAccessibleAlbums
  • getAllAlbums
  • getAllDates
  • getAllowedTags
  • getAllSubAlbumIDs
  • getAllTagsCount
  • getAllTagsFromAlbum
  • getAllTagsFromAlbum_multi_unique
  • getAllTagsFromZenpage
  • getAllTagsUnique
  • getAllTranslations
  • getAnnotatedAlbumTitle
  • getAnnotatedImageTitle
  • getAnonymIP
  • getAuthor
  • getBare
  • getBareAlbumDesc
  • getBareAlbumTitle
  • getBareGalleryDesc
  • getBareGalleryTitle
  • getBareImageDesc
  • getBareImageTitle
  • getBareNewsTitle
  • getBarePageTitle
  • getCheckboxState
  • getCodeblock
  • getCommentAddress
  • getCommentAuthorEmail
  • getCommentAuthorLink
  • getCommentAuthorName
  • getCommentAuthorSite
  • getCommentBody
  • getCommentCount
  • getCommentDateTime
  • getCommentErrors
  • getCommentStored
  • getContactFormMacros
  • getContentShorten
  • getCookieInfoData
  • getCookieInfoHTML
  • getCookieInfoMacro
  • getCurrentMenuItem
  • getCurrentNewsArchive
  • getCurrentPage
  • getCurrentTheme
  • getCustomAlbumThumb
  • getCustomAlbumThumbMaxSpace
  • getCustomGalleryIndexPage
  • getCustomGalleryIndexURL
  • getCustomImageURL
  • getCustomPageURL
  • getCustomSizedImageMaxSpace
  • getCustomSizedImageThumbMaxSpace
  • getDataUsageNotice
  • getDefaultHeight
  • getDefaultRewriteTokens
  • getDefaultSizedImage
  • getDefaultWidth
  • getdownloadList
  • getDownloadURL
  • getE
  • getEnabledPlugins
  • getExpiryDatePost
  • getFavoritesURL
  • getField
  • getFullHeight
  • getFullImageFilesize
  • getFullImageURL
  • getFullWidth
  • getGalleryDesc
  • getGalleryIndexURL
  • getGalleryTitle
  • getGeoCoord
  • getHeadTitle
  • getHitcounter
  • getImageArgs
  • getImageCacheFilename
  • getImageCachePostfix
  • getImageCity
  • getImageCountry
  • getImageCustomData
  • getImageData
  • getImageDate
  • getImageDesc
  • getImageGeodata
  • getImageLocation
  • getImageMetaData
  • getImageParameters
  • getImageProcessorURI
  • getImageProcessorURIFromCacheName
  • getImageRotation
  • getImageState
  • getImageStatistic
  • getImageThumb
  • getImageTitle
  • getImageType
  • getImageURI
  • getImageURL
  • getItem
  • getItemByID
  • getItemTitleAndURL
  • getjPlayerSkinCSS
  • getjPlayerSkins
  • getLangAttributeLocale
  • getLanguageArray
  • getLanguageDisplayName
  • getLanguageFlag
  • getLanguageSubdomains
  • getLanguageText
  • getLatestComments
  • getLatestNews
  • getLatestZenpageComments
  • getLayout
  • getLayoutSelector
  • getLinkHTML
  • getLogTabs
  • getMacros
  • getMainSiteName
  • getMainSiteURL
  • getManagedAlbumList
  • getMaxSpaceContainer
  • getMenuFromLink
  • getMenuItemChilds
  • getMenuItems
  • getMenumanagerPredicessor
  • getMenumanagerSuccessor
  • getMenuSetSelector
  • getMenuVisibility
  • getMimeString
  • getNestedAlbumList
  • getNewsAdminOption
  • getNewsAdminOptionPath
  • getNewsArchivePath
  • getNewsArchiveURL
  • getNewsAuthor
  • getNewsCategories
  • getNewsCategoryCustomData
  • getNewsCategoryDesc
  • getNewsCategoryURL
  • getNewsContent
  • getNewsCustomData
  • getNewsDate
  • getNewsExtraContent
  • getNewsID
  • getNewsIndexURL
  • getNewsPagesStatistic
  • getNewsPathNav
  • getNewsReadMore
  • getNewsTitle
  • getNewsURL
  • getNextAlbum
  • getNextAlbumURL
  • getNextImageThumb
  • getNextImageURL
  • getNextNewsPageURL
  • getNextNewsURL
  • getNextPageURL
  • getNextPrevNews
  • getNotViewableAlbums
  • getNotViewableImages
  • getNumAlbums
  • getNumAllSubalbums
  • getNumImages
  • getNumNews
  • getNumPages
  • getOption
  • getOptionFromDB
  • getOptionList
  • getOwnerAuthor
  • getOwnerAuthorURL
  • getPageAuthor
  • getPageContent
  • getPageCustomData
  • getPageDate
  • getPageExtraContent
  • getPageID
  • getPageLastChangeDate
  • getPageNavList
  • getPageNumURL
  • getPageParentID
  • getPageRedirect
  • getPageSelector
  • getPageSortorder
  • getPageTitle
  • getPageTitleLink
  • getPageURL
  • getParentAlbums
  • getParentAlbumsAdmin
  • getParentBreadcrumb
  • getParentMenuItems
  • getPasswordProtectImage
  • getPHPFiles
  • getPictureOfTheDay
  • getPlugin
  • getPluginFiles
  • getPluginTabs
  • getPrevAlbum
  • getPrevAlbumURL
  • getPrevImageThumb
  • getPrevImageURL
  • getPrevNewsPageURL
  • getPrevNewsURL
  • getPrevPageURL
  • getProtectedImageURL
  • getRandomImages
  • getRandomImagesAlbum
  • getRating
  • getReconfigureNote
  • getRelatedItems
  • getRequestURI
  • getrow
  • getRSSLink
  • getRules
  • getSearchDate
  • getSearchURL
  • getSearchWords
  • getSelectedLayout
  • getSerializedArray
  • getSetClause
  • getSiteHomeURL
  • getSizeCustomImage
  • getSizeDefaultImage
  • getSizeDefaultThumb
  • getSizedImageURL
  • getSizeFullImage
  • getSortByOptions
  • getSortByStatusOptions
  • getStandardGalleryIndexURL
  • getSubtabs
  • getSuffix
  • getSystemLocales
  • getTagCountByAccess
  • getTagOrder
  • getTags
  • gettext
  • gettext_pl
  • gettext_th
  • getThemeFiles
  • getThemeOption
  • getTimezones
  • getTinyMCE4ConfigFiles
  • getTitle
  • getTotalHitcounter
  • getTotalImagesIn
  • getTotalNewsPages
  • getTotalPages
  • getUnprotectedImageURL
  • getUrAlbum
  • getUserIP
  • getUserLocale
  • getUserURL
  • getVersion
  • getWatermarkParam
  • getWatermarkPath
  • getWatermarks
  • getWhereClause
  • getXSRFToken
  • getZenpagePagesOptionsArray
  • getZenpageStatistic
  • handleSearchParms
  • hasDynamicAlbumSuffix
  • hasNextImage
  • hasNextNewsPage
  • hasNextPage
  • hasPrevImage
  • hasPrevNewsPage
  • hasPrevPage
  • hasPrimaryScripts
  • hl_attrval
  • hl_bal
  • hl_cmtcd
  • hl_ent
  • hl_prot
  • hl_regex
  • hl_spec
  • hl_tag
  • hl_tag2
  • hl_tidy
  • hl_version
  • html_decode
  • html_encode
  • html_encodeTagged
  • html_pathurlencode
  • htmLawed
  • httpsRedirect
  • httpUploadHandler
  • httpUploadHandler_admin_tabs
  • i18nSetLocale
  • ignoreSetupRunRequest
  • imageBlurGD
  • imagecreatefrombmp
  • imageDebug
  • imageError
  • imageNumber
  • imgSrcURI
  • in_context
  • installSignature
  • instrument
  • internalToFilesystem
  • inventMenuItem
  • iptc_make_tag
  • is_AdminEditPage
  • is_connected
  • is_News
  • is_NewsArchive
  • is_NewsArticle
  • is_NewsCategory
  • is_NewsPage
  • is_Pages
  • is_valid_email_zp
  • is_zip
  • isAlbumClass
  • isAlbumPage
  • isArchive
  • isCurrentitemParent
  • isHandledAlbum
  • isImageClass
  • isImagePage
  • isImagePhoto
  • isImageVideo
  • isIncompatibleExtension
  • isLandscape
  • isolate
  • isSetupProtected
  • isValidEmail
  • 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
  • myts_date
  • newAlbum
  • newImage
  • next_album
  • next_comment
  • next_image
  • next_news
  • next_page
  • ngettext
  • ngettext_pl
  • ngettext_th
  • omsAdditions
  • parse_query
  • parse_size
  • parseAllowedTags
  • parseHttpAcceptLanguage
  • pathurlencode
  • pluginDebug
  • populateManagedObjectsList
  • postAlbumSort
  • postIndexDecode
  • postIndexEncode
  • prefix
  • prepareAlbumPage
  • prepareCustomPage
  • prepareImagePage
  • prepareIndexPage
  • print404status
  • print_language_string_list
  • printAddToFavorites
  • printAdminFooter
  • printAdminHeader
  • printAdminRightsTable
  • printAdminThumb
  • printAlbumBreadcrumb
  • printAlbumButtons
  • printAlbumCustomData
  • printAlbumData
  • printAlbumDate
  • printAlbumDesc
  • printAlbumEditForm
  • printAlbumEditRow
  • printAlbumLegend
  • printAlbumLocation
  • printAlbumMenu
  • printAlbumMenuJump
  • printAlbumMenuList
  • printAlbumMenuListAlbum
  • printAlbumsSelector
  • printAlbumStatistic
  • printAlbumStatisticItem
  • printAlbumThumbImage
  • printAlbumTitle
  • printAlbumURL
  • printAllDates
  • printAllNestedList
  • printAllNewsCategories
  • printAllTags
  • printAllTagsAs
  • printAllTagsFromAlbum
  • printAllTagsFromZenpage
  • printAnnotatedAlbumTitle
  • printAnnotatedImageTitle
  • printArticleCategories
  • printArticleDatesDropdown
  • printArticlesPerPageDropdown
  • printAuthorDropdown
  • printBareAlbumDesc
  • printBareAlbumTitle
  • printBareGalleryDesc
  • printBareGalleryTitle
  • printBareImageDesc
  • printBareImageTitle
  • printBareNewsTitle
  • printBarePageTitle
  • printBarGraph
  • printBulkActions
  • printCategoriesStatistic
  • printCategoryCheckboxListEntry
  • printCategoryDropdown
  • printCategoryListSortableTable
  • printCategorySelection
  • printCodeblock
  • printCodeblockEdit
  • printCommentAuthorLink
  • printCommentErrors
  • printCommentForm
  • printContactForm
  • printContactFormMacro
  • printCookieInfo
  • printCopyrightNotice
  • printCurrentNewsArchive
  • printCurrentNewsCategory
  • printCustomAlbumThumbImage
  • printCustomAlbumThumbMaxSpace
  • printCustomMenu
  • printCustomPageSelector
  • printCustomPageURL
  • printCustomSizedImage
  • printCustomSizedImageMaxSpace
  • printCustomSizedImageThumbMaxSpace
  • printDataUsageNotice
  • printDefaultSizedImage
  • printDownloadAlbumZipURL
  • printdownloadList
  • printDownloadURL
  • printEditCommentLink
  • printEditDropdown
  • printExpired
  • printFavoritesURL
  • printFullAlbumsList
  • printFullImageDownloadURL
  • printGalleryDesc
  • printGalleryIndexURL
  • printGalleryTitle
  • printGoogleMap
  • printHeadTitle
  • printHomeLink
  • printImageCustomData
  • printImageData
  • printImageDate
  • printImageDesc
  • printImageMetadata
  • printImageslist
  • printImageStatistic
  • printImageThumb
  • printImageTitle
  • printImageURL
  • printItemEditLink
  • printItemsList
  • printItemsListTable
  • printItemStatusDropdown
  • printjPlayerPlaylist
  • printLangAttribute
  • printLanguageSelector
  • printLastChangeInfo
  • printLatestAlbums
  • printLatestComments
  • printLatestImages
  • printLatestImagesByDate
  • printLatestImagesByMtime
  • printLatestNews
  • printLatestUpdatedAlbums
  • printLinkHTML
  • printLogoAndLinks
  • printManagedObjects
  • printMenuemanagerPageList
  • printMenuemanagerPageListWithNav
  • printMenumanagerBreadcrumb
  • printMenumanagerNextLink
  • printMenumanagerPrevLink
  • printMostPopularItems
  • printMostRatedAlbums
  • printMostRatedImages
  • printMostRatedItems
  • printNestedAlbumsList
  • printNestedItemsList
  • printNestedMenu
  • printNews
  • printNewsArchive
  • printNewsArticlesList
  • printNewsAuthor
  • printNewsCategories
  • printNewsCategoryCustomData
  • printNewsCategoryDesc
  • printNewsCategoryURL
  • printNewsContent
  • printNewsCustomData
  • printNewsDate
  • printNewsExtraContent
  • printNewsIndexURL
  • printNewsPageList
  • printNewsPageListWithNav
  • printNewsStatistic
  • printNewsTitle
  • printNewsURL
  • printNextNewsLink
  • printNextNewsPageLink
  • printNextPageURL
  • printOpenStreetMap
  • printOwnerAuthor
  • printOwnerAuthorURL
  • printPageArticleTags
  • printPageAuthor
  • printPageContent
  • printPageCustomData
  • printPageDate
  • printPagedThumbsNav
  • printPageExtraContent
  • printPageID
  • printPageLastChangeDate
  • printPageList
  • printPageListWithNav
  • printPageMenu
  • printPageNav
  • printPageSelector
  • printPagesListTable
  • printPagesStatistic
  • printPageTitle
  • printPageTitleLink
  • printPageURL
  • printParentBreadcrumb
  • printPasswordForm
  • printPopularAlbums
  • printPopularImages
  • printPrevNewsLink
  • printPrevNewsPageLink
  • printPrevPageURL
  • printPrivacyPageLink
  • printPublished
  • printPublishIconLink
  • printPublishIconLinkGallery
  • printRandomImages
  • printRating
  • printReconfigureError
  • printReconfigureNote
  • printRegisterURL
  • printRegistrationForm
  • printRelatedItems
  • printRSSHeaderLink
  • printRSSLink
  • printScheduledPublishingNotes
  • printSearchBreadcrumb
  • printSearchForm
  • printSelectorWithCustomField
  • printSiteHomeURL
  • printSizedImageURL
  • printSlideShow
  • printSlideShowLink
  • printSortableHead
  • printSortOrderDropdown
  • printSubLevelAlbums
  • printSubPagesExcerpts
  • printSubtabs
  • printTabs
  • printTags
  • printThumbNav
  • printTinyPageNav
  • printTinyZenpageCategorySelector
  • printTopRatedAlbums
  • printTopRatedImages
  • printTopRatedItems
  • printUnpublishedDropdown
  • printUserLogin_out
  • printUserSelector
  • printUserURL
  • printVersion
  • printZenJavascripts
  • printZenpageIconLegend
  • printZenpageItems
  • printZenpageItemsBreadcrumb
  • printZenpageNewsCategorySelector
  • printZenpagePageSelector
  • printZenpagePagesSelector
  • printZenpageStatistic
  • printZenphotoLink
  • process_language_string_save
  • processAlbumBulkActions
  • processAlbumEdit
  • processCodeblockSave
  • processCommentBulkActions
  • processCredentials
  • processCustomOptionSave
  • processEditSelection
  • processExtensionVariable
  • processImageBulkActions
  • processImageEdit
  • processManagedObjects
  • processMenuBulkActions
  • processOrder
  • processRights
  • processTags
  • processZenpageBulkActions
  • propSizes
  • protectSetupFiles
  • publishItem
  • purgeOption
  • purgeThemeOption
  • query
  • query_full_array
  • query_single_row
  • rc4
  • read_exif_data_protected
  • readTags
  • reconfigureAction
  • reconfigureCSS
  • recordMissing
  • redirectionHandler
  • redirectURL
  • rem_context
  • removeDir
  • removeParentAlbumNames
  • removeTrailingSlash
  • renameOption
  • replaceOption
  • replaceThemeOption
  • restore_context
  • reveal
  • rewrite_get_album_image
  • rewrite_path
  • rewriteHandler
  • RSS_Channel
  • RSS_Retrieve
  • RSS_Tags
  • rulesList
  • 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
  • setAlbumSubtabs
  • setexifvars
  • setMainDomain
  • setOption
  • setOptionDefault
  • setSiteState
  • setThemeColumns
  • setThemeOption
  • setThemeOptionDefault
  • setTinyZenpageLocale
  • setupCurrentLocale
  • setupDomain
  • setupTheme
  • shortenContent
  • shortentitle
  • showOrNotShowField
  • showZenphotoOptions
  • shuffle_assoc
  • signatureChange
  • site_upgrade_button
  • site_upgrade_status
  • skipScheduledPublishing
  • sortArray
  • sortByKey
  • sortByMultilingual
  • sortMultiArray
  • standardScripts
  • standardThemeOptions
  • stickyNews
  • storeConfig
  • storeTags
  • stripSuffix
  • submenuOf
  • switchLog
  • tagSelector
  • tagSuggestJS
  • tagSuggestJS_admin
  • tagSuggestJS_frontend
  • tagURLs
  • textdomain
  • themeIsEditable
  • themeSetup
  • tidyHTML
  • timezoneDiff
  • tinymce4ConfigJS
  • truncate_string
  • unprotectSetupFiles
  • unpublishedZenpageItemCheck
  • unpublishedZenphotoItemCheck
  • unpublishSubalbums
  • unQuote
  • unTagURLs
  • unzip
  • updateArticle
  • updateCacheName
  • updateCategory
  • updateConfigItem
  • updateImageProcessorLink
  • updateItemSortorder
  • updateItemsSortorder
  • updateMenuItem
  • updatePage
  • upload_extra
  • upload_form
  • upload_head
  • user_mailing_list_button
  • validateLocale
  • writeHeader
  • XSRFdefender
  • XSRFToken
  • zenpageAlbumImage
  • zenpageBulkActionMessage
  • zenpageJSCSS
  • 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_imageResizeTransparent
  • 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_destroy
  • zp_session_start
  • zp_setCookie
  • zp_writeString
  • zpErrorHandler
  • zpFormattedDate
  • zpRewriteURL
  • Overview
  • Class
  • Tree
  • Package
  • Deprecated
   1:    2:    3:    4:    5:    6:    7:    8:    9:   10:   11:   12:   13:   14:   15:   16:   17:   18:   19:   20:   21:   22:   23:   24:   25:   26:   27:   28:   29:   30:   31:   32:   33:   34:   35:   36:   37:   38:   39:   40:   41:   42:   43:   44:   45:   46:   47:   48:   49:   50:   51:   52:   53:   54:   55:   56:   57:   58:   59:   60:   61:   62:   63:   64:   65:   66:   67:   68:   69:   70:   71:   72:   73:   74:   75:   76:   77:   78:   79:   80:   81:   82:   83:   84:   85:   86:   87:   88:   89:   90:   91:   92:   93:   94:   95:   96:   97:   98:   99:  100:  101:  102:  103:  104:  105:  106:  107:  108:  109:  110:  111:  112:  113:  114:  115:  116:  117:  118:  119:  120:  121:  122:  123:  124:  125:  126:  127:  128:  129:  130:  131:  132:  133:  134:  135:  136:  137:  138:  139:  140:  141:  142:  143:  144:  145:  146:  147:  148:  149:  150:  151:  152:  153:  154:  155:  156:  157:  158:  159:  160:  161:  162:  163:  164:  165:  166:  167:  168:  169:  170:  171:  172:  173:  174:  175:  176:  177:  178:  179:  180:  181:  182:  183:  184:  185:  186:  187:  188:  189:  190:  191:  192:  193:  194:  195:  196:  197:  198:  199:  200:  201:  202:  203:  204:  205:  206:  207:  208:  209:  210:  211:  212:  213:  214:  215:  216:  217:  218:  219:  220:  221:  222:  223:  224:  225:  226:  227:  228:  229:  230:  231:  232:  233:  234:  235:  236:  237:  238:  239:  240:  241:  242:  243:  244:  245:  246:  247:  248:  249:  250:  251:  252:  253:  254:  255:  256:  257:  258:  259:  260:  261:  262:  263:  264:  265:  266:  267:  268:  269:  270:  271:  272:  273:  274:  275:  276:  277:  278:  279:  280:  281:  282:  283:  284:  285:  286:  287:  288:  289:  290:  291:  292:  293:  294:  295:  296:  297:  298:  299:  300:  301:  302:  303:  304:  305:  306:  307:  308:  309:  310:  311:  312:  313:  314:  315:  316:  317:  318:  319:  320:  321:  322:  323:  324:  325:  326:  327:  328:  329:  330:  331:  332:  333:  334:  335:  336:  337:  338:  339:  340:  341:  342:  343:  344:  345:  346:  347:  348:  349:  350:  351:  352:  353:  354:  355:  356:  357:  358:  359:  360:  361:  362:  363:  364:  365:  366:  367:  368:  369:  370:  371:  372:  373:  374:  375:  376:  377:  378:  379:  380:  381:  382:  383:  384:  385:  386:  387:  388:  389:  390:  391:  392:  393:  394:  395:  396:  397:  398:  399:  400:  401:  402:  403:  404:  405:  406:  407:  408:  409:  410:  411:  412:  413:  414:  415:  416:  417:  418:  419:  420:  421:  422:  423:  424:  425:  426:  427:  428:  429:  430:  431:  432:  433:  434:  435:  436:  437:  438:  439:  440:  441:  442:  443:  444:  445:  446:  447:  448:  449:  450:  451:  452:  453:  454:  455:  456:  457:  458:  459:  460:  461:  462:  463:  464:  465:  466:  467:  468:  469:  470:  471:  472:  473:  474:  475:  476:  477:  478:  479:  480:  481:  482:  483:  484:  485:  486:  487:  488:  489:  490:  491:  492:  493:  494:  495:  496:  497:  498:  499:  500:  501:  502:  503:  504:  505:  506:  507:  508:  509:  510:  511:  512:  513:  514:  515:  516:  517:  518:  519:  520:  521:  522:  523:  524:  525:  526:  527:  528:  529:  530:  531:  532:  533:  534:  535:  536:  537:  538:  539:  540:  541:  542:  543:  544:  545:  546:  547:  548:  549:  550:  551:  552:  553:  554:  555:  556:  557:  558:  559:  560:  561:  562:  563:  564:  565:  566:  567:  568:  569:  570:  571:  572:  573:  574:  575:  576:  577:  578:  579:  580:  581:  582:  583:  584:  585:  586:  587:  588:  589:  590:  591:  592:  593:  594:  595:  596:  597:  598:  599:  600:  601:  602:  603:  604:  605:  606:  607:  608:  609:  610:  611:  612:  613:  614:  615:  616:  617:  618:  619:  620:  621:  622:  623:  624:  625:  626:  627:  628:  629:  630:  631:  632:  633:  634:  635:  636:  637:  638:  639:  640:  641:  642:  643:  644:  645:  646:  647:  648:  649:  650:  651:  652:  653:  654:  655:  656:  657:  658:  659:  660:  661:  662:  663:  664:  665:  666:  667:  668:  669:  670:  671:  672:  673:  674:  675:  676:  677:  678:  679:  680:  681:  682:  683:  684:  685:  686:  687:  688:  689:  690:  691:  692:  693:  694:  695:  696:  697:  698:  699:  700:  701:  702:  703:  704:  705:  706:  707:  708:  709:  710:  711:  712:  713:  714:  715:  716:  717:  718:  719:  720:  721:  722:  723:  724:  725:  726:  727:  728:  729:  730:  731:  732:  733:  734:  735:  736:  737:  738:  739:  740:  741:  742:  743:  744:  745:  746:  747:  748:  749:  750:  751:  752:  753:  754:  755:  756:  757:  758:  759:  760:  761:  762:  763:  764:  765:  766:  767:  768:  769:  770:  771:  772:  773:  774:  775:  776:  777:  778:  779:  780:  781:  782:  783:  784:  785:  786:  787:  788:  789:  790:  791:  792:  793:  794:  795:  796:  797:  798:  799:  800:  801:  802:  803:  804:  805:  806:  807:  808:  809:  810:  811:  812:  813:  814:  815:  816:  817:  818:  819:  820:  821:  822:  823:  824:  825:  826:  827:  828:  829:  830:  831:  832:  833:  834:  835:  836:  837:  838:  839:  840:  841:  842:  843:  844:  845:  846:  847:  848:  849:  850:  851:  852:  853:  854:  855:  856:  857:  858:  859:  860:  861:  862:  863:  864:  865:  866:  867:  868:  869:  870:  871:  872:  873:  874:  875:  876:  877:  878:  879:  880:  881:  882:  883:  884:  885:  886:  887:  888:  889:  890:  891:  892:  893:  894:  895:  896:  897:  898:  899:  900:  901:  902:  903:  904:  905:  906:  907:  908:  909:  910:  911:  912:  913:  914:  915:  916:  917:  918:  919:  920:  921:  922:  923:  924:  925:  926:  927:  928:  929:  930:  931:  932:  933:  934:  935:  936:  937:  938:  939:  940:  941:  942:  943:  944:  945:  946:  947:  948:  949:  950:  951:  952:  953:  954:  955:  956:  957:  958:  959:  960:  961:  962:  963:  964:  965:  966:  967:  968:  969:  970:  971:  972:  973:  974:  975:  976:  977:  978:  979:  980:  981:  982:  983:  984:  985:  986:  987:  988:  989:  990:  991:  992:  993:  994:  995:  996:  997:  998:  999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 
<?php
/**
 * Generates individually sitemap.org compatible XML files for use with Google and other search engines.
 * It supports albums and images as well as optionally Zenpage pages, news articles and news categories.
 * Sitemaps need to be generated via the button on the admin overview page and are cached as static
 * files in the <var>/%STATIC_CACHE_FOLDER%/sitemap/</var> folder.
 * Individual sitemaps are generated for all of the above item types as well as a sitemapindex file.
 * Album sitemaps are split into individual sitemaps per album (incl. all albums pages) and image sitemaps
 * into individual sitemaps per album.
 *
 * Based on the plugin by Jeppe Toustrup (Tenzer) http://github.com/Tenzer/zenphoto-sitemap 
 *
 * The sitemapindex file can be referenced via <var>www.yourdomain.com/zenphoto/index.php?sitemap</var> or
 * with modrewrite <var>www.yourdomain.com/zenphoto/?sitemap</var>.
 *
 * <b>IMPORTANT:</b> A multilingual sitemap requires the <var>dynamic-locale</var> plugin and either the <var>seo_locale</var> plugin or <i>language subdomains</i>.
 *
 * @author Malte Müller (acrylian), Jeppe Toustrup (Tenzer), timo, Blue Dragonfly and Francois Marechal (frankm)
 * @package plugins
 * @subpackage sitemap-extended
 */
$plugin_is_filter = 0 | CLASS_PLUGIN;
$plugin_description = gettext('Generates sitemap.org compatible XML files for use with Google and other search engines.');
$plugin_notice = gettext('<strong>Note:</strong> The index links may not match if using the Zenpage option "news on index" that some themes provide! Also it does not "know" about "custom pages" outside Zenpage or any special custom theme setup!!');
$plugin_author = 'Malte Müller (acrylian), Jeppe Toustrup (Tenzer), timo, Blue Dragonfly and Francois Marechal (frankm)';
$plugin_category = gettext('SEO');
$option_interface = 'sitemapOptions';

zp_register_filter('admin_utilities_buttons', 'sitemap::button');

$sitemapfolder = SERVERPATH . '/' . STATIC_CACHE_FOLDER . '/sitemap';
if (!file_exists($sitemapfolder)) {
    if (!mkdir_recursive($sitemapfolder, FOLDER_MOD)) {
        die(gettext("sitemap cache folder could not be created. Please try to create it manually via FTP with chmod 0777."));
    }
}
if (getOption('sitemap_galleryindex')) {
    purgeOption('sitemap_galleryindex');
}
define('SITEMAP_CHUNK', getOption('sitemap_processing_chunk'));
define('GOOGLE_SITEMAP', getOption('sitemap_google'));
if (getOption('multi_lingual') && defined('LOCALE_TYPE')) {
    define('SITEMAP_LOCALE_TYPE', LOCALE_TYPE);
} else {
    define('SITEMAP_LOCALE_TYPE', 0);
}

/**
 * Plugin option handling class
 *
 */
class sitemapOptions {

    var $startmtime;
    var $disable = false; // manual disable caching a page

    function __construct() {
        setOptionDefault('sitemap_changefreq_index', 'daily');
        setOptionDefault('sitemap_changefreq_albums', 'daily');
        setOptionDefault('sitemap_changefreq_images', 'daily');
        setOptionDefault('sitemap_changefreq_pages', 'weekly');
        setOptionDefault('sitemap_changefreq_newsindex', 'daily');
        setOptionDefault('sitemap_changefreq_news', 'daily');
        setOptionDefault('sitemap_changefreq_newscats', 'weekly');
        setOptionDefault('sitemap_lastmod_albums', 'mtime');
        setOptionDefault('sitemap_lastmod_images', 'mtime');
        setOptionDefault('sitemap_processing_chunk', 25);
        setOptionDefault('sitemap_google', 0);
        setOptionDefault('sitemap_google_fullimage', 0);
    }

    function getOptionsSupported() {
        global $_common_locale_type;
        $localdesc = '<p>' . gettext('If checked links to the alternative languages will be in the form <code><em>language</em>.domain</code> where <code><em>language</em></code> is the language code, e.g. <code><em>fr</em></code> for French.') . '</p>';
        if (!$_common_locale_type) {
            $localdesc .= '<p>' . gettext('This requires that you have created the appropriate subdomains pointing to your Zenphoto installation. That is <code>fr.mydomain.com/zenphoto/</code> must point to the same location as <code>mydomain.com/zenphoto/</code>. (Some providers will automatically redirect undefined subdomains to the main domain. If your provider does this, no subdomain creation is needed.)') . '</p>';
        }
        $options = array(
                gettext('Album date') => array(
                        'key' => 'sitemap_lastmod_albums',
                        'type' => OPTION_TYPE_SELECTOR,
                        'order' => 0,
                        'selections' => array(
                                gettext("date") => "date",
                                gettext("mtime") => "mtime",
                                gettext("last change date") => 'lastchange'),
                        'desc' => gettext('Field to use for the last modification date of albums.')),
                gettext('Image date') => array(
                        'key' => 'sitemap_lastmod_images',
                        'type' => OPTION_TYPE_SELECTOR,
                        'order' => 1,
                        'selections' => array(
                                gettext("date") => "date",
                                gettext("mtime") => "mtime",
                                gettext("last change date") => 'lastchange'),
                        'desc' => gettext('Field to use for the last modification date of images.')),
                gettext('Change frequency - Zenphoto index') => array(
                        'key' => 'sitemap_changefreq_index',
                        'type' => OPTION_TYPE_SELECTOR,
                        'order' => 2,
                        'selections' => array(gettext("always") => "always",
                                gettext("hourly") => "hourly",
                                gettext("daily") => "daily",
                                gettext("weekly") => "weekly",
                                gettext("monthly") => "monthly",
                                gettext("yearly") => "yearly",
                                gettext("never") => "never"),
                        'desc' => ''),
                gettext('Change frequency - albums') => array(
                        'key' => 'sitemap_changefreq_albums',
                        'type' => OPTION_TYPE_SELECTOR,
                        'order' => 3,
                        'selections' => array(gettext("always") => "always",
                                gettext("hourly") => "hourly",
                                gettext("daily") => "daily",
                                gettext("weekly") => "weekly",
                                gettext("monthly") => "monthly",
                                gettext("yearly") => "yearly",
                                gettext("never") => "never"),
                        'desc' => ''),
                gettext('Change frequency - images') => array(
                        'key' => 'sitemap_changefreq_images',
                        'type' => OPTION_TYPE_SELECTOR,
                        'order' => 4,
                        'selections' => array(gettext("always") => "always",
                                gettext("hourly") => "hourly",
                                gettext("daily") => "daily",
                                gettext("weekly") => "weekly",
                                gettext("monthly") => "monthly",
                                gettext("yearly") => "yearly",
                                gettext("never") => "never"),
                        'desc' => ''),
                gettext('Change frequency - Zenpage pages') => array(
                        'key' => 'sitemap_changefreq_pages',
                        'type' => OPTION_TYPE_SELECTOR,
                        'order' => 5,
                        'selections' => array(gettext("always") => "always",
                                gettext("hourly") => "hourly",
                                gettext("daily") => "daily",
                                gettext("weekly") => "weekly",
                                gettext("monthly") => "monthly",
                                gettext("yearly") => "yearly",
                                gettext("never") => "never"),
                        'desc' => ''),
                gettext('Change frequency - Zenpage news index') => array(
                        'key' => 'sitemap_changefreq_newsindex',
                        'type' => OPTION_TYPE_SELECTOR,
                        'order' => 6,
                        'selections' => array(gettext("always") => "always",
                                gettext("hourly") => "hourly",
                                gettext("daily") => "daily",
                                gettext("weekly") => "weekly",
                                gettext("monthly") => "monthly",
                                gettext("yearly") => "yearly",
                                gettext("never") => "never"),
                        'desc' => ''),
                gettext('Change frequency: Zenpage news articles') => array(
                        'key' => 'sitemap_changefreq_news',
                        'type' => OPTION_TYPE_SELECTOR,
                        'order' => 7,
                        'selections' => array(gettext("always") => "always",
                                gettext("hourly") => "hourly",
                                gettext("daily") => "daily",
                                gettext("weekly") => "weekly",
                                gettext("monthly") => "monthly",
                                gettext("yearly") => "yearly",
                                gettext("never") => "never"),
                        'desc' => ''),
                gettext('Change frequency - Zenpage news categories') => array(
                        'key' => 'sitemap_changefreq_newscats',
                        'type' => OPTION_TYPE_SELECTOR,
                        'order' => 8,
                        'selections' => array(gettext("always") => "always",
                                gettext("hourly") => "hourly",
                                gettext("daily") => "daily",
                                gettext("weekly") => "weekly",
                                gettext("monthly") => "monthly",
                                gettext("yearly") => "yearly",
                                gettext("never") => "never"),
                        'desc' => ''),
                gettext('Enable Google image and video extension') => array(
                        'key' => 'sitemap_google',
                        'type' => OPTION_TYPE_CHECKBOX,
                        'order' => 9,
                        'desc' => gettext('If checked, the XML output file will be formatted using the Google XML image and video extensions where applicable.') . '<p class="notebox">' . gettext('<strong>Note:</strong> Other search engines (Yahoo, Bing) might not be able to read your sitemap. Also the Google extensions cover only image and video formats. If you use custom file types that are not covered by Zenphoto standard plugins or types like .mp3, .txt and .html you should probably not use this or modify the plugin. Also, if your site is really huge think about if you really need this setting as the creation may cause extra workload of your server and result in timeouts') . '</p>'),
                gettext('Google image and video extension: Link full image ') => array(
                        'key' => 'sitemap_google_fullimage',
                        'type' => OPTION_TYPE_CHECKBOX,
                        'order' => 10,
                        'desc' => gettext('If checked, the original full image is referenced instead of the sized images in the cache. For image formats only.')),
                gettext('Google - URL to image license') => array(
                        'key' => 'sitemap_license',
                        'type' => OPTION_TYPE_TEXTBOX,
                        'order' => 12,
                        'multilingual' => false,
                        'desc' => gettext('Optional. Used only if the Google extension is checked. Must be an absolute URL address of the form: http://mydomain.com/license.html')),
                gettext('Sitemap processing chunk') => array(
                        'key' => 'sitemap_processing_chunk',
                        'type' => OPTION_TYPE_TEXTBOX,
                        'order' => 13,
                        'desc' => gettext('The number of albums that will be processed for each sitemap file. Lower this value if you get script timeouts when creating the files.')),
                gettext('Use subdomains') . '*' => array(
                        'key' => 'dynamic_locale_subdomain',
                        'type' => OPTION_TYPE_CHECKBOX,
                        'order' => 14,
                        'disabled' => $_common_locale_type,
                        'desc' => $localdesc)
        );
        if ($_common_locale_type) {
            $options['note'] = array(
                    'key' => 'sitemap_locale_type',
                    'type' => OPTION_TYPE_NOTE,
                    'order' => 15,
                    'desc' => '<p class="notebox">' . $_common_locale_type . '</p>');
        } else {
            $_common_locale_type = gettext('* This option may be set via the <a href="javascript:gotoName(\'sitemap-extended\');"><em>sitemap-extended</em></a> plugin options.');
            $options['note'] = array(
                    'key' => 'sitemap_locale_type',
                    'type' => OPTION_TYPE_NOTE,
                    'order' => 16,
                    'desc' => gettext('<p class="notebox">*<strong>Note:</strong> The setting of this option is shared with other plugins.</p>'));
        }
        return $options;
    }

    function handleOption($option, $currentValue) {
        
    }

}

if (isset($_GET['sitemap'])) {
    $sitemappath = SERVERPATH . '/' . STATIC_CACHE_FOLDER . '/sitemap/sitemapindex.xml';
    if (file_exists($sitemappath)) {
        $sitemapfile = file_get_contents($sitemappath);
        echo $sitemapfile;
    }
    exitZP();
}

/**
 * Sitemap class
 */
class sitemap {

    /**
     * creates the Utilities button to purge the static sitemap cache
     * @param array $buttons
     * @return array
     */
    static function button($buttons) {
        $buttons[] = array(
                'category' => gettext('Seo'),
                'enable' => true,
                'button_text' => gettext('Sitemap tools'),
                'formname' => 'sitemap_button',
                'action' => FULLWEBPATH . '/' . ZENFOLDER . '/' . PLUGIN_FOLDER . '/sitemap-extended/sitemap-extended-admin.php',
                'icon' => FULLWEBPATH . '/' . ZENFOLDER . '/images/cache.png',
                'title' => gettext('Generate or purge sitemap cache files.'),
                'alt' => '',
                'hidden' => '',
                'rights' => ADMIN_RIGHTS
        );
        return $buttons;
    }

    /**
     * Simple helper function which simply outputs a string and ends it of with a new-line.
     * @param  string $string text string
     * @return string
     */
    static function echonl($string) {
        return $string . "\n";
    }

    /**
     * Generates a sitemap file.
     *
     * @param string $filename How the file should be named. ".xml" is appended automatically
     * @param string $data The actual sitemap data as generated by the appropiate functions
     */
    static function generateCacheFile($filename, $data) {
        if (!empty($data)) {
            $filepath = SERVERPATH . '/' . STATIC_CACHE_FOLDER . '/sitemap/' . $filename . '.xml';
            $handler = fopen($filepath, 'w');
            fwrite($handler, $data);
            fclose($handler);
            echo '<li>' . $filename . '</li>';
        }
    }

    /**
     * Generates the sitemap index file that points to the individual sitemaps from the content of the sitemap cache.
     * It is always named "sitemapindex.xml"
     */
    static function generateIndexCacheFile() {
        $data = '';
        $cachefolder = SERVERPATH . '/' . STATIC_CACHE_FOLDER . '/sitemap/';
        $dirs = array_diff(scandir($cachefolder), array('.', '..', '.DS_Store', 'Thumbs.db', '.htaccess', '.svn'));
        if ($dirs) {
            $data .= sitemap::echonl('<?xml version="1.0" encoding="UTF-8"?>');
            $data .= sitemap::echonl('<sitemapindex xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/siteindex.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
            foreach ($dirs as $dir) {
                $data .= sitemap::echonl("\t<sitemap>");
                $data .= sitemap::echonl("\t\t<loc>" . FULLWEBPATH . '/' . STATIC_CACHE_FOLDER . '/sitemap/' . $dir . '</loc>');
                $data .= sitemap::echonl("\t\t<lastmod>" . sitemap::getISO8601Date() . '</lastmod>');
                $data .= sitemap::echonl("\t</sitemap>");
            }
            $data .= sitemap::echonl('</sitemapindex>');
            $filepath = SERVERPATH . '/' . STATIC_CACHE_FOLDER . '/sitemap/sitemapindex.xml';
            $handler = fopen($filepath, 'w');
            fwrite($handler, $data);
            fclose($handler);
            echo '<p>sitemapindex.xml created.</p>';
        }
    }

    /**
     * Checks the changefreq value if entered manually and makes sure it is only one of the supported regarding sitemap.org
     * @param  string $changefreq One of the supported changefrequence values regarding sitemap.org. Default is empty or wrong is "daily".
     * @return string
     */
    static function getChangefreq($changefreq = '') {
        $changefreq = sanitize($changefreq);
        switch ($changefreq) {
            case 'always':
            case 'hourly':
            case 'daily':
            case 'weekly':
            case 'monthly':
            case 'yearly':
            case 'never':
                $changefreq = $changefreq;
                break;
            default:
                $changefreq = 'daily';
                break;
        }
        return $changefreq;
    }

    /**
     * Gets the dateformat for images and albums only.
     * @param object $obj image or album object
     * @param  string $option "date" or "mtime". If "mtime" is discovered to be not set, the date values is taken instead so we don't get 1970-01-10 dates
     * @return string
     */
    static function getDateformat($obj, $option) {
        $date = '';
        switch ($option) {
            case 'date':
            default:
                $date = $obj->getDatetime();
                break;
            case 'mtime':
                $timestamp = $obj->get('mtime');
                if ($timestamp == 0) {
                    $date = $obj->getDatetime();
                } else {
                    return gmstrftime('%Y-%m-%dT%H:%M:%SZ', $timestamp);
                    // For more streamlined but PHP5-only equivalent, remove the above line and uncomment the following:
                    // return gmstrftime(DATE_ISO8601, $timestamp);
                }
                break;
            case 'lastchange':
                $date = sitemap::getLastChangeDate($obj, true);
                break;
        }
        return sitemap::getISO8601Date($date);
        // For more streamlined but PHP5-only equivalent, remove the above line and uncomment the following:
        // return gmstrftime(DATE_ISO8601, strtotime($date));
    }

    /**
     * Gets the limit and offset for the db queries for sitemap splitting.
     * @param  int $items_per_sitemap Number of items per sitemap
     * @return string
     */
    static function getDBLimit($items_per_sitemap = 2) {
        global $_sitemap_number;
        if ($_sitemap_number < 1) {
            $_sitemap_number = 1;
        }
        $offset = ($_sitemap_number - 1) * $items_per_sitemap;
        $limit = " LIMIT " . $offset . "," . $items_per_sitemap;
        return $limit;
    }

    /*   * TODO index links are not splitted into several sitemaps yet
     *
     * Gets the links to the index of a Zenphoto gallery incl. index pagination
     *
     * @return string
     */

    static function getIndexLinks() {
        global $_zp_gallery, $_sitemap_number;
        $data = '';
        if ($_sitemap_number < 2) {
            set_context(ZP_INDEX);
            $albums_per_page = getOption('albums_per_page');
            if (getOption('custom_index_page')) {
                $galleryindex = getCustomGalleryIndexURL(1, '');
            } else {
                $galleryindex = getStandardGalleryIndexURL(1, '');
            }
            $toplevelpages = getTotalPages();
            $data .= sitemap::echonl('<?xml version="1.0" encoding="UTF-8"?>');
            $data .= sitemap::echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
            $sitemap_locales = generateLanguageList();
            $changefreq = sitemap::getChangefreq(getOption('sitemap_changefreq_index'));
            // normal index/homepage we need in any case always
            $date = sitemap::getISO8601Date();
            switch (SITEMAP_LOCALE_TYPE) {
                case 1:
                    foreach ($sitemap_locales as $locale) {
                        $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . seo_locale::localePath(true, $locale) . "/</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                    }
                    break;
                case 2:
                    foreach ($sitemap_locales as $locale) {
                        $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . dynamic_locale::fullHostPath($locale) . "/</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                    }
                    break;
                default:
                    $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . FULLWEBPATH . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                    break;
            }
            // the extra ones if we have a custom gallery index
            if (getOption('custom_index_page')) {
                switch (SITEMAP_LOCALE_TYPE) {
                    case 1:
                        foreach ($sitemap_locales as $locale) {
                            $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . seo_locale::localePath(true, $locale) . '/' . $galleryindex . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                        }
                        break;
                    case 2:
                        foreach ($sitemap_locales as $locale) {
                            $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . dynamic_locale::fullHostPath($locale) . '/' . $galleryindex . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                        }
                        break;
                    default:
                        $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . FULLWEBPATH . $galleryindex . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                        break;
                }
            }
            // print further index pages if available
            if ($toplevelpages) {
                for ($x = 2; $x <= $toplevelpages; $x++) {
                    if (getOption('custom_index_page')) {
                        $galleryindex = getCustomGalleryIndexURL($x, '');
                    } else {
                        $galleryindex = getStandardGalleryIndexURL($x, '');
                    }
                    switch (SITEMAP_LOCALE_TYPE) {
                        case 1:
                            foreach ($sitemap_locales as $locale) {
                                $url = seo_locale::localePath(true, $locale) . $galleryindex;
                                $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            }
                            break;
                        case 2:
                            foreach ($sitemap_locales as $locale) {
                                $url = dynamic_locale::fullHostPath($locale) . $galleryindex;
                                $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            }
                            break;
                        default:
                            $url = FULLWEBPATH . $galleryindex;
                            $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            break;
                    }
                }
            }
            $data .= sitemap::echonl('</urlset>'); // End off the <urlset> tag
            restore_context();
            return $data;
        } // sitemap number end
    }

    /**
     *
     * Enter description here ...
     * @param object $obj the starting point
     * @param array $albumlist the container for the results
     */
    static function getAlbumList($obj, &$albumlist) {
        global $_zp_gallery;
        $locallist = $obj->getAlbums();
        foreach ($locallist as $folder) {
            $album = newAlbum($folder);
            if ($album->isPublic() && !$album->isProtected()) {
                $albumlist[] = array('folder' => $album->name, 'date' => $album->getDateTime(), 'title' => $album->getTitle());
                if (!$album->isDynamic()) {
                    sitemap::getAlbumList($album, $albumlist);
                }
            }
        }
    }

    /**
     * gateway check for albums (no refinement of the criteria)
     * 
     * @deprecated Unused
     * @param object $album
     */
    static function passAlbums($album) {
        return true;
    }

    /**
     * gateway function for images (screens out dynamic albums and password protected albums)
     * 
     * @deprecated Unused
     * @param object $album
     */
    static function passImages($album) {
        return !$album->isDynamic() && !$album->getPassword();
    }

    /**
     * Places album and all of its album pages on one sitemap
     *
     * Gets links to all albums incl. pagination and if the Google image video extension is enabled for images using this as well.
     * This is independent from the images fetched by getSitemapImages().
     *
     * NOTE: Using the Google extension is currently NOT recommended if you have a huge gallery.
     *
     * @return string
     */
    static function getAlbums() {
        global $_zp_gallery, $_sitemap_number;
        $data_start = $data = '';
        $sitemap_locales = generateLanguageList();
        $albumchangefreq = getOption('sitemap_changefreq_albums');
        $imagechangefreq = getOption('sitemap_changefreq_images');
        $albumlastmod = getOption('sitemap_lastmod_albums');
        $albumlastmod = sanitize($albumlastmod);
        $imagelastmod = getOption('sitemap_lastmod_images');
        $albums = array();
        sitemap::getAlbumList($_zp_gallery, $albums);
        $offset = ($_sitemap_number - 1);
        $albums = array_slice($albums, $offset, SITEMAP_CHUNK);
        if (!empty($albums)) {
            $data_start .= sitemap::echonl('<?xml version="1.0" encoding="UTF-8"?>');
            $data_start .= sitemap::echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
            foreach ($albums as $album) {
                $albumobj = newAlbum($album['folder']);
                set_context(ZP_ALBUM);
                makeAlbumCurrent($albumobj);
                $pageCount = getTotalPages();
                //$imageCount = getNumImages();
                //$images = $albumobj->getImages();
                $date = sitemap::getDateformat($albumobj, $albumlastmod);
                switch (SITEMAP_LOCALE_TYPE) {
                    case 1:
                        foreach ($sitemap_locales as $locale) {
                            $url = seo_locale::localePath(true, $locale) . '/' . pathurlencode($albumobj->linkname) . '/';
                            $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $albumchangefreq . "</changefreq>\n\t\t<priority>0.8</priority>\n");
                            $data .= sitemap::echonl("\t</url>");
                        }
                        break;
                    case 2:
                        foreach ($sitemap_locales as $locale) {
                            $url = rewrite_path(pathurlencode($albumobj->linkname) . '/', '?album=' . pathurlencode($albumobj->name), dynamic_locale::fullHostPath($locale));
                            $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $albumchangefreq . "</changefreq>\n\t\t<priority>0.8</priority>\n");
                            $data .= sitemap::echonl("\t</url>");
                        }
                        break;
                    default:
                        $url = rewrite_path(pathurlencode($albumobj->linkname) . '/', '?album=' . pathurlencode($albumobj->name), FULLWEBPATH);
                        $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $albumchangefreq . "</changefreq>\n\t\t<priority>0.8</priority>\n");
                        $data .= sitemap::echonl("\t</url>");
                        break;
                }
                // print album pages if avaiable
                if ($pageCount > 1) {
                    for ($x = 2; $x <= $pageCount; $x++) {
                        switch (SITEMAP_LOCALE_TYPE) {
                            case 1:
                                foreach ($sitemap_locales as $locale) {
                                    $url = seo_locale::localePath(true, $locale) . '/' . pathurlencode($albumobj->linkname) . '/' . _PAGE_ . '/' . $x . '/';
                                    $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $albumchangefreq . "</changefreq>\n\t\t<priority>0.8</priority>\n");
                                    $data .= sitemap::echonl("\t</url>");
                                }
                                break;
                            case 2:
                                foreach ($sitemap_locales as $locale) {
                                    $url = rewrite_path(pathurlencode($albumobj->linkname) . '/' . _PAGE_ . '/' . $x . '/', '?album=' . pathurlencode($albumobj->name) . '&amp;page=' . $x, dynamic_locale::fullHostPath($locale));
                                    $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $albumchangefreq . "</changefreq>\n\t\t<priority>0.8</priority>\n");
                                    $data .= sitemap::echonl("\t</url>");
                                }
                                break;
                            default:
                                $url = rewrite_path(pathurlencode($albumobj->linkname) . '/' . _PAGE_ . '/' . $x . '/', '?album=' . pathurlencode($albumobj->name) . '&amp;page=' . $x, FULLWEBPATH);
                                $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $albumchangefreq . "</changefreq>\n\t\t<priority>0.8</priority>\n");
                                $data .= sitemap::echonl("\t</url>");
                                break;
                        }
                    }
                }
            }
            if (!empty($data)) {
                $data = $data_start . $data . sitemap::echonl('</urlset>'); // End off the <urlset> tag
            }
        }
        restore_context();
        return $data;
    }

    /**
     * currently this splitts only sitemaps for albums and its images. Spliting the images itself requires a major rework...
     *
     * Gets links to all images for all albums (album by album)
     *
     * @return string
     */
    static function getImages() {
        global $_zp_gallery, $_sitemap_number;
        $data_start = $data = '';
        $sitemap_locales = generateLanguageList();
        $imagechangefreq = getOption('sitemap_changefreq_images');
        $imagelastmod = getOption('sitemap_lastmod_images');
        $limit = sitemap::getDBLimit(1);
        $albums = array();
        sitemap::getAlbumList($_zp_gallery, $albums);
        $offset = ($_sitemap_number - 1);
        $albums = array_slice($albums, $offset, SITEMAP_CHUNK);
        if ($albums) {
            $data_start .= sitemap::echonl('<?xml version="1.0" encoding="UTF-8"?>');
            if (GOOGLE_SITEMAP) {
                $data_start .= sitemap::echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1">');
            } else {
                $data_start .= sitemap::echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
            }
            foreach ($albums as $album) {
                @set_time_limit(120); //    Extend script timeout to allow for gathering the images.
                $albumobj = newAlbum($album['folder']);
                $images = $albumobj->getImages();
                // print plain images links if available
                if ($images) {
                    foreach ($images as $image) {
                        $imageobj = newImage($albumobj, $image);
                        if($imageobj->isPublic() && !$albumobj->isDynamic()) {
                        $ext = getSuffix($imageobj->filename);
                        $date = sitemap::getDateformat($imageobj, $imagelastmod);
                        switch (SITEMAP_LOCALE_TYPE) {
                            case 1:
                                foreach ($sitemap_locales as $locale) {
                                    $path = seo_locale::localePath(true, $locale) . '/' . pathurlencode($albumobj->linkname) . '/' . urlencode($imageobj->filename) . IM_SUFFIX;
                                    $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $path . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $imagechangefreq . "</changefreq>\n\t\t<priority>0.6</priority>\n");
                                    if (GOOGLE_SITEMAP) {
                                        $data .= sitemap::getGoogleImageVideoExtras($albumobj, $imageobj, $locale);
                                    }
                                    $data .= sitemap::echonl("</url>");
                                }
                                break;
                            case 2:
                                foreach ($sitemap_locales as $locale) {
                                    $path = rewrite_path(pathurlencode($albumobj->linkname) . '/' . urlencode($imageobj->filename) . IM_SUFFIX, '?album=' . pathurlencode($albumobj->name) . '&amp;image=' . urlencode($imageobj->filename), dynamic_locale::fullHostPath($locale));
                                    $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $path . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $imagechangefreq . "</changefreq>\n\t\t<priority>0.6</priority>\n");
                                    if (GOOGLE_SITEMAP) {
                                        $data .= sitemap::getGoogleImageVideoExtras($albumobj, $imageobj, $locale);
                                    }
                                    $data .= sitemap::echonl("</url>");
                                }
                                break;
                            default:
                                $path = rewrite_path(pathurlencode($albumobj->linkname) . '/' . urlencode($imageobj->filename) . IM_SUFFIX, '?album=' . pathurlencode($albumobj->name) . '&amp;image=' . urlencode($imageobj->filename), FULLWEBPATH);
                                $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $path . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $imagechangefreq . "</changefreq>\n\t\t<priority>0.6</priority>\n");
                                if (GOOGLE_SITEMAP) {
                                    $data .= sitemap::getGoogleImageVideoExtras($albumobj, $imageobj, NULL);
                                }
                                $data .= sitemap::echonl("</url>");
                                break;
                        }
                    }
                }
            }
            }
            if (!empty($data)) {
                $data = $data_start . $data . sitemap::echonl('</urlset>'); // End off the <urlset> tag
            }
        }
        return $data;
    }

    /**
     * Helper function to get the loop index if the Google video extension is enabled
     */
    static function getGoogleLoopIndex($imageCount, $pageCount) {
        if (GOOGLE_SITEMAP) {
            $loop_index = array();
            for ($x = 1; $x <= $pageCount; $x++) {
                if ($imageCount < ($x * getOption('images_per_page'))) {
                    $val = $imageCount - (($x - 1) * getOption('images_per_page'));
                } else {
                    $val = getOption('images_per_page');
                }
                array_push($loop_index, $val);
            }
            return $loop_index;
        }
        return NULL;
    }

    /**
     * Helper function to get the image/video extra entries for albums if the Google video extension is enabled
     * @return string
     */
    static function getGoogleImageVideoExtras($albumobj, $imageobj, $locale) {
        $data = '';
        $host = PROTOCOL . '://' . html_encode($_SERVER["HTTP_HOST"]);
        $ext = strtolower(strrchr($imageobj->filename, "."));
        $location = '';
        if ($imageobj->getLocation()) {
            $location .= $imageobj->getLocation($locale) . ', ';
        }
        if ($imageobj->getCity()) {
            $location .= $imageobj->getCity($locale) . ', ';
        }
        if ($imageobj->getState()) {
            $location .= $imageobj->getState($locale) . ', ';
        }
        if ($imageobj->getCountry()) {
            $location .= $imageobj->getCountry($locale);
        }
        $license = getOption('sitemap_license');
        if (empty($license)) {
            $license = $imageobj->getCopyrightURL();
        }
        if (isImageVideo($imageobj) && in_array($ext, array('.mpg', '.mpeg', '.mp4', '.m4v', '.mov', '.wmv', '.asf', '.avi', '.ra', '.ram', '.flv', '.swf'))) { // google says it can index these so we list them even if unsupported by Zenphoto
            $data .= sitemap::echonl("\t\t<video:video>\n\t\t\t<video:thumbnail_loc>" . $host . html_encode($imageobj->getThumb()) . "</video:thumbnail_loc>\n");
            $data .= sitemap::echonl("\t\t\t<video:title>" . html_encode($imageobj->getTitle($locale)) . "</video:title>");
            if ($imageobj->getDesc()) {
                $data .= sitemap::echonl("\t\t\t<video:description>" . html_encode(getBare($imageobj->getDesc($locale))) . "</video:description>");
            }
            $data .= sitemap::echonl("\t\t\t<video:content_loc>" . $host . pathurlencode($imageobj->getFullImageURL()) . "</video:content_loc>");
            $data .= sitemap::echonl("\t\t</video:video>");
        } else if (in_array($ext, array('.jpg', '.jpeg', '.gif', '.png'))) { // this might need to be extended!
            if (getOption('sitemap_google_fullimage')) {
                $imagelocation = $host . pathurlencode($imageobj->getFullImageURL());
            } else {
                $imagelocation = $host . html_encode($imageobj->getSizedImage(getOption('image_size')));
            }
            $data .= sitemap::echonl("\t\t<image:image>\n\t\t\t<image:loc>" . html_encode($imagelocation) . "</image:loc>\n");
            // disabled for the multilingual reasons above
            $data .= sitemap::echonl("\t\t\t<image:title>" . html_encode($imageobj->getTitle($locale)) . "</image:title>");
            if ($imageobj->getDesc()) {
                $data .= sitemap::echonl("\t\t\t<image:caption>" . html_encode(getBare($imageobj->getDesc($locale))) . "</image:caption>");
            }
            if (!empty($license)) {
                $data .= sitemap::echonl("\t\t\t<image:license>" . html_encode($license) . "</image:license>");
            }
            // location is kept although the same multilingual issue applies
            if (!empty($location)) {
                $data .= sitemap::echonl("\t\t\t<image:geo_location>" . html_encode($location) . "</image:geo_location>");
            }
            $data .= sitemap::echonl("\t\t</image:image>");
        }
        return $data;
    }

    /**
     * Gets links to all Zenpage pages
     *
     * @return string
     */
    static function getZenpagePages() {
        global $_zp_zenpage, $_sitemap_number;
        //not splitted into several sitemaps yet
        if ($_sitemap_number == 1) {
            $data_start = $data = '';
            $limit = sitemap::getDBLimit(2);
            $sitemap_locales = generateLanguageList();
            $changefreq = getOption('sitemap_changefreq_pages');
            $pages = $_zp_zenpage->getPages(true);
            if ($pages) {
                $data_start .= sitemap::echonl('<?xml version="1.0" encoding="UTF-8"?>');
                $data_start .= sitemap::echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
                foreach ($pages as $page) {
                    $pageobj = new ZenpagePage($page['titlelink']);
                    if ($pageobj->isPublic() && !$pageobj->isProtected()) {
                        $date = sitemap::getLastChangeDate($pageobj, false);
                            switch (SITEMAP_LOCALE_TYPE) {
                                case 1:
                                    foreach ($sitemap_locales as $locale) {
                                        $url = seo_locale::localePath(true, $locale) . '/' . _PAGES_ . '/' . urlencode($page['titlelink']) . '/';
                                        $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    }
                                    break;
                                case 2:
                                    foreach ($sitemap_locales as $locale) {
                                        $url = rewrite_path(_PAGES_ . '/' . urlencode($page['titlelink']) . '/', '?p=pages&amp;title=' . urlencode($page['titlelink']), dynamic_locale::fullHostPath($locale));
                                        $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    }
                                    break;
                                default:
                                    $url = rewrite_path(_PAGES_ . '/' . urlencode($page['titlelink']) . '/', '?p=pages&amp;title=' . urlencode($page['titlelink']), FULLWEBPATH);
                                    $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    break;
                            }
                        }
        
                }
                if (!empty($data)) {
                    $data = $data_start . $data . sitemap::echonl('</urlset>'); // End off the <urlset> tag
                }
            }
            return $data;
        }
    }

    /**
     * Gets links to the main Zenpage news index incl. pagination
     *
     * @return string
     */
    static function getZenpageNewsIndex() {
        global $_zp_zenpage, $_sitemap_number;
        //not splitted into several sitemaps yet
        if ($_sitemap_number == 1) {
            $data = '';
            $data .= sitemap::echonl('<?xml version="1.0" encoding="UTF-8"?>');
            $data .= sitemap::echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
            $sitemap_locales = generateLanguageList();
            $changefreq = getOption('sitemap_changefreq_newsindex');
            $date = sitemap::getISO8601Date();
            switch (SITEMAP_LOCALE_TYPE) {
                case 1:
                    foreach ($sitemap_locales as $locale) {
                        $url = seo_locale::localePath(true, $locale) . '/' . _NEWS_ . '/1/';
                        $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                    }
                    Break;
                case 2:
                    foreach ($sitemap_locales as $locale) {
                        $url = rewrite_path(_NEWS_ . '/1/', '?p=news&amp;page=1', dynamic_locale::fullHostPath($locale));
                        $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                    }
                    Break;
                default:
                    $url = rewrite_path(_NEWS_ . '/1/', '?p=news&amp;page=1', FULLWEBPATH);
                    $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                    Break;
            }
            // getting pages for the main news loop
            /* Not used anyway
              if(!empty($articlesperpage)) {
              $zenpage_articles_per_page = sanitize_numeric($articlesperpage);
              } else {
              $zenpage_articles_per_page = ZP_ARTICLES_PER_PAGE;
              } */
            $zenpage_articles_per_page = ZP_ARTICLES_PER_PAGE;
            $newspages = ceil($_zp_zenpage->getTotalArticles() / $zenpage_articles_per_page);
            if ($newspages > 1) {
                for ($x = 2; $x <= $newspages; $x++) {
                    switch (SITEMAP_LOCALE_TYPE) {
                        case 1:
                            foreach ($sitemap_locales as $locale) {
                                $url = seo_locale::localePath(true, $locale) . '/' . _NEWS_ . '/' . $x . '/';
                                $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            }
                            break;
                        case 2:
                            foreach ($sitemap_locales as $locale) {
                                $url = rewrite_path(_NEWS_ . '/' . $x . '/', '?p=news&amp;page=' . $x, dynamic_locale::fullHostPath($locale));
                                $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            }
                            break;
                        default:
                            $url = rewrite_path(_NEWS_ . '/' . $x . '/', '?p=news&amp;page=' . $x, FULLWEBPATH);
                            $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                            break;
                    }
                }
            }
            $data .= sitemap::echonl('</urlset>'); // End off the <urlset> tag
            return $data;
        }
    }

    /**
     * Gets to the Zenpage news articles
     *
     * @param  string $changefreq One of the supported changefrequence values regarding sitemap.org. Default is empty or wrong is "daily".
     * @return string
     */
    static function getZenpageNewsArticles() {
        global $_zp_zenpage, $_sitemap_number;
        //not splitted into several sitemaps yet
        if ($_sitemap_number == 1) {
            $data_start = $data = '';
            $sitemap_locales = generateLanguageList();
            $changefreq = getOption('sitemap_changefreq_news');
            $articles = $_zp_zenpage->getArticles('', 'published', true, "date", "desc");
            if ($articles) {
                $data_start .= sitemap::echonl('<?xml version="1.0" encoding="UTF-8"?>');
                $data_start .= sitemap::echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
                foreach ($articles as $article) {
                    $articleobj = new ZenpageNews($article['titlelink']);
                    if ($articleobj->isPublic() && !$articleobj->isProtected()) {
                        $date = sitemap::getLastChangeDate($articleobj, false);
                            switch (SITEMAP_LOCALE_TYPE) {
                                case 1:
                                    foreach ($sitemap_locales as $locale) {
                                        $url = seo_locale::localePath(true, $locale) . '/' . _NEWS_ . '/' . urlencode($articleobj->getTitlelink()) . '/';
                                        $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    }
                                    break;
                                case 2:
                                    foreach ($sitemap_locales as $locale) {
                                        $url = rewrite_path(_NEWS_ . '/' . urlencode($articleobj->getTitlelink()) . '/', '?p=news&amp;title=' . urlencode($articleobj->getTitlelink()), dynamic_locale::fullHostPath($locale));
                                        $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    }
                                    break;
                                default:
                                    $url = rewrite_path(_NEWS_ . '/' . urlencode($articleobj->getTitlelink()) . '/', '?p=news&amp;title=' . urlencode($articleobj->getTitlelink()), FULLWEBPATH);
                                    $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<lastmod>" . $date . "</lastmod>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    break;
                            }
                        }
                    }
                if (!empty($data)) {
                    $data = $data_start . $data . sitemap::echonl('</urlset>'); // End off the <urlset> tag
                }
            }
            return $data;
        }
    }

    /**
     * Gets links to Zenpage news categories incl. pagination
     *
     * @return string
     */
    static function getZenpageNewsCategories() {
        global $_zp_zenpage, $_sitemap_number;
        //TODO not splitted into several sitemaps yet
        if ($_sitemap_number == 1) {
            $data_start = $data = '';
            $sitemap_locales = generateLanguageList();
            $changefreq = getOption('sitemap_changefreq_newscats');
            $newscats = $_zp_zenpage->getAllCategories();
            if ($newscats) {
                $data_start .= sitemap::echonl('<?xml version="1.0" encoding="UTF-8"?>');
                $data_start .= sitemap::echonl('<urlset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">');
                foreach ($newscats as $newscat) {
                    $catobj = new ZenpageCategory($newscat['titlelink']);
                    if ($catobj->isPublic() && !$catobj->isProtected()) {
                            switch (SITEMAP_LOCALE_TYPE) {
                                case 1:
                                    foreach ($sitemap_locales as $locale) {
                                        $url = seo_locale::localePath(true, $locale) . '/' . _CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/1/';
                                        $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    }
                                    break;
                                case 2:
                                    foreach ($sitemap_locales as $locale) {
                                        $url = rewrite_path(_CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/1/', '?p=news&amp;category=' . urlencode($catobj->getTitlelink()) . '&amp;page=1', dynamic_locale::fullHostPath($locale));
                                        $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    }
                                    break;
                                default:
                                    $url = rewrite_path(_CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/1/', '?p=news&amp;category=' . urlencode($catobj->getTitlelink()) . '&amp;page=1', FULLWEBPATH);
                                    $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                    break;
                            }
                            // getting pages for the categories
                            /*
                              if(!empty($articlesperpage)) {
                              $zenpage_articles_per_page = sanitize_numeric($articlesperpage);
                              } else {
                              $zenpage_articles_per_page = ZP_ARTICLES_PER_PAGE;
                              } */
                            $zenpage_articles_per_page = ZP_ARTICLES_PER_PAGE;
                            $articlecount = count($catobj->getArticles());
                            $catpages = ceil($articlecount / $zenpage_articles_per_page);
                            if ($catpages > 1) {
                                for ($x = 2; $x <= $catpages; $x++) {
                                    switch (SITEMAP_LOCALE_TYPE) {
                                        case 1:
                                            foreach ($sitemap_locales as $locale) {
                                                $url = seo_locale::localePath(true, $locale) . '/' . _CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/' . $x . '/';
                                                $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                            }
                                            break;
                                        case 2:
                                            foreach ($sitemap_locales as $locale) {
                                                $url = rewrite_path(_CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/' . $x . '/', '?p=news&amp;category=' . urlencode($catobj->getTitlelink()) . '&amp;page=' . $x, dynamic_locale::fullHostPath($locale));
                                                $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                            }
                                            break;
                                        default:
                                            $url = rewrite_path(_CATEGORY_ . '/' . urlencode($catobj->getTitlelink()) . '/' . $x . '/', '?p=news&amp;category=' . urlencode($catobj->getTitlelink()) . '&amp;page=' . $x, FULLWEBPATH);
                                            $data .= sitemap::echonl("\t<url>\n\t\t<loc>" . $url . "</loc>\n\t\t<changefreq>" . $changefreq . "</changefreq>\n\t\t<priority>0.9</priority>\n\t</url>");
                                            break;
                                    }
                                }
                            }
                        }
                    }

                if (!empty($data)) {
                    $data = $data_start . $data . sitemap::echonl('</urlset>'); // End off the <urlset> tag
                }
            }
            return $data;
        }
    }

    /**
     * Cleans out the cache folder.
     *
     */
    static function clearCache() {
        $cachefolder = SERVERPATH . '/' . STATIC_CACHE_FOLDER . '/sitemap/';
        if (is_dir($cachefolder)) {
            $handle = opendir($cachefolder);
            while (false !== ($filename = readdir($handle))) {
                $fullname = $cachefolder . '/' . $filename;
                if (is_dir($fullname) && !(substr($filename, 0, 1) == '.')) {
                    if (($filename != '.') && ($filename != '..')) {
                        RSS::clearRSSCache($fullname);
                        rmdir($fullname);
                    }
                } else {
                    if (file_exists($fullname) && !(substr($filename, 0, 1) == '.')) {
                        @chmod($fullname, 0777);
                        unlink($fullname);
                    }
                }
            }
            closedir($handle);
        }
    }

    /**
     * Returns an ISO-8601 compliant date/time string for the given date/time.
     * While PHP5 can use the date format constant DATE_ISO8601, this function is designed to allow PHP4 use as well.
     * Eventually it can be deprecated, by:
     *   1. Replacing parameterless references to this function with date(DATE_ISO8601)
     *   2. Replacing references to this function in sitemap_getDateformat as documented there
     *
     */
    static function getISO8601Date($date = '') {
        if (empty($date)) {
            return gmstrftime('%Y-%m-%dT%H:%M:%SZ');
        } else {
            return gmstrftime('%Y-%m-%dT%H:%M:%SZ', strtotime($date));
        }
    }

    static function printAvailableSitemaps() {
        $cachefolder = SERVERPATH . '/' . STATIC_CACHE_FOLDER . '/sitemap/';
        $dirs = array_diff(scandir($cachefolder), array('.', '..', '.DS_Store', 'Thumbs.db', '.htaccess', '.svn'));
        echo '<h2>' . gettext('Available sitemap files:') . '</h2>';
        if (!$dirs) {
            echo '<p>' . gettext('No sitemap files available.') . '</p>';
        } else {
            echo '<ol>';
            foreach ($dirs as $dir) {
                $filemtime = filemtime($cachefolder . $dir);
                $lastchange = date('Y-m-d H:m:s', $filemtime);
                ?>
                <li><a target="_blank" href="<?php echo FULLWEBPATH . '/' . STATIC_CACHE_FOLDER; ?>/sitemap/<?php echo $dir; ?>"><?php echo $dir; ?></a> (<small><?php echo $lastchange; ?>)</small>
                </li>
                <?php
            }
            echo '</ol>';
        }
    }

    /**
     * Gets the date as Y-m-d or if available last change date of $obj
     * 
     * @param obj $obj
     * @param bool $fulldate True to return the full date incl. time, otherwise the date only
     * @return string
     */
    static function getLastChangeDate($obj, $fulldate = false) {
        $date = $obj->getDatetime();
        if (!$fulldate) {
            $date = substr($date, 0, 10);
        }
        $lastchange = '';
        if (!is_null($obj->getLastchange())) {
            $lastchange = $obj->getLastchange();
            if (!$fulldate) {
                $lastchange = substr($lastchange, 0, 10);
            }
        }
        if ($date > $lastchange && !empty($lastchange)) {
            return $lastchange;
        }
        return $date;
    }

}
ZenphotoCMS 1.5.x API documentation generated by ApiGen