Overview

Packages

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

Classes

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

Exceptions

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

Functions

  • __autoload
  • _escape_xref
  • _recaptcha_aes_encrypt
  • _recaptcha_aes_pad
  • _recaptcha_http_post
  • _recaptcha_mailhide_email_parts
  • _recaptcha_mailhide_urlbase64
  • _recaptcha_qsencode
  • accessAllAlbums
  • add_context
  • addalbumsToDatabase
  • addCategoriesToDatabase
  • addGeoCoord
  • addItem
  • addPagesToDatabase
  • addPluginScript
  • addPluginType
  • addSubalbumMenus
  • admin_album_list
  • admin_securityChecks
  • admin_showupdate
  • adminPageNav
  • adminToolbox
  • albumNumber
  • applyMacros
  • Auth_OpenID_arrangeByType
  • Auth_OpenID_AX_checkAlias
  • Auth_OpenID_AX_toTypeURIs
  • Auth_OpenID_bestMatchingService
  • Auth_OpenID_checkFieldName
  • Auth_OpenID_checkSessionType
  • Auth_OpenID_checkTimestamp
  • Auth_OpenID_detectMathLibrary
  • Auth_OpenID_discover
  • Auth_OpenID_discoverURI
  • Auth_OpenID_discoverWithoutYadis
  • Auth_OpenID_discoverWithYadis
  • Auth_OpenID_discoverXRI
  • Auth_OpenID_extractReturnURL
  • Auth_OpenID_findOPLocalIdentifier
  • Auth_OpenID_getAllAssociationTypes
  • Auth_OpenID_getAllowedReturnURLs
  • Auth_OpenID_getAuthorityPattern
  • Auth_OpenID_getAvailableSessionTypes
  • Auth_OpenID_getDefaultAssociationOrder
  • Auth_OpenID_getDefaultGen
  • Auth_OpenID_getDefaultMod
  • Auth_OpenID_getDefaultNegotiator
  • Auth_OpenID_getEncodedPattern
  • Auth_OpenID_getEncryptedNegotiator
  • Auth_OpenID_getEscapeRE
  • Auth_OpenID_getMathLib
  • Auth_OpenID_getOnlyEncryptedOrder
  • Auth_OpenID_getOpenIDConsumerTypeURIs
  • Auth_OpenID_getOpenIDTypeName
  • Auth_OpenID_getOpenIDTypeURIs
  • Auth_OpenID_getOPOrUserServices
  • Auth_OpenID_getSecretSize
  • Auth_OpenID_getSessionTypes
  • Auth_OpenID_getSupportedAssociationTypes
  • Auth_OpenID_getUnreserved
  • Auth_OpenID_getURIPattern
  • Auth_OpenID_getURLIllegalCharRE
  • Auth_OpenID_HMACSHA1
  • Auth_OpenID_HMACSHA256
  • Auth_OpenID_include_init
  • Auth_OpenID_isError
  • Auth_OpenID_isOpenID1
  • Auth_OpenID_legacy_discover
  • Auth_OpenID_makeOpenIDEndpoints
  • Auth_OpenID_math_extensions
  • Auth_OpenID_mkNonce
  • Auth_OpenID_noMathSupport
  • Auth_OpenID_pct_encoded_replace
  • Auth_OpenID_pct_encoded_replace_unreserved
  • Auth_OpenID_registerNamespaceAlias
  • Auth_OpenID_remove_dot_segments
  • Auth_OpenID_removeNamespaceAlias
  • Auth_OpenID_returnToMatches
  • Auth_OpenID_setNoMathSupport
  • Auth_OpenID_SHA1
  • Auth_OpenID_SHA256
  • Auth_OpenID_splitNonce
  • Auth_OpenID_supportsSReg
  • Auth_OpenID_urinorm
  • Auth_OpenID_verifyReturnTo
  • Auth_Yadis_array_scramble
  • Auth_Yadis_escapeForIRI
  • Auth_Yadis_getCanonicalID
  • Auth_Yadis_getDefaultProxy
  • Auth_Yadis_getEscapeRE
  • Auth_Yadis_getIPrivateChars
  • Auth_Yadis_getNSMap
  • Auth_Yadis_getServiceEndpoints
  • Auth_Yadis_getSupportedExtensions
  • Auth_Yadis_getUCSChars
  • Auth_Yadis_getXMLParser
  • Auth_Yadis_getXRDExpiration
  • Auth_Yadis_getXrefRE
  • Auth_Yadis_getXRIAuthorities
  • Auth_Yadis_identifierScheme
  • Auth_Yadis_iriToURI
  • Auth_Yadis_pct_escape_unicode
  • Auth_Yadis_providerIsAuthoritative
  • Auth_Yadis_rootAuthority
  • Auth_Yadis_setDefaultParser
  • Auth_Yadis_startswith
  • Auth_Yadis_toIRINormal
  • Auth_Yadis_toURINormal
  • Auth_Yadis_XRI
  • Auth_Yadis_XRIAppendArgs
  • authorSelector
  • build_query
  • build_url
  • bulkActionRedirect
  • bulkTags
  • byteConvert
  • cacheImage
  • checkAccess
  • checkAlbumimagesort
  • checkAlbumParentid
  • checkAlbumPassword
  • checkChosenItemStatus
  • checkChosenMenuset
  • checked
  • checkFolder
  • checkForEmptyTitle
  • checkForGuest
  • checkForPage
  • checkForPassword
  • checkForUpdate
  • checkHitcounterDisplay
  • checkIfChecked
  • checkIfLockedNews
  • checkIfLockedPage
  • checkIfNew
  • checkInstall
  • checkLayoutUseForImages
  • checkNewsAccess
  • checkNewsCategoryPassword
  • checkObjectsThumb
  • checkPagePassword
  • checkPageValidity
  • checkParentLayouts
  • checkPublishDates
  • checkRequiredField
  • checkSelectedAlbum
  • checkSignature
  • cleanAlbum
  • cleanHTML
  • clearSitemapCache
  • clonedFrom
  • codeblocktabsJS
  • comment_form_addComment
  • comment_form_handle_comment
  • comment_form_PaginationJS
  • comment_form_postcomment
  • comment_form_print10Most
  • comment_form_visualEditor
  • commentFormUseCaptcha
  • commentReply
  • commentsAllowed
  • consolidatedEditMessages
  • copyLayoutSelection
  • copyThemeDirectory
  • countArticles
  • countCombiNews
  • createMenuIfNotExists
  • createRelatedItemsResultArray
  • cron_starter
  • currentRelativeURL
  • customOptions
  • dateDiff
  • datepickerJS
  • dateTimeConvert
  • db_affected_rows
  • db_close
  • db_collation
  • db_connect
  • db_count
  • db_create
  • db_create_table
  • db_error
  • db_fetch_assoc
  • db_fetch_row
  • db_free_result
  • db_getSQLmode
  • db_insert_id
  • db_LIKE_escape
  • db_list_fields
  • db_name
  • db_num_rows
  • db_permissions
  • db_quote
  • db_setSQLmode
  • db_show
  • db_software
  • db_table_update
  • db_truncate_table
  • debug404
  • debugLog
  • debugLogBacktrace
  • debugLogVar
  • defaultCodeblocks_codebox
  • deleteArticle
  • deleteCategory
  • deleteItem
  • deleteLayoutSelection
  • deletePage
  • deleteThemeDirectory
  • detect_fetcher
  • detect_math
  • detect_query_corruption
  • detect_random
  • detect_stores
  • detect_xml
  • dircopy
  • displayError
  • doIncludes
  • elFinder_admin_tabs
  • elFinder_tinymce
  • enableExtension
  • escape
  • executeRSS
  • exitZP
  • exposeZenPhotoInformations
  • extensionEnabled
  • fetchComments
  • filesystemToInternal
  • filter_extractReturnURL
  • filter_MatchesAnyOpenIDConsumerType
  • filter_MatchesAnyOpenIDType
  • filterImageQuery
  • fix_path_redirect
  • formatList
  • fullText
  • galleryAlbumsPerPage
  • genAlbumList
  • generateCaptcha
  • generateLanguageList
  • generateListFromArray
  • generateListFromFiles
  • generateRadiobuttonsFromArray
  • generateSitemapCacheFile
  • generateSitemapIndexCacheFile
  • generateUnorderedListFromArray
  • get_AnyFile_suffixes
  • get_context
  • get_filterScript
  • get_instance
  • get_language_string
  • getAdminThumb
  • getAlbumArray
  • getAlbumBreadcrumb
  • getAlbumBreadcrumbAdmin
  • getAlbumCustomData
  • getAlbumData
  • getAlbumDate
  • getAlbumDesc
  • getAlbumFolder
  • getAlbumGeodata
  • getAlbumId
  • getAlbumInherited
  • getAlbumLinkURL
  • getAlbumLocation
  • getAlbumPage
  • getAlbumPlace
  • getAlbumStatistic
  • getAlbumThumb
  • getAlbumTitle
  • getAlbumURL
  • getAllAccessibleAlbums
  • getAllAlbums
  • getAllArticleDates
  • getAllCategories
  • getAllDates
  • getAllowedTags
  • getAllSubAlbumIDs
  • getAllSubalbums
  • getAllTagsCount
  • getAllTagsFromAlbum
  • getAllTagsFromAlbum_multi_unique
  • getAllTagsFromZenpage
  • getAllTagsUnique
  • getAllTranslations
  • getAnnotatedAlbumTitle
  • getAnnotatedImageTitle
  • getArticles
  • getAuthor
  • getBare
  • getBareAlbumDesc
  • getBareAlbumTitle
  • getBareGalleryDesc
  • getBareGalleryTitle
  • getBareImageDesc
  • getBareImageTitle
  • getBareNewsAlbumTitle
  • getBareNewsTitle
  • getBarePageTitle
  • getCategory
  • getCategoryID
  • getCategoryLink
  • getCategoryParentID
  • getCategorySortOrder
  • getCategoryTitle
  • getCheckboxState
  • getCodeblock
  • getCombiNews
  • getCommentAddress
  • getCommentAuthorEmail
  • getCommentAuthorLink
  • getCommentAuthorName
  • getCommentAuthorSite
  • getCommentBody
  • getCommentCount
  • getCommentDate
  • getCommentDateTime
  • getCommentErrors
  • getCommentsAllowed
  • getCommentStored
  • getCommentTime
  • getConsumer
  • getContentShorten
  • getCurrentMenuItem
  • getCurrentNewsArchive
  • getCurrentNewsCategory
  • getCurrentNewsCategoryID
  • getCurrentNewsCategoryParentID
  • getCurrentNewsPage
  • getCurrentPage
  • getCurrentTheme
  • getCustomAlbumThumb
  • getCustomAlbumThumbMaxSpace
  • getCustomImageURL
  • getCustomPageURL
  • getCustomSizedImageMaxSpace
  • getCustomSizedImageThumbMaxSpace
  • getDefaultHeight
  • getDefaultSizedImage
  • getDefaultWidth
  • getDownloadLink
  • getdownloadList
  • getDownloadURL
  • getE
  • getEnabledPlugins
  • getExpiryDatePost
  • getFavoritesURL
  • getField
  • getFirstImageURL
  • getFullHeight
  • getFullImageURL
  • getFullNewsImage
  • getFullWidth
  • getGalleryDesc
  • getGalleryIndexURL
  • getGalleryTitle
  • getGeoCoord
  • getHeadTitle
  • getHitcounter
  • getImageArgs
  • getImageCacheFilename
  • getImageCachePostfix
  • getImageCity
  • getImageCountry
  • getImageCustomData
  • getImageData
  • getImageDate
  • getImageDesc
  • getImageEXIFData
  • getImageGeodata
  • getImageID
  • getImageLinkURL
  • getImageLocation
  • getImageMetaData
  • getImageParameters
  • getImageProcessorURI
  • getImageProcessorURIFromCacheName
  • getImageRotation
  • getImageSortOrder
  • getImageState
  • getImageStatistic
  • getImageThumb
  • getImageTitle
  • getImageURI
  • getImageURL
  • getItem
  • getItemByID
  • getItemTitleAndURL
  • getjPlayerSkinCSS
  • getjPlayerSkins
  • getLanguageArray
  • getLanguageFlag
  • getLastImageURL
  • getLatestComments
  • getLatestNews
  • getLatestZenpageComments
  • getLayout
  • getLayoutSelector
  • getLink
  • getLinkHTML
  • getLogTabs
  • getMacros
  • getMainSiteName
  • getMainSiteURL
  • getManagedAlbumList
  • getMaxSpaceContainer
  • getMenuFromLink
  • getMenuItemChilds
  • getMenuItems
  • getMenumanagerPredicessor
  • getMenumanagerSuccessor
  • getMenuSetSelector
  • getMenuVisibility
  • getMimeString
  • getNestedAlbumList
  • getNewsAdminOption
  • getNewsAdminOptionPath
  • getNewsAlbumName
  • getNewsAlbumTitle
  • getNewsAlbumURL
  • getNewsArchivePath
  • getNewsArchiveURL
  • getNewsAuthor
  • getNewsCategories
  • getNewsCategoryCustomData
  • getNewsCategoryDesc
  • getNewsCategoryPath
  • getNewsCategoryURL
  • getNewsContent
  • getNewsContentShorten
  • getNewsCustomData
  • getNewsDate
  • getNewsExtraContent
  • getNewsID
  • getNewsImageTags
  • getNewsIndexURL
  • getNewsLink
  • getNewsPagesStatistic
  • getNewsPathNav
  • getNewsReadMore
  • getNewsTitle
  • getNewsTitleLink
  • getNewsTitlePath
  • getNewsType
  • getNewsURL
  • getNewsVideoContent
  • getNextAlbum
  • getNextAlbumURL
  • getNextImageThumb
  • getNextImageURL
  • getNextNewsPageURL
  • getNextNewsURL
  • getNextPageURL
  • getNextPrevNews
  • getNotViewableAlbums
  • getNotViewableImages
  • getNumAlbums
  • getNumAllSubalbums
  • getNumImages
  • getNumNews
  • getNumPages
  • getNumSubalbums
  • getOpenIDURL
  • getOption
  • getOptionFromDB
  • getOptionList
  • getPageAuthor
  • getPageContent
  • getPageCustomData
  • getPageDate
  • getPageExtraContent
  • getPageID
  • getPageLastChangeDate
  • getPageLinkPath
  • getPageLinkURL
  • getPageNavList
  • getPageNumURL
  • getPageParentID
  • getPageRedirect
  • getPages
  • getPageSelector
  • getPageSortorder
  • getPageTitle
  • getPageTitleLink
  • getPageURL
  • getParentAlbums
  • getParentAlbumsAdmin
  • getParentBreadcrumb
  • getParentItems
  • getParentMenuItems
  • getParentNewsCategories
  • getParentPages
  • getPasswordProtectImage
  • getPHPFiles
  • getPlugin
  • getPluginFiles
  • getPluginTabs
  • getPrevAlbum
  • getPrevAlbumURL
  • getPrevImageThumb
  • getPrevImageURL
  • getPrevNewsPageURL
  • getPrevNewsURL
  • getPrevPageURL
  • getProtectedImageURL
  • getRandomImages
  • getRandomImagesAlbum
  • getRating
  • getRelatedItems
  • getRequestURI
  • getReturnTo
  • getRSSHeaderLink
  • getRSSLink
  • getScheme
  • getSearchDate
  • getSearchURL
  • getSearchWords
  • getSelectedLayout
  • getSerializedArray
  • getSetClause
  • getSiteHomeURL
  • getSitemapAlbumList
  • getSitemapAlbums
  • getSitemapGoogleImageVideoExtras
  • getSitemapGoogleLoopIndex
  • getSitemapImages
  • getSitemapIndexLinks
  • getSitemapZenpageNewsArticles
  • getSitemapZenpageNewsCategories
  • getSitemapZenpageNewsIndex
  • getSitemapZenpagePages
  • getSizeCustomImage
  • getSizeDefaultImage
  • getSizeDefaultThumb
  • getSizedImageURL
  • getSizeFullImage
  • getStore
  • getSubCategories
  • getSubtabs
  • getSuffix
  • getTagCountByAccess
  • getTagOrder
  • getTags
  • gettext_pl
  • gettext_th
  • getTheme
  • getThemeFiles
  • getThemeOption
  • getTimezones
  • getTinyMCE4ConfigFiles
  • getTitle
  • getTotalArticles
  • getTotalImagesIn
  • getTotalNewsPages
  • getTotalPages
  • getTrustRoot
  • getUnprotectedImageURL
  • getUrAlbum
  • getURL
  • getUserIP
  • getUserLocale
  • getVersion
  • getViewerImageSize
  • getWatermarkParam
  • getWatermarkPath
  • getWatermarks
  • getWhereClause
  • getXSRFToken
  • getZenpageHitcounter
  • getZenpageRSSHeaderLink
  • getZenpageRSSLink
  • getZenpageStatistic
  • googleVerifyHead
  • handleSearchParms
  • hasDynamicAlbumSuffix
  • hasNextImage
  • hasNextPage
  • hasPrevImage
  • hasPrevPage
  • hitcounter
  • html_decode
  • html_encode
  • html_encodeTagged
  • httpsRedirect
  • httpUploadHandler
  • httpUploadHandler_admin_tabs
  • i18nSetLocale
  • imageBlurGD
  • imageDebug
  • imageError
  • imageNumber
  • imgSrcURI
  • in_context
  • inNewsCategory
  • inProtectedNewsCategory
  • installSignature
  • instrument
  • inSubNewsCategoryOf
  • internalToFilesystem
  • inventMenuItem
  • iptc_make_tag
  • is_AdminEditPage
  • is_connected
  • is_GalleryNewsType
  • is_News
  • is_NewsArchive
  • is_NewsArticle
  • is_NewsCategory
  • is_NewsPage
  • is_NewsType
  • is_Pages
  • is_valid_email_zp
  • is_valid_image
  • is_valid_other_type
  • is_zip
  • isAlbumClass
  • isAlbumPage
  • isArchive
  • isHandledAlbum
  • isImageClass
  • isImagePage
  • isImagePhoto
  • isImageVideo
  • isLandscape
  • isMyAlbum
  • isMyNews
  • isMyPage
  • isolate
  • isProtectedAlbum
  • isProtectedNewsCategory
  • isProtectedPage
  • isSubNewsCategoryOf
  • isValidURL
  • jQueryUpload_head
  • jQueryUpload_headers
  • jQueryUploadHandler
  • jQueryUploadHandler_admin_tabs
  • js_encode
  • json_decode
  • json_encode
  • kses
  • kses_array_lc
  • kses_attr
  • kses_bad_protocol
  • kses_bad_protocol_once
  • kses_bad_protocol_once2
  • kses_check_attr_val
  • kses_decode_entities
  • kses_hair
  • kses_hook
  • kses_html_error
  • kses_js_entities
  • kses_no_null
  • kses_normalize_entities
  • kses_normalize_entities2
  • kses_split
  • kses_split2
  • kses_stripslashes
  • kses_version
  • ksesProcess
  • layoutSelector
  • layoutSelector_album
  • listDBUses
  • listDirectoryFiles
  • listUses
  • load_zenpage_news
  • load_zenpage_pages
  • loadLocalOptions
  • log_message
  • lookupSortKey
  • macro_admin_tabs
  • macroList_show
  • makeAlbumCurrent
  • makeImageCurrent
  • makeSpecialImageName
  • markRelease_button
  • mb_strlen
  • mb_strpos
  • mb_strrpos
  • mb_strtolower
  • mb_strtoupper
  • mb_substr
  • mb_substr_count
  • menu_admin_toolbox_global
  • menu_tabs
  • minDiff
  • mkdir_recursive
  • my_truncate_string
  • myts_date
  • newAlbum
  • newImage
  • next_album
  • next_comment
  • next_image
  • next_news
  • next_page
  • ngettext_pl
  • ngettext_th
  • normalizeColumns
  • omsAdditions
  • openedForComments
  • parse_query
  • parse_size
  • parseAllowedTags
  • parseHttpAcceptLanguage
  • passAlbums
  • passImages
  • pathurlencode
  • PclZipUtilCopyBlock
  • PclZipUtilOptionText
  • PclZipUtilPathInclusion
  • PclZipUtilPathReduction
  • PclZipUtilRename
  • PclZipUtilTranslateWinPath
  • PHPMailerAutoload
  • populateManagedObjectsList
  • postAlbumSort
  • postIndexDecode
  • postIndexEncode
  • prefix
  • prepareAlbumPage
  • prepareCustomPage
  • prepareImagePage
  • prepareIndexPage
  • print404status
  • print_language_string_list
  • printAddToFavorites
  • printAdminFooter
  • printAdminHeader
  • printAdminRightsTable
  • printAdminToolbox
  • printAlbumBreadcrumb
  • printAlbumButtons
  • printAlbumCustomData
  • printAlbumData
  • printAlbumDate
  • printAlbumDesc
  • printAlbumEditForm
  • printAlbumEditRow
  • printAlbumLegend
  • printAlbumLink
  • printAlbumLocation
  • printAlbumMap
  • printAlbumMenu
  • printAlbumMenuJump
  • printAlbumMenuList
  • printAlbumMenuListAlbum
  • printAlbumPlace
  • printAlbumRating
  • printAlbumsSelector
  • printAlbumStatistic
  • printAlbumStatisticItem
  • printAlbumThumbImage
  • printAlbumTitle
  • printAlbumURL
  • printAlbumZip
  • printAllDates
  • printAllNewsCategories
  • printAllTags
  • printAllTagsAs
  • printAllTagsFromAlbum
  • printAllTagsFromZenpage
  • printAnnotatedAlbumTitle
  • printAnnotatedImageTitle
  • printArticleCategories
  • printArticleDatesDropdown
  • printArticlesPerPageDropdown
  • printBareAlbumDesc
  • printBareAlbumTitle
  • printBareGalleryDesc
  • printBareGalleryTitle
  • printBareImageDesc
  • printBareImageTitle
  • printBareNewsTitle
  • printBarePageTitle
  • printBulkActions
  • printCaptcha
  • printCategoriesStatistic
  • printCategoryCheckboxListEntry
  • printCategoryDropdown
  • printCategoryListSortableTable
  • printCategorySelection
  • printCodeblock
  • printCodeblockEdit
  • printCommentAuthorLink
  • printCommentErrors
  • printCommentForm
  • printContactForm
  • printCurrentNewsArchive
  • printCurrentNewsCategory
  • printCustomAlbumThumbImage
  • printCustomAlbumThumbMaxSpace
  • printCustomMenu
  • printCustomPageSelector
  • printCustomPageURL
  • printCustomSizedImage
  • printCustomSizedImageMaxHeight
  • printCustomSizedImageMaxSpace
  • printCustomSizedImageThumbMaxSpace
  • printDefaultSizedImage
  • printDownloadAlbumZipURL
  • printDownloadLink
  • printDownloadLinkAlbumZip
  • printdownloadList
  • printDownloadURL
  • printEditable
  • printEditCommentLink
  • printEditDropdown
  • printExpired
  • printFavoritesLink
  • printFavoritesURL
  • printField
  • printGalleryDesc
  • printGalleryIndexURL
  • printGalleryTitle
  • printGoogleMap
  • printHeadTitle
  • printHomeLink
  • printImageCustomData
  • printImageData
  • printImageDate
  • printImageDesc
  • printImageDiv
  • printImageEXIFData
  • printImageID
  • printImageLink
  • printImageMap
  • printImageMetadata
  • printImageRating
  • printImageSortOrder
  • printImageStatistic
  • printImageThumb
  • printImageTitle
  • printImageURL
  • printItemEditLink
  • printItemsList
  • printItemsListTable
  • printItemStatusDropdown
  • printjCarouselThumbNav
  • printjPlayerPlaylist
  • printLanguageSelector
  • printLatestAlbums
  • printLatestComments
  • printLatestImages
  • printLatestImagesByDate
  • printLatestImagesByMtime
  • printLatestNews
  • printLatestUpdatedAlbums
  • printLatestZenpageComments
  • printLink
  • printLinkHTML
  • printLogoAndLinks
  • printManagedObjects
  • printMenuemanagerPageList
  • printMenuemanagerPageListWithNav
  • printMenumanagerBreadcrumb
  • printMenumanagerNextLink
  • printMenumanagerPrevLink
  • printMostPopularItems
  • printMostRatedAlbums
  • printMostRatedImages
  • printMostRatedItems
  • printNestedAlbumsList
  • printNestedItemsList
  • printNestedMenu
  • printNews
  • printNewsArchive
  • printNewsAuthor
  • printNewsCategories
  • printNewsCategoryCustomData
  • printNewsCategoryDesc
  • printNewsCategoryURL
  • printNewsContent
  • printNewsCustomData
  • printNewsDate
  • printNewsExtraContent
  • printNewsImageTags
  • printNewsIndexURL
  • printNewsLink
  • printNewsPageList
  • printNewsPageListWithNav
  • printNewsReadMoreLink
  • printNewsStatistic
  • printNewsTitle
  • printNewsTitleLink
  • printNewsURL
  • printNextNewsLink
  • printNextNewsPageLink
  • printNextPageLink
  • printNextPageURL
  • printPageArticleTags
  • printPageAuthor
  • printPageContent
  • printPageCustomData
  • printPageDate
  • printPagedThumbsNav
  • printPageExtraContent
  • printPageID
  • printPageLastChangeDate
  • printPageLinkURL
  • printPageList
  • printPageListWithNav
  • printPageMenu
  • printPageNav
  • printPageSelector
  • printPagesListTable
  • printPagesStatistic
  • printPageTitle
  • printPageTitleLink
  • printPageURL
  • printParentBreadcrumb
  • printParentPagesBreadcrumb
  • printPasswordForm
  • printPopularAlbums
  • printPopularImages
  • printPreloadScript
  • printPrevNewsLink
  • printPrevNewsPageLink
  • printPrevPageLink
  • printPrevPageURL
  • printPublished
  • printPublishIconLink
  • printRandomImages
  • printRating
  • printRegisterURL
  • printRegistrationForm
  • printRelatedItems
  • printRSSHeaderLink
  • printRSSLink
  • printSearchBreadcrumb
  • printSearchForm
  • printSiteHomeURL
  • printSizedImageLink
  • printSizedImageURL
  • printSlideShow
  • printSlideShowJS
  • printSlideShowLink
  • printSortableHead
  • printSortOrderDropdown
  • printSubPagesExcerpts
  • printSubtabs
  • printTabs
  • printTags
  • printThumbNav
  • printTopRatedAlbums
  • printTopRatedImages
  • printTopRatedItems
  • printUnpublishedDropdown
  • printUserLogin_out
  • printUserSizeImage
  • printUserSizeSelector
  • printVersion
  • printZenJavascripts
  • printZenpageIconLegend
  • printZenpageItemsBreadcrumb
  • printZenpageNewsCategorySelector
  • printZenpagePagesSelector
  • printZenpageRSSHeaderLink
  • printZenpageRSSLink
  • printZenpageStatistic
  • printZenphotoLink
  • process_language_string_save
  • processAlbumBulkActions
  • processAlbumEdit
  • processCodeblockSave
  • processCommentBulkActions
  • processCredentials
  • processCustomOptionSave
  • processEditSelection
  • processExpired
  • processImageBulkActions
  • processImageEdit
  • processManagedObjects
  • processMenuBulkActions
  • processOrder
  • processRights
  • processTags
  • processZenpageBulkActions
  • propSizes
  • publishItem
  • purgeOption
  • query
  • query_full_array
  • query_single_row
  • rc4
  • read_exif_data_protected
  • readTags
  • recaptcha_check_answer
  • recaptcha_get_html
  • recaptcha_get_signup_url
  • recaptcha_mailhide_html
  • recaptcha_mailhide_url
  • reconfigureAction
  • reconfigureCS
  • reconfigurePage
  • recordMissing
  • rem_context
  • removeParentAlbumNames
  • resetCurrentAlbum
  • restore_context
  • reveal
  • rewrite_get_album_image
  • rewrite_path
  • rewrite_path_zenpage
  • RSS_Channel
  • RSS_Retrieve
  • RSS_Tags
  • rulesList
  • run
  • safe_fnmatch
  • safe_glob
  • sanitize
  • sanitize_numeric
  • sanitize_path
  • sanitize_script
  • sanitize_string
  • sanitizeRedirect
  • save_context
  • saveLayoutSelection
  • saveZenphotoLayoutSelection
  • search_quote
  • secureServer
  • seo_cleanup_button
  • seoFriendly
  • seoFriendlyJS
  • set_context
  • setAlbumCustomData
  • setAlbumSubtabs
  • setImageCustomData
  • setMainDomain
  • setOption
  • setOptionDefault
  • setPluginDomain
  • setThemeColumns
  • setThemeDomain
  • setThemeOption
  • setThemeOptionDefault
  • setupAllowedMaps
  • setupCurrentLocale
  • setupDomain
  • setupTheme
  • shortenContent
  • showOrNotShowField
  • shuffle_assoc
  • signatureChange
  • site_upgrade_button
  • site_upgrade_status
  • sitemap_echonl
  • sitemap_getChangefreq
  • sitemap_getDateformat
  • sitemap_getDBLimit
  • sitemap_getISO8601Date
  • skipScheduledPublishing
  • sortByKey
  • sortByMultilingual
  • sortMultiArray
  • standardScripts
  • standardThemeOptions
  • stickyNews
  • storeConfig
  • storeTags
  • stripSuffix
  • submenuOf
  • switchLog
  • tagSelector
  • tagSuggestJS
  • tagSuggestJS_admin
  • tagSuggestJS_frontend
  • themeIsEditable
  • themeSetup
  • timezoneDiff
  • tinymce4ConfigJS
  • truncate_string
  • unpublishedZenphotoItemCheck
  • unpublishSubalbums
  • unQuote
  • unzip
  • updateArticle
  • updateCacheName
  • updateCategory
  • updateConfigItem
  • updateItemSortorder
  • updateItemsSortorder
  • updateMenuItem
  • updatePage
  • upload_extra
  • upload_form
  • upload_head
  • user_mailing_list_button
  • validateLocale
  • wordpress_import_button
  • wp_prefix
  • wp_query_full_array
  • wpimport_TryAgainError
  • XSRFdefender
  • XSRFToken
  • zenJavascript
  • zenpageAlbumImage
  • zenpageBulkActionMessage
  • zenpageHitcounter
  • zenpageJSCSS
  • zenpageOpenedForComments
  • zenpagePublish
  • zenphoto_PHPMailer
  • zenphoto_sendmail
  • zenPhotoTheme
  • zp_apply_filter
  • zp_clearCookie
  • zp_colorAllocate
  • zp_cookieEncode
  • zp_copyCanvas
  • zp_createImage
  • zp_drawRectangle
  • zp_error
  • zp_filter_slot
  • zp_filter_unique_id
  • zp_getCookie
  • zp_getFonts
  • zp_graphicsLibInfo
  • zp_handle_password
  • zp_handle_password_single
  • zp_has_filter
  • zp_image_types
  • zp_imageCanRotate
  • zp_imageColorTransparent
  • zp_imageDims
  • zp_imageFill
  • zp_imageFontHeight
  • zp_imageFontWidth
  • zp_imageFromString
  • zp_imageGet
  • zp_imageGray
  • zp_imageHeight
  • zp_imageIPTC
  • zp_imageKill
  • zp_imageLoadFont
  • zp_imageMerge
  • zp_imageOutput
  • zp_imageResizeAlpha
  • zp_imageUnsharpMask
  • zp_imageWidth
  • zp_load_album
  • zp_load_gallery
  • zp_load_image
  • zp_load_page
  • zp_load_request
  • zp_load_search
  • zp_loggedin
  • zp_mail
  • zp_register_filter
  • zp_remove_filter
  • zp_resampleImage
  • zp_rotateImage
  • zp_session_start
  • zp_setCookie
  • zp_writeString
  • zpErrorHandler
  • zpFormattedDate
  • zpRewriteURL
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
   1: <?php
   2: /////////////////////////////////////////////////////////////////
   3: /// getID3() by James Heinrich <info@getid3.org>               //
   4: //  available at http://getid3.sourceforge.net                 //
   5: //            or http://www.getid3.org                         //
   6: //          also https://github.com/JamesHeinrich/getID3       //
   7: /////////////////////////////////////////////////////////////////
   8: //                                                             //
   9: // getid3.lib.php - part of getID3()                           //
  10: // See readme.txt for more details                             //
  11: //                                                            ///
  12: /////////////////////////////////////////////////////////////////
  13: 
  14: 
  15: class getid3_lib
  16: {
  17: 
  18:     public static function PrintHexBytes($string, $hex=true, $spaces=true, $htmlencoding='UTF-8') {
  19:         $returnstring = '';
  20:         for ($i = 0; $i < strlen($string); $i++) {
  21:             if ($hex) {
  22:                 $returnstring .= str_pad(dechex(ord($string{$i})), 2, '0', STR_PAD_LEFT);
  23:             } else {
  24:                 $returnstring .= ' '.(preg_match("#[\x20-\x7E]#", $string{$i}) ? $string{$i} : '¤');
  25:             }
  26:             if ($spaces) {
  27:                 $returnstring .= ' ';
  28:             }
  29:         }
  30:         if (!empty($htmlencoding)) {
  31:             if ($htmlencoding === true) {
  32:                 $htmlencoding = 'UTF-8'; // prior to getID3 v1.9.0 the function's 4th parameter was boolean
  33:             }
  34:             $returnstring = htmlentities($returnstring, ENT_QUOTES, $htmlencoding);
  35:         }
  36:         return $returnstring;
  37:     }
  38: 
  39:     public static function trunc($floatnumber) {
  40:         // truncates a floating-point number at the decimal point
  41:         // returns int (if possible, otherwise float)
  42:         if ($floatnumber >= 1) {
  43:             $truncatednumber = floor($floatnumber);
  44:         } elseif ($floatnumber <= -1) {
  45:             $truncatednumber = ceil($floatnumber);
  46:         } else {
  47:             $truncatednumber = 0;
  48:         }
  49:         if (self::intValueSupported($truncatednumber)) {
  50:             $truncatednumber = (int) $truncatednumber;
  51:         }
  52:         return $truncatednumber;
  53:     }
  54: 
  55: 
  56:     public static function safe_inc(&$variable, $increment=1) {
  57:         if (isset($variable)) {
  58:             $variable += $increment;
  59:         } else {
  60:             $variable = $increment;
  61:         }
  62:         return true;
  63:     }
  64: 
  65:     public static function CastAsInt($floatnum) {
  66:         // convert to float if not already
  67:         $floatnum = (float) $floatnum;
  68: 
  69:         // convert a float to type int, only if possible
  70:         if (self::trunc($floatnum) == $floatnum) {
  71:             // it's not floating point
  72:             if (self::intValueSupported($floatnum)) {
  73:                 // it's within int range
  74:                 $floatnum = (int) $floatnum;
  75:             }
  76:         }
  77:         return $floatnum;
  78:     }
  79: 
  80:     public static function intValueSupported($num) {
  81:         // check if integers are 64-bit
  82:         static $hasINT64 = null;
  83:         if ($hasINT64 === null) { // 10x faster than is_null()
  84:             $hasINT64 = is_int(pow(2, 31)); // 32-bit int are limited to (2^31)-1
  85:             if (!$hasINT64 && !defined('PHP_INT_MIN')) {
  86:                 define('PHP_INT_MIN', ~PHP_INT_MAX);
  87:             }
  88:         }
  89:         // if integers are 64-bit - no other check required
  90:         if ($hasINT64 || (($num <= PHP_INT_MAX) && ($num >= PHP_INT_MIN))) {
  91:             return true;
  92:         }
  93:         return false;
  94:     }
  95: 
  96:     public static function DecimalizeFraction($fraction) {
  97:         list($numerator, $denominator) = explode('/', $fraction);
  98:         return $numerator / ($denominator ? $denominator : 1);
  99:     }
 100: 
 101: 
 102:     public static function DecimalBinary2Float($binarynumerator) {
 103:         $numerator   = self::Bin2Dec($binarynumerator);
 104:         $denominator = self::Bin2Dec('1'.str_repeat('0', strlen($binarynumerator)));
 105:         return ($numerator / $denominator);
 106:     }
 107: 
 108: 
 109:     public static function NormalizeBinaryPoint($binarypointnumber, $maxbits=52) {
 110:         // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
 111:         if (strpos($binarypointnumber, '.') === false) {
 112:             $binarypointnumber = '0.'.$binarypointnumber;
 113:         } elseif ($binarypointnumber{0} == '.') {
 114:             $binarypointnumber = '0'.$binarypointnumber;
 115:         }
 116:         $exponent = 0;
 117:         while (($binarypointnumber{0} != '1') || (substr($binarypointnumber, 1, 1) != '.')) {
 118:             if (substr($binarypointnumber, 1, 1) == '.') {
 119:                 $exponent--;
 120:                 $binarypointnumber = substr($binarypointnumber, 2, 1).'.'.substr($binarypointnumber, 3);
 121:             } else {
 122:                 $pointpos = strpos($binarypointnumber, '.');
 123:                 $exponent += ($pointpos - 1);
 124:                 $binarypointnumber = str_replace('.', '', $binarypointnumber);
 125:                 $binarypointnumber = $binarypointnumber{0}.'.'.substr($binarypointnumber, 1);
 126:             }
 127:         }
 128:         $binarypointnumber = str_pad(substr($binarypointnumber, 0, $maxbits + 2), $maxbits + 2, '0', STR_PAD_RIGHT);
 129:         return array('normalized'=>$binarypointnumber, 'exponent'=>(int) $exponent);
 130:     }
 131: 
 132: 
 133:     public static function Float2BinaryDecimal($floatvalue) {
 134:         // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/binary.html
 135:         $maxbits = 128; // to how many bits of precision should the calculations be taken?
 136:         $intpart   = self::trunc($floatvalue);
 137:         $floatpart = abs($floatvalue - $intpart);
 138:         $pointbitstring = '';
 139:         while (($floatpart != 0) && (strlen($pointbitstring) < $maxbits)) {
 140:             $floatpart *= 2;
 141:             $pointbitstring .= (string) self::trunc($floatpart);
 142:             $floatpart -= self::trunc($floatpart);
 143:         }
 144:         $binarypointnumber = decbin($intpart).'.'.$pointbitstring;
 145:         return $binarypointnumber;
 146:     }
 147: 
 148: 
 149:     public static function Float2String($floatvalue, $bits) {
 150:         // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee-expl.html
 151:         switch ($bits) {
 152:             case 32:
 153:                 $exponentbits = 8;
 154:                 $fractionbits = 23;
 155:                 break;
 156: 
 157:             case 64:
 158:                 $exponentbits = 11;
 159:                 $fractionbits = 52;
 160:                 break;
 161: 
 162:             default:
 163:                 return false;
 164:                 break;
 165:         }
 166:         if ($floatvalue >= 0) {
 167:             $signbit = '0';
 168:         } else {
 169:             $signbit = '1';
 170:         }
 171:         $normalizedbinary  = self::NormalizeBinaryPoint(self::Float2BinaryDecimal($floatvalue), $fractionbits);
 172:         $biasedexponent    = pow(2, $exponentbits - 1) - 1 + $normalizedbinary['exponent']; // (127 or 1023) +/- exponent
 173:         $exponentbitstring = str_pad(decbin($biasedexponent), $exponentbits, '0', STR_PAD_LEFT);
 174:         $fractionbitstring = str_pad(substr($normalizedbinary['normalized'], 2), $fractionbits, '0', STR_PAD_RIGHT);
 175: 
 176:         return self::BigEndian2String(self::Bin2Dec($signbit.$exponentbitstring.$fractionbitstring), $bits % 8, false);
 177:     }
 178: 
 179: 
 180:     public static function LittleEndian2Float($byteword) {
 181:         return self::BigEndian2Float(strrev($byteword));
 182:     }
 183: 
 184: 
 185:     public static function BigEndian2Float($byteword) {
 186:         // ANSI/IEEE Standard 754-1985, Standard for Binary Floating Point Arithmetic
 187:         // http://www.psc.edu/general/software/packages/ieee/ieee.html
 188:         // http://www.scri.fsu.edu/~jac/MAD3401/Backgrnd/ieee.html
 189: 
 190:         $bitword = self::BigEndian2Bin($byteword);
 191:         if (!$bitword) {
 192:             return 0;
 193:         }
 194:         $signbit = $bitword{0};
 195: 
 196:         switch (strlen($byteword) * 8) {
 197:             case 32:
 198:                 $exponentbits = 8;
 199:                 $fractionbits = 23;
 200:                 break;
 201: 
 202:             case 64:
 203:                 $exponentbits = 11;
 204:                 $fractionbits = 52;
 205:                 break;
 206: 
 207:             case 80:
 208:                 // 80-bit Apple SANE format
 209:                 // http://www.mactech.com/articles/mactech/Vol.06/06.01/SANENormalized/
 210:                 $exponentstring = substr($bitword, 1, 15);
 211:                 $isnormalized = intval($bitword{16});
 212:                 $fractionstring = substr($bitword, 17, 63);
 213:                 $exponent = pow(2, self::Bin2Dec($exponentstring) - 16383);
 214:                 $fraction = $isnormalized + self::DecimalBinary2Float($fractionstring);
 215:                 $floatvalue = $exponent * $fraction;
 216:                 if ($signbit == '1') {
 217:                     $floatvalue *= -1;
 218:                 }
 219:                 return $floatvalue;
 220:                 break;
 221: 
 222:             default:
 223:                 return false;
 224:                 break;
 225:         }
 226:         $exponentstring = substr($bitword, 1, $exponentbits);
 227:         $fractionstring = substr($bitword, $exponentbits + 1, $fractionbits);
 228:         $exponent = self::Bin2Dec($exponentstring);
 229:         $fraction = self::Bin2Dec($fractionstring);
 230: 
 231:         if (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction != 0)) {
 232:             // Not a Number
 233:             $floatvalue = false;
 234:         } elseif (($exponent == (pow(2, $exponentbits) - 1)) && ($fraction == 0)) {
 235:             if ($signbit == '1') {
 236:                 $floatvalue = '-infinity';
 237:             } else {
 238:                 $floatvalue = '+infinity';
 239:             }
 240:         } elseif (($exponent == 0) && ($fraction == 0)) {
 241:             if ($signbit == '1') {
 242:                 $floatvalue = -0;
 243:             } else {
 244:                 $floatvalue = 0;
 245:             }
 246:             $floatvalue = ($signbit ? 0 : -0);
 247:         } elseif (($exponent == 0) && ($fraction != 0)) {
 248:             // These are 'unnormalized' values
 249:             $floatvalue = pow(2, (-1 * (pow(2, $exponentbits - 1) - 2))) * self::DecimalBinary2Float($fractionstring);
 250:             if ($signbit == '1') {
 251:                 $floatvalue *= -1;
 252:             }
 253:         } elseif ($exponent != 0) {
 254:             $floatvalue = pow(2, ($exponent - (pow(2, $exponentbits - 1) - 1))) * (1 + self::DecimalBinary2Float($fractionstring));
 255:             if ($signbit == '1') {
 256:                 $floatvalue *= -1;
 257:             }
 258:         }
 259:         return (float) $floatvalue;
 260:     }
 261: 
 262: 
 263:     public static function BigEndian2Int($byteword, $synchsafe=false, $signed=false) {
 264:         $intvalue = 0;
 265:         $bytewordlen = strlen($byteword);
 266:         if ($bytewordlen == 0) {
 267:             return false;
 268:         }
 269:         for ($i = 0; $i < $bytewordlen; $i++) {
 270:             if ($synchsafe) { // disregard MSB, effectively 7-bit bytes
 271:                 //$intvalue = $intvalue | (ord($byteword{$i}) & 0x7F) << (($bytewordlen - 1 - $i) * 7); // faster, but runs into problems past 2^31 on 32-bit systems
 272:                 $intvalue += (ord($byteword{$i}) & 0x7F) * pow(2, ($bytewordlen - 1 - $i) * 7);
 273:             } else {
 274:                 $intvalue += ord($byteword{$i}) * pow(256, ($bytewordlen - 1 - $i));
 275:             }
 276:         }
 277:         if ($signed && !$synchsafe) {
 278:             // synchsafe ints are not allowed to be signed
 279:             if ($bytewordlen <= PHP_INT_SIZE) {
 280:                 $signMaskBit = 0x80 << (8 * ($bytewordlen - 1));
 281:                 if ($intvalue & $signMaskBit) {
 282:                     $intvalue = 0 - ($intvalue & ($signMaskBit - 1));
 283:                 }
 284:             } else {
 285:                 throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits ('.strlen($byteword).') in self::BigEndian2Int()');
 286:             }
 287:         }
 288:         return self::CastAsInt($intvalue);
 289:     }
 290: 
 291: 
 292:     public static function LittleEndian2Int($byteword, $signed=false) {
 293:         return self::BigEndian2Int(strrev($byteword), false, $signed);
 294:     }
 295: 
 296: 
 297:     public static function BigEndian2Bin($byteword) {
 298:         $binvalue = '';
 299:         $bytewordlen = strlen($byteword);
 300:         for ($i = 0; $i < $bytewordlen; $i++) {
 301:             $binvalue .= str_pad(decbin(ord($byteword{$i})), 8, '0', STR_PAD_LEFT);
 302:         }
 303:         return $binvalue;
 304:     }
 305: 
 306: 
 307:     public static function BigEndian2String($number, $minbytes=1, $synchsafe=false, $signed=false) {
 308:         if ($number < 0) {
 309:             throw new Exception('ERROR: self::BigEndian2String() does not support negative numbers');
 310:         }
 311:         $maskbyte = (($synchsafe || $signed) ? 0x7F : 0xFF);
 312:         $intstring = '';
 313:         if ($signed) {
 314:             if ($minbytes > PHP_INT_SIZE) {
 315:                 throw new Exception('ERROR: Cannot have signed integers larger than '.(8 * PHP_INT_SIZE).'-bits in self::BigEndian2String()');
 316:             }
 317:             $number = $number & (0x80 << (8 * ($minbytes - 1)));
 318:         }
 319:         while ($number != 0) {
 320:             $quotient = ($number / ($maskbyte + 1));
 321:             $intstring = chr(ceil(($quotient - floor($quotient)) * $maskbyte)).$intstring;
 322:             $number = floor($quotient);
 323:         }
 324:         return str_pad($intstring, $minbytes, "\x00", STR_PAD_LEFT);
 325:     }
 326: 
 327: 
 328:     public static function Dec2Bin($number) {
 329:         while ($number >= 256) {
 330:             $bytes[] = (($number / 256) - (floor($number / 256))) * 256;
 331:             $number = floor($number / 256);
 332:         }
 333:         $bytes[] = $number;
 334:         $binstring = '';
 335:         for ($i = 0; $i < count($bytes); $i++) {
 336:             $binstring = (($i == count($bytes) - 1) ? decbin($bytes[$i]) : str_pad(decbin($bytes[$i]), 8, '0', STR_PAD_LEFT)).$binstring;
 337:         }
 338:         return $binstring;
 339:     }
 340: 
 341: 
 342:     public static function Bin2Dec($binstring, $signed=false) {
 343:         $signmult = 1;
 344:         if ($signed) {
 345:             if ($binstring{0} == '1') {
 346:                 $signmult = -1;
 347:             }
 348:             $binstring = substr($binstring, 1);
 349:         }
 350:         $decvalue = 0;
 351:         for ($i = 0; $i < strlen($binstring); $i++) {
 352:             $decvalue += ((int) substr($binstring, strlen($binstring) - $i - 1, 1)) * pow(2, $i);
 353:         }
 354:         return self::CastAsInt($decvalue * $signmult);
 355:     }
 356: 
 357: 
 358:     public static function Bin2String($binstring) {
 359:         // return 'hi' for input of '0110100001101001'
 360:         $string = '';
 361:         $binstringreversed = strrev($binstring);
 362:         for ($i = 0; $i < strlen($binstringreversed); $i += 8) {
 363:             $string = chr(self::Bin2Dec(strrev(substr($binstringreversed, $i, 8)))).$string;
 364:         }
 365:         return $string;
 366:     }
 367: 
 368: 
 369:     public static function LittleEndian2String($number, $minbytes=1, $synchsafe=false) {
 370:         $intstring = '';
 371:         while ($number > 0) {
 372:             if ($synchsafe) {
 373:                 $intstring = $intstring.chr($number & 127);
 374:                 $number >>= 7;
 375:             } else {
 376:                 $intstring = $intstring.chr($number & 255);
 377:                 $number >>= 8;
 378:             }
 379:         }
 380:         return str_pad($intstring, $minbytes, "\x00", STR_PAD_RIGHT);
 381:     }
 382: 
 383: 
 384:     public static function array_merge_clobber($array1, $array2) {
 385:         // written by kcØhireability*com
 386:         // taken from http://www.php.net/manual/en/function.array-merge-recursive.php
 387:         if (!is_array($array1) || !is_array($array2)) {
 388:             return false;
 389:         }
 390:         $newarray = $array1;
 391:         foreach ($array2 as $key => $val) {
 392:             if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
 393:                 $newarray[$key] = self::array_merge_clobber($newarray[$key], $val);
 394:             } else {
 395:                 $newarray[$key] = $val;
 396:             }
 397:         }
 398:         return $newarray;
 399:     }
 400: 
 401: 
 402:     public static function array_merge_noclobber($array1, $array2) {
 403:         if (!is_array($array1) || !is_array($array2)) {
 404:             return false;
 405:         }
 406:         $newarray = $array1;
 407:         foreach ($array2 as $key => $val) {
 408:             if (is_array($val) && isset($newarray[$key]) && is_array($newarray[$key])) {
 409:                 $newarray[$key] = self::array_merge_noclobber($newarray[$key], $val);
 410:             } elseif (!isset($newarray[$key])) {
 411:                 $newarray[$key] = $val;
 412:             }
 413:         }
 414:         return $newarray;
 415:     }
 416: 
 417:     public static function flipped_array_merge_noclobber($array1, $array2) {
 418:         if (!is_array($array1) || !is_array($array2)) {
 419:             return false;
 420:         }
 421:         # naturally, this only works non-recursively
 422:         $newarray = array_flip($array1);
 423:         foreach (array_flip($array2) as $key => $val) {
 424:             if (!isset($newarray[$key])) {
 425:                 $newarray[$key] = count($newarray);
 426:             }
 427:         }
 428:         return array_flip($newarray);
 429:     }
 430: 
 431: 
 432:     public static function ksort_recursive(&$theArray) {
 433:         ksort($theArray);
 434:         foreach ($theArray as $key => $value) {
 435:             if (is_array($value)) {
 436:                 self::ksort_recursive($theArray[$key]);
 437:             }
 438:         }
 439:         return true;
 440:     }
 441: 
 442:     public static function fileextension($filename, $numextensions=1) {
 443:         if (strstr($filename, '.')) {
 444:             $reversedfilename = strrev($filename);
 445:             $offset = 0;
 446:             for ($i = 0; $i < $numextensions; $i++) {
 447:                 $offset = strpos($reversedfilename, '.', $offset + 1);
 448:                 if ($offset === false) {
 449:                     return '';
 450:                 }
 451:             }
 452:             return strrev(substr($reversedfilename, 0, $offset));
 453:         }
 454:         return '';
 455:     }
 456: 
 457: 
 458:     public static function PlaytimeString($seconds) {
 459:         $sign = (($seconds < 0) ? '-' : '');
 460:         $seconds = round(abs($seconds));
 461:         $H = (int) floor( $seconds                            / 3600);
 462:         $M = (int) floor(($seconds - (3600 * $H)            ) /   60);
 463:         $S = (int) round( $seconds - (3600 * $H) - (60 * $M)        );
 464:         return $sign.($H ? $H.':' : '').($H ? str_pad($M, 2, '0', STR_PAD_LEFT) : intval($M)).':'.str_pad($S, 2, 0, STR_PAD_LEFT);
 465:     }
 466: 
 467: 
 468:     public static function DateMac2Unix($macdate) {
 469:         // Macintosh timestamp: seconds since 00:00h January 1, 1904
 470:         // UNIX timestamp:      seconds since 00:00h January 1, 1970
 471:         return self::CastAsInt($macdate - 2082844800);
 472:     }
 473: 
 474: 
 475:     public static function FixedPoint8_8($rawdata) {
 476:         return self::BigEndian2Int(substr($rawdata, 0, 1)) + (float) (self::BigEndian2Int(substr($rawdata, 1, 1)) / pow(2, 8));
 477:     }
 478: 
 479: 
 480:     public static function FixedPoint16_16($rawdata) {
 481:         return self::BigEndian2Int(substr($rawdata, 0, 2)) + (float) (self::BigEndian2Int(substr($rawdata, 2, 2)) / pow(2, 16));
 482:     }
 483: 
 484: 
 485:     public static function FixedPoint2_30($rawdata) {
 486:         $binarystring = self::BigEndian2Bin($rawdata);
 487:         return self::Bin2Dec(substr($binarystring, 0, 2)) + (float) (self::Bin2Dec(substr($binarystring, 2, 30)) / pow(2, 30));
 488:     }
 489: 
 490: 
 491:     public static function CreateDeepArray($ArrayPath, $Separator, $Value) {
 492:         // assigns $Value to a nested array path:
 493:         //   $foo = self::CreateDeepArray('/path/to/my', '/', 'file.txt')
 494:         // is the same as:
 495:         //   $foo = array('path'=>array('to'=>'array('my'=>array('file.txt'))));
 496:         // or
 497:         //   $foo['path']['to']['my'] = 'file.txt';
 498:         $ArrayPath = ltrim($ArrayPath, $Separator);
 499:         if (($pos = strpos($ArrayPath, $Separator)) !== false) {
 500:             $ReturnedArray[substr($ArrayPath, 0, $pos)] = self::CreateDeepArray(substr($ArrayPath, $pos + 1), $Separator, $Value);
 501:         } else {
 502:             $ReturnedArray[$ArrayPath] = $Value;
 503:         }
 504:         return $ReturnedArray;
 505:     }
 506: 
 507:     public static function array_max($arraydata, $returnkey=false) {
 508:         $maxvalue = false;
 509:         $maxkey = false;
 510:         foreach ($arraydata as $key => $value) {
 511:             if (!is_array($value)) {
 512:                 if ($value > $maxvalue) {
 513:                     $maxvalue = $value;
 514:                     $maxkey = $key;
 515:                 }
 516:             }
 517:         }
 518:         return ($returnkey ? $maxkey : $maxvalue);
 519:     }
 520: 
 521:     public static function array_min($arraydata, $returnkey=false) {
 522:         $minvalue = false;
 523:         $minkey = false;
 524:         foreach ($arraydata as $key => $value) {
 525:             if (!is_array($value)) {
 526:                 if ($value > $minvalue) {
 527:                     $minvalue = $value;
 528:                     $minkey = $key;
 529:                 }
 530:             }
 531:         }
 532:         return ($returnkey ? $minkey : $minvalue);
 533:     }
 534: 
 535:     public static function XML2array($XMLstring) {
 536:         if (function_exists('simplexml_load_string') && function_exists('libxml_disable_entity_loader')) {
 537:             // http://websec.io/2012/08/27/Preventing-XEE-in-PHP.html
 538:             // https://core.trac.wordpress.org/changeset/29378
 539:             $loader = libxml_disable_entity_loader(true);
 540:             $XMLobject = simplexml_load_string($XMLstring, 'SimpleXMLElement', LIBXML_NOENT);
 541:             $return = self::SimpleXMLelement2array($XMLobject);
 542:             libxml_disable_entity_loader($loader);
 543:             return $return;
 544:         }
 545:         return false;
 546:     }
 547: 
 548:     public static function SimpleXMLelement2array($XMLobject) {
 549:         if (!is_object($XMLobject) && !is_array($XMLobject)) {
 550:             return $XMLobject;
 551:         }
 552:         $XMLarray = (is_object($XMLobject) ? get_object_vars($XMLobject) : $XMLobject);
 553:         foreach ($XMLarray as $key => $value) {
 554:             $XMLarray[$key] = self::SimpleXMLelement2array($value);
 555:         }
 556:         return $XMLarray;
 557:     }
 558: 
 559: 
 560:     // Allan Hansen <ahØartemis*dk>
 561:     // self::md5_data() - returns md5sum for a file from startuing position to absolute end position
 562:     public static function hash_data($file, $offset, $end, $algorithm) {
 563:         static $tempdir = '';
 564:         if (!self::intValueSupported($end)) {
 565:             return false;
 566:         }
 567:         switch ($algorithm) {
 568:             case 'md5':
 569:                 $hash_function = 'md5_file';
 570:                 $unix_call     = 'md5sum';
 571:                 $windows_call  = 'md5sum.exe';
 572:                 $hash_length   = 32;
 573:                 break;
 574: 
 575:             case 'sha1':
 576:                 $hash_function = 'sha1_file';
 577:                 $unix_call     = 'sha1sum';
 578:                 $windows_call  = 'sha1sum.exe';
 579:                 $hash_length   = 40;
 580:                 break;
 581: 
 582:             default:
 583:                 throw new Exception('Invalid algorithm ('.$algorithm.') in self::hash_data()');
 584:                 break;
 585:         }
 586:         $size = $end - $offset;
 587:         while (true) {
 588:             if (GETID3_OS_ISWINDOWS) {
 589: 
 590:                 // It seems that sha1sum.exe for Windows only works on physical files, does not accept piped data
 591:                 // Fall back to create-temp-file method:
 592:                 if ($algorithm == 'sha1') {
 593:                     break;
 594:                 }
 595: 
 596:                 $RequiredFiles = array('cygwin1.dll', 'head.exe', 'tail.exe', $windows_call);
 597:                 foreach ($RequiredFiles as $required_file) {
 598:                     if (!is_readable(GETID3_HELPERAPPSDIR.$required_file)) {
 599:                         // helper apps not available - fall back to old method
 600:                         break 2;
 601:                     }
 602:                 }
 603:                 $commandline  = GETID3_HELPERAPPSDIR.'head.exe -c '.$end.' '.escapeshellarg(str_replace('/', DIRECTORY_SEPARATOR, $file)).' | ';
 604:                 $commandline .= GETID3_HELPERAPPSDIR.'tail.exe -c '.$size.' | ';
 605:                 $commandline .= GETID3_HELPERAPPSDIR.$windows_call;
 606: 
 607:             } else {
 608: 
 609:                 $commandline  = 'head -c'.$end.' '.escapeshellarg($file).' | ';
 610:                 $commandline .= 'tail -c'.$size.' | ';
 611:                 $commandline .= $unix_call;
 612: 
 613:             }
 614:             if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) {
 615:                 //throw new Exception('PHP running in Safe Mode - backtick operator not available, using slower non-system-call '.$algorithm.' algorithm');
 616:                 break;
 617:             }
 618:             return substr(`$commandline`, 0, $hash_length);
 619:         }
 620: 
 621:         if (empty($tempdir)) {
 622:             // yes this is ugly, feel free to suggest a better way
 623:             require_once(dirname(__FILE__).'/getid3.php');
 624:             $getid3_temp = new getID3();
 625:             $tempdir = $getid3_temp->tempdir;
 626:             unset($getid3_temp);
 627:         }
 628:         // try to create a temporary file in the system temp directory - invalid dirname should force to system temp dir
 629:         if (($data_filename = tempnam($tempdir, 'gI3')) === false) {
 630:             // can't find anywhere to create a temp file, just fail
 631:             return false;
 632:         }
 633: 
 634:         // Init
 635:         $result = false;
 636: 
 637:         // copy parts of file
 638:         try {
 639:             self::CopyFileParts($file, $data_filename, $offset, $end - $offset);
 640:             $result = $hash_function($data_filename);
 641:         } catch (Exception $e) {
 642:             throw new Exception('self::CopyFileParts() failed in getid_lib::hash_data(): '.$e->getMessage());
 643:         }
 644:         unlink($data_filename);
 645:         return $result;
 646:     }
 647: 
 648:     public static function CopyFileParts($filename_source, $filename_dest, $offset, $length) {
 649:         if (!self::intValueSupported($offset + $length)) {
 650:             throw new Exception('cannot copy file portion, it extends beyond the '.round(PHP_INT_MAX / 1073741824).'GB limit');
 651:         }
 652:         if (is_readable($filename_source) && is_file($filename_source) && ($fp_src = fopen($filename_source, 'rb'))) {
 653:             if (($fp_dest = fopen($filename_dest, 'wb'))) {
 654:                 if (fseek($fp_src, $offset) == 0) {
 655:                     $byteslefttowrite = $length;
 656:                     while (($byteslefttowrite > 0) && ($buffer = fread($fp_src, min($byteslefttowrite, getID3::FREAD_BUFFER_SIZE)))) {
 657:                         $byteswritten = fwrite($fp_dest, $buffer, $byteslefttowrite);
 658:                         $byteslefttowrite -= $byteswritten;
 659:                     }
 660:                     return true;
 661:                 } else {
 662:                     throw new Exception('failed to seek to offset '.$offset.' in '.$filename_source);
 663:                 }
 664:                 fclose($fp_dest);
 665:             } else {
 666:                 throw new Exception('failed to create file for writing '.$filename_dest);
 667:             }
 668:             fclose($fp_src);
 669:         } else {
 670:             throw new Exception('failed to open file for reading '.$filename_source);
 671:         }
 672:         return false;
 673:     }
 674: 
 675:     public static function iconv_fallback_int_utf8($charval) {
 676:         if ($charval < 128) {
 677:             // 0bbbbbbb
 678:             $newcharstring = chr($charval);
 679:         } elseif ($charval < 2048) {
 680:             // 110bbbbb 10bbbbbb
 681:             $newcharstring  = chr(($charval >>   6) | 0xC0);
 682:             $newcharstring .= chr(($charval & 0x3F) | 0x80);
 683:         } elseif ($charval < 65536) {
 684:             // 1110bbbb 10bbbbbb 10bbbbbb
 685:             $newcharstring  = chr(($charval >>  12) | 0xE0);
 686:             $newcharstring .= chr(($charval >>   6) | 0xC0);
 687:             $newcharstring .= chr(($charval & 0x3F) | 0x80);
 688:         } else {
 689:             // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
 690:             $newcharstring  = chr(($charval >>  18) | 0xF0);
 691:             $newcharstring .= chr(($charval >>  12) | 0xC0);
 692:             $newcharstring .= chr(($charval >>   6) | 0xC0);
 693:             $newcharstring .= chr(($charval & 0x3F) | 0x80);
 694:         }
 695:         return $newcharstring;
 696:     }
 697: 
 698:     // ISO-8859-1 => UTF-8
 699:     public static function iconv_fallback_iso88591_utf8($string, $bom=false) {
 700:         if (function_exists('utf8_encode')) {
 701:             return utf8_encode($string);
 702:         }
 703:         // utf8_encode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
 704:         $newcharstring = '';
 705:         if ($bom) {
 706:             $newcharstring .= "\xEF\xBB\xBF";
 707:         }
 708:         for ($i = 0; $i < strlen($string); $i++) {
 709:             $charval = ord($string{$i});
 710:             $newcharstring .= self::iconv_fallback_int_utf8($charval);
 711:         }
 712:         return $newcharstring;
 713:     }
 714: 
 715:     // ISO-8859-1 => UTF-16BE
 716:     public static function iconv_fallback_iso88591_utf16be($string, $bom=false) {
 717:         $newcharstring = '';
 718:         if ($bom) {
 719:             $newcharstring .= "\xFE\xFF";
 720:         }
 721:         for ($i = 0; $i < strlen($string); $i++) {
 722:             $newcharstring .= "\x00".$string{$i};
 723:         }
 724:         return $newcharstring;
 725:     }
 726: 
 727:     // ISO-8859-1 => UTF-16LE
 728:     public static function iconv_fallback_iso88591_utf16le($string, $bom=false) {
 729:         $newcharstring = '';
 730:         if ($bom) {
 731:             $newcharstring .= "\xFF\xFE";
 732:         }
 733:         for ($i = 0; $i < strlen($string); $i++) {
 734:             $newcharstring .= $string{$i}."\x00";
 735:         }
 736:         return $newcharstring;
 737:     }
 738: 
 739:     // ISO-8859-1 => UTF-16LE (BOM)
 740:     public static function iconv_fallback_iso88591_utf16($string) {
 741:         return self::iconv_fallback_iso88591_utf16le($string, true);
 742:     }
 743: 
 744:     // UTF-8 => ISO-8859-1
 745:     public static function iconv_fallback_utf8_iso88591($string) {
 746:         if (function_exists('utf8_decode')) {
 747:             return utf8_decode($string);
 748:         }
 749:         // utf8_decode() unavailable, use getID3()'s iconv_fallback() conversions (possibly PHP is compiled without XML support)
 750:         $newcharstring = '';
 751:         $offset = 0;
 752:         $stringlength = strlen($string);
 753:         while ($offset < $stringlength) {
 754:             if ((ord($string{$offset}) | 0x07) == 0xF7) {
 755:                 // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
 756:                 $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
 757:                            ((ord($string{($offset + 1)}) & 0x3F) << 12) &
 758:                            ((ord($string{($offset + 2)}) & 0x3F) <<  6) &
 759:                             (ord($string{($offset + 3)}) & 0x3F);
 760:                 $offset += 4;
 761:             } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
 762:                 // 1110bbbb 10bbbbbb 10bbbbbb
 763:                 $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
 764:                            ((ord($string{($offset + 1)}) & 0x3F) <<  6) &
 765:                             (ord($string{($offset + 2)}) & 0x3F);
 766:                 $offset += 3;
 767:             } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
 768:                 // 110bbbbb 10bbbbbb
 769:                 $charval = ((ord($string{($offset + 0)}) & 0x1F) <<  6) &
 770:                             (ord($string{($offset + 1)}) & 0x3F);
 771:                 $offset += 2;
 772:             } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
 773:                 // 0bbbbbbb
 774:                 $charval = ord($string{$offset});
 775:                 $offset += 1;
 776:             } else {
 777:                 // error? throw some kind of warning here?
 778:                 $charval = false;
 779:                 $offset += 1;
 780:             }
 781:             if ($charval !== false) {
 782:                 $newcharstring .= (($charval < 256) ? chr($charval) : '?');
 783:             }
 784:         }
 785:         return $newcharstring;
 786:     }
 787: 
 788:     // UTF-8 => UTF-16BE
 789:     public static function iconv_fallback_utf8_utf16be($string, $bom=false) {
 790:         $newcharstring = '';
 791:         if ($bom) {
 792:             $newcharstring .= "\xFE\xFF";
 793:         }
 794:         $offset = 0;
 795:         $stringlength = strlen($string);
 796:         while ($offset < $stringlength) {
 797:             if ((ord($string{$offset}) | 0x07) == 0xF7) {
 798:                 // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
 799:                 $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
 800:                            ((ord($string{($offset + 1)}) & 0x3F) << 12) &
 801:                            ((ord($string{($offset + 2)}) & 0x3F) <<  6) &
 802:                             (ord($string{($offset + 3)}) & 0x3F);
 803:                 $offset += 4;
 804:             } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
 805:                 // 1110bbbb 10bbbbbb 10bbbbbb
 806:                 $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
 807:                            ((ord($string{($offset + 1)}) & 0x3F) <<  6) &
 808:                             (ord($string{($offset + 2)}) & 0x3F);
 809:                 $offset += 3;
 810:             } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
 811:                 // 110bbbbb 10bbbbbb
 812:                 $charval = ((ord($string{($offset + 0)}) & 0x1F) <<  6) &
 813:                             (ord($string{($offset + 1)}) & 0x3F);
 814:                 $offset += 2;
 815:             } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
 816:                 // 0bbbbbbb
 817:                 $charval = ord($string{$offset});
 818:                 $offset += 1;
 819:             } else {
 820:                 // error? throw some kind of warning here?
 821:                 $charval = false;
 822:                 $offset += 1;
 823:             }
 824:             if ($charval !== false) {
 825:                 $newcharstring .= (($charval < 65536) ? self::BigEndian2String($charval, 2) : "\x00".'?');
 826:             }
 827:         }
 828:         return $newcharstring;
 829:     }
 830: 
 831:     // UTF-8 => UTF-16LE
 832:     public static function iconv_fallback_utf8_utf16le($string, $bom=false) {
 833:         $newcharstring = '';
 834:         if ($bom) {
 835:             $newcharstring .= "\xFF\xFE";
 836:         }
 837:         $offset = 0;
 838:         $stringlength = strlen($string);
 839:         while ($offset < $stringlength) {
 840:             if ((ord($string{$offset}) | 0x07) == 0xF7) {
 841:                 // 11110bbb 10bbbbbb 10bbbbbb 10bbbbbb
 842:                 $charval = ((ord($string{($offset + 0)}) & 0x07) << 18) &
 843:                            ((ord($string{($offset + 1)}) & 0x3F) << 12) &
 844:                            ((ord($string{($offset + 2)}) & 0x3F) <<  6) &
 845:                             (ord($string{($offset + 3)}) & 0x3F);
 846:                 $offset += 4;
 847:             } elseif ((ord($string{$offset}) | 0x0F) == 0xEF) {
 848:                 // 1110bbbb 10bbbbbb 10bbbbbb
 849:                 $charval = ((ord($string{($offset + 0)}) & 0x0F) << 12) &
 850:                            ((ord($string{($offset + 1)}) & 0x3F) <<  6) &
 851:                             (ord($string{($offset + 2)}) & 0x3F);
 852:                 $offset += 3;
 853:             } elseif ((ord($string{$offset}) | 0x1F) == 0xDF) {
 854:                 // 110bbbbb 10bbbbbb
 855:                 $charval = ((ord($string{($offset + 0)}) & 0x1F) <<  6) &
 856:                             (ord($string{($offset + 1)}) & 0x3F);
 857:                 $offset += 2;
 858:             } elseif ((ord($string{$offset}) | 0x7F) == 0x7F) {
 859:                 // 0bbbbbbb
 860:                 $charval = ord($string{$offset});
 861:                 $offset += 1;
 862:             } else {
 863:                 // error? maybe throw some warning here?
 864:                 $charval = false;
 865:                 $offset += 1;
 866:             }
 867:             if ($charval !== false) {
 868:                 $newcharstring .= (($charval < 65536) ? self::LittleEndian2String($charval, 2) : '?'."\x00");
 869:             }
 870:         }
 871:         return $newcharstring;
 872:     }
 873: 
 874:     // UTF-8 => UTF-16LE (BOM)
 875:     public static function iconv_fallback_utf8_utf16($string) {
 876:         return self::iconv_fallback_utf8_utf16le($string, true);
 877:     }
 878: 
 879:     // UTF-16BE => UTF-8
 880:     public static function iconv_fallback_utf16be_utf8($string) {
 881:         if (substr($string, 0, 2) == "\xFE\xFF") {
 882:             // strip BOM
 883:             $string = substr($string, 2);
 884:         }
 885:         $newcharstring = '';
 886:         for ($i = 0; $i < strlen($string); $i += 2) {
 887:             $charval = self::BigEndian2Int(substr($string, $i, 2));
 888:             $newcharstring .= self::iconv_fallback_int_utf8($charval);
 889:         }
 890:         return $newcharstring;
 891:     }
 892: 
 893:     // UTF-16LE => UTF-8
 894:     public static function iconv_fallback_utf16le_utf8($string) {
 895:         if (substr($string, 0, 2) == "\xFF\xFE") {
 896:             // strip BOM
 897:             $string = substr($string, 2);
 898:         }
 899:         $newcharstring = '';
 900:         for ($i = 0; $i < strlen($string); $i += 2) {
 901:             $charval = self::LittleEndian2Int(substr($string, $i, 2));
 902:             $newcharstring .= self::iconv_fallback_int_utf8($charval);
 903:         }
 904:         return $newcharstring;
 905:     }
 906: 
 907:     // UTF-16BE => ISO-8859-1
 908:     public static function iconv_fallback_utf16be_iso88591($string) {
 909:         if (substr($string, 0, 2) == "\xFE\xFF") {
 910:             // strip BOM
 911:             $string = substr($string, 2);
 912:         }
 913:         $newcharstring = '';
 914:         for ($i = 0; $i < strlen($string); $i += 2) {
 915:             $charval = self::BigEndian2Int(substr($string, $i, 2));
 916:             $newcharstring .= (($charval < 256) ? chr($charval) : '?');
 917:         }
 918:         return $newcharstring;
 919:     }
 920: 
 921:     // UTF-16LE => ISO-8859-1
 922:     public static function iconv_fallback_utf16le_iso88591($string) {
 923:         if (substr($string, 0, 2) == "\xFF\xFE") {
 924:             // strip BOM
 925:             $string = substr($string, 2);
 926:         }
 927:         $newcharstring = '';
 928:         for ($i = 0; $i < strlen($string); $i += 2) {
 929:             $charval = self::LittleEndian2Int(substr($string, $i, 2));
 930:             $newcharstring .= (($charval < 256) ? chr($charval) : '?');
 931:         }
 932:         return $newcharstring;
 933:     }
 934: 
 935:     // UTF-16 (BOM) => ISO-8859-1
 936:     public static function iconv_fallback_utf16_iso88591($string) {
 937:         $bom = substr($string, 0, 2);
 938:         if ($bom == "\xFE\xFF") {
 939:             return self::iconv_fallback_utf16be_iso88591(substr($string, 2));
 940:         } elseif ($bom == "\xFF\xFE") {
 941:             return self::iconv_fallback_utf16le_iso88591(substr($string, 2));
 942:         }
 943:         return $string;
 944:     }
 945: 
 946:     // UTF-16 (BOM) => UTF-8
 947:     public static function iconv_fallback_utf16_utf8($string) {
 948:         $bom = substr($string, 0, 2);
 949:         if ($bom == "\xFE\xFF") {
 950:             return self::iconv_fallback_utf16be_utf8(substr($string, 2));
 951:         } elseif ($bom == "\xFF\xFE") {
 952:             return self::iconv_fallback_utf16le_utf8(substr($string, 2));
 953:         }
 954:         return $string;
 955:     }
 956: 
 957:     public static function iconv_fallback($in_charset, $out_charset, $string) {
 958: 
 959:         if ($in_charset == $out_charset) {
 960:             return $string;
 961:         }
 962: 
 963:         // iconv() availble
 964:         if (function_exists('iconv')) {
 965:             if ($converted_string = @iconv($in_charset, $out_charset.'//TRANSLIT', $string)) {
 966:                 switch ($out_charset) {
 967:                     case 'ISO-8859-1':
 968:                         $converted_string = rtrim($converted_string, "\x00");
 969:                         break;
 970:                 }
 971:                 return $converted_string;
 972:             }
 973: 
 974:             // iconv() may sometimes fail with "illegal character in input string" error message
 975:             // and return an empty string, but returning the unconverted string is more useful
 976:             return $string;
 977:         }
 978: 
 979: 
 980:         // iconv() not available
 981:         static $ConversionFunctionList = array();
 982:         if (empty($ConversionFunctionList)) {
 983:             $ConversionFunctionList['ISO-8859-1']['UTF-8']    = 'iconv_fallback_iso88591_utf8';
 984:             $ConversionFunctionList['ISO-8859-1']['UTF-16']   = 'iconv_fallback_iso88591_utf16';
 985:             $ConversionFunctionList['ISO-8859-1']['UTF-16BE'] = 'iconv_fallback_iso88591_utf16be';
 986:             $ConversionFunctionList['ISO-8859-1']['UTF-16LE'] = 'iconv_fallback_iso88591_utf16le';
 987:             $ConversionFunctionList['UTF-8']['ISO-8859-1']    = 'iconv_fallback_utf8_iso88591';
 988:             $ConversionFunctionList['UTF-8']['UTF-16']        = 'iconv_fallback_utf8_utf16';
 989:             $ConversionFunctionList['UTF-8']['UTF-16BE']      = 'iconv_fallback_utf8_utf16be';
 990:             $ConversionFunctionList['UTF-8']['UTF-16LE']      = 'iconv_fallback_utf8_utf16le';
 991:             $ConversionFunctionList['UTF-16']['ISO-8859-1']   = 'iconv_fallback_utf16_iso88591';
 992:             $ConversionFunctionList['UTF-16']['UTF-8']        = 'iconv_fallback_utf16_utf8';
 993:             $ConversionFunctionList['UTF-16LE']['ISO-8859-1'] = 'iconv_fallback_utf16le_iso88591';
 994:             $ConversionFunctionList['UTF-16LE']['UTF-8']      = 'iconv_fallback_utf16le_utf8';
 995:             $ConversionFunctionList['UTF-16BE']['ISO-8859-1'] = 'iconv_fallback_utf16be_iso88591';
 996:             $ConversionFunctionList['UTF-16BE']['UTF-8']      = 'iconv_fallback_utf16be_utf8';
 997:         }
 998:         if (isset($ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)])) {
 999:             $ConversionFunction = $ConversionFunctionList[strtoupper($in_charset)][strtoupper($out_charset)];
1000:             return self::$ConversionFunction($string);
1001:         }
1002:         throw new Exception('PHP does not have iconv() support - cannot convert from '.$in_charset.' to '.$out_charset);
1003:     }
1004: 
1005:     public static function recursiveMultiByteCharString2HTML($data, $charset='ISO-8859-1') {
1006:         if (is_string($data)) {
1007:             return self::MultiByteCharString2HTML($data, $charset);
1008:         } elseif (is_array($data)) {
1009:             $return_data = array();
1010:             foreach ($data as $key => $value) {
1011:                 $return_data[$key] = self::recursiveMultiByteCharString2HTML($value, $charset);
1012:             }
1013:             return $return_data;
1014:         }
1015:         // integer, float, objects, resources, etc
1016:         return $data;
1017:     }
1018: 
1019:     public static function MultiByteCharString2HTML($string, $charset='ISO-8859-1') {
1020:         $string = (string) $string; // in case trying to pass a numeric (float, int) string, would otherwise return an empty string
1021:         $HTMLstring = '';
1022: 
1023:         switch ($charset) {
1024:             case '1251':
1025:             case '1252':
1026:             case '866':
1027:             case '932':
1028:             case '936':
1029:             case '950':
1030:             case 'BIG5':
1031:             case 'BIG5-HKSCS':
1032:             case 'cp1251':
1033:             case 'cp1252':
1034:             case 'cp866':
1035:             case 'EUC-JP':
1036:             case 'EUCJP':
1037:             case 'GB2312':
1038:             case 'ibm866':
1039:             case 'ISO-8859-1':
1040:             case 'ISO-8859-15':
1041:             case 'ISO8859-1':
1042:             case 'ISO8859-15':
1043:             case 'KOI8-R':
1044:             case 'koi8-ru':
1045:             case 'koi8r':
1046:             case 'Shift_JIS':
1047:             case 'SJIS':
1048:             case 'win-1251':
1049:             case 'Windows-1251':
1050:             case 'Windows-1252':
1051:                 $HTMLstring = htmlentities($string, ENT_COMPAT, $charset);
1052:                 break;
1053: 
1054:             case 'UTF-8':
1055:                 $strlen = strlen($string);
1056:                 for ($i = 0; $i < $strlen; $i++) {
1057:                     $char_ord_val = ord($string{$i});
1058:                     $charval = 0;
1059:                     if ($char_ord_val < 0x80) {
1060:                         $charval = $char_ord_val;
1061:                     } elseif ((($char_ord_val & 0xF0) >> 4) == 0x0F  &&  $i+3 < $strlen) {
1062:                         $charval  = (($char_ord_val & 0x07) << 18);
1063:                         $charval += ((ord($string{++$i}) & 0x3F) << 12);
1064:                         $charval += ((ord($string{++$i}) & 0x3F) << 6);
1065:                         $charval +=  (ord($string{++$i}) & 0x3F);
1066:                     } elseif ((($char_ord_val & 0xE0) >> 5) == 0x07  &&  $i+2 < $strlen) {
1067:                         $charval  = (($char_ord_val & 0x0F) << 12);
1068:                         $charval += ((ord($string{++$i}) & 0x3F) << 6);
1069:                         $charval +=  (ord($string{++$i}) & 0x3F);
1070:                     } elseif ((($char_ord_val & 0xC0) >> 6) == 0x03  &&  $i+1 < $strlen) {
1071:                         $charval  = (($char_ord_val & 0x1F) << 6);
1072:                         $charval += (ord($string{++$i}) & 0x3F);
1073:                     }
1074:                     if (($charval >= 32) && ($charval <= 127)) {
1075:                         $HTMLstring .= htmlentities(chr($charval));
1076:                     } else {
1077:                         $HTMLstring .= '&#'.$charval.';';
1078:                     }
1079:                 }
1080:                 break;
1081: 
1082:             case 'UTF-16LE':
1083:                 for ($i = 0; $i < strlen($string); $i += 2) {
1084:                     $charval = self::LittleEndian2Int(substr($string, $i, 2));
1085:                     if (($charval >= 32) && ($charval <= 127)) {
1086:                         $HTMLstring .= chr($charval);
1087:                     } else {
1088:                         $HTMLstring .= '&#'.$charval.';';
1089:                     }
1090:                 }
1091:                 break;
1092: 
1093:             case 'UTF-16BE':
1094:                 for ($i = 0; $i < strlen($string); $i += 2) {
1095:                     $charval = self::BigEndian2Int(substr($string, $i, 2));
1096:                     if (($charval >= 32) && ($charval <= 127)) {
1097:                         $HTMLstring .= chr($charval);
1098:                     } else {
1099:                         $HTMLstring .= '&#'.$charval.';';
1100:                     }
1101:                 }
1102:                 break;
1103: 
1104:             default:
1105:                 $HTMLstring = 'ERROR: Character set "'.$charset.'" not supported in MultiByteCharString2HTML()';
1106:                 break;
1107:         }
1108:         return $HTMLstring;
1109:     }
1110: 
1111: 
1112: 
1113:     public static function RGADnameLookup($namecode) {
1114:         static $RGADname = array();
1115:         if (empty($RGADname)) {
1116:             $RGADname[0] = 'not set';
1117:             $RGADname[1] = 'Track Gain Adjustment';
1118:             $RGADname[2] = 'Album Gain Adjustment';
1119:         }
1120: 
1121:         return (isset($RGADname[$namecode]) ? $RGADname[$namecode] : '');
1122:     }
1123: 
1124: 
1125:     public static function RGADoriginatorLookup($originatorcode) {
1126:         static $RGADoriginator = array();
1127:         if (empty($RGADoriginator)) {
1128:             $RGADoriginator[0] = 'unspecified';
1129:             $RGADoriginator[1] = 'pre-set by artist/producer/mastering engineer';
1130:             $RGADoriginator[2] = 'set by user';
1131:             $RGADoriginator[3] = 'determined automatically';
1132:         }
1133: 
1134:         return (isset($RGADoriginator[$originatorcode]) ? $RGADoriginator[$originatorcode] : '');
1135:     }
1136: 
1137: 
1138:     public static function RGADadjustmentLookup($rawadjustment, $signbit) {
1139:         $adjustment = $rawadjustment / 10;
1140:         if ($signbit == 1) {
1141:             $adjustment *= -1;
1142:         }
1143:         return (float) $adjustment;
1144:     }
1145: 
1146: 
1147:     public static function RGADgainString($namecode, $originatorcode, $replaygain) {
1148:         if ($replaygain < 0) {
1149:             $signbit = '1';
1150:         } else {
1151:             $signbit = '0';
1152:         }
1153:         $storedreplaygain = intval(round($replaygain * 10));
1154:         $gainstring  = str_pad(decbin($namecode), 3, '0', STR_PAD_LEFT);
1155:         $gainstring .= str_pad(decbin($originatorcode), 3, '0', STR_PAD_LEFT);
1156:         $gainstring .= $signbit;
1157:         $gainstring .= str_pad(decbin($storedreplaygain), 9, '0', STR_PAD_LEFT);
1158: 
1159:         return $gainstring;
1160:     }
1161: 
1162:     public static function RGADamplitude2dB($amplitude) {
1163:         return 20 * log10($amplitude);
1164:     }
1165: 
1166: 
1167:     public static function GetDataImageSize($imgData, &$imageinfo=array()) {
1168:         static $tempdir = '';
1169:         if (empty($tempdir)) {
1170:             if (function_exists('sys_get_temp_dir')) {
1171:                 $tempdir = sys_get_temp_dir(); // https://github.com/JamesHeinrich/getID3/issues/52
1172:             }
1173: 
1174:             // yes this is ugly, feel free to suggest a better way
1175:             if (include_once(dirname(__FILE__).'/getid3.php')) {
1176:                 if ($getid3_temp = new getID3()) {
1177:                     if ($getid3_temp_tempdir = $getid3_temp->tempdir) {
1178:                         $tempdir = $getid3_temp_tempdir;
1179:                     }
1180:                     unset($getid3_temp, $getid3_temp_tempdir);
1181:                 }
1182:             }
1183:         }
1184:         $GetDataImageSize = false;
1185:         if ($tempfilename = tempnam($tempdir, 'gI3')) {
1186:             if (is_writable($tempfilename) && is_file($tempfilename) && ($tmp = fopen($tempfilename, 'wb'))) {
1187:                 fwrite($tmp, $imgData);
1188:                 fclose($tmp);
1189:                 $GetDataImageSize = @getimagesize($tempfilename, $imageinfo);
1190:                 if (($GetDataImageSize === false) || !isset($GetDataImageSize[0]) || !isset($GetDataImageSize[1])) {
1191:                     return false;
1192:                 }
1193:                 $GetDataImageSize['height'] = $GetDataImageSize[0];
1194:                 $GetDataImageSize['width']  = $GetDataImageSize[1];
1195:             }
1196:             unlink($tempfilename);
1197:         }
1198:         return $GetDataImageSize;
1199:     }
1200: 
1201:     public static function ImageExtFromMime($mime_type) {
1202:         // temporary way, works OK for now, but should be reworked in the future
1203:         return str_replace(array('image/', 'x-', 'jpeg'), array('', '', 'jpg'), $mime_type);
1204:     }
1205: 
1206:     public static function ImageTypesLookup($imagetypeid) {
1207:         static $ImageTypesLookup = array();
1208:         if (empty($ImageTypesLookup)) {
1209:             $ImageTypesLookup[1]  = 'gif';
1210:             $ImageTypesLookup[2]  = 'jpeg';
1211:             $ImageTypesLookup[3]  = 'png';
1212:             $ImageTypesLookup[4]  = 'swf';
1213:             $ImageTypesLookup[5]  = 'psd';
1214:             $ImageTypesLookup[6]  = 'bmp';
1215:             $ImageTypesLookup[7]  = 'tiff (little-endian)';
1216:             $ImageTypesLookup[8]  = 'tiff (big-endian)';
1217:             $ImageTypesLookup[9]  = 'jpc';
1218:             $ImageTypesLookup[10] = 'jp2';
1219:             $ImageTypesLookup[11] = 'jpx';
1220:             $ImageTypesLookup[12] = 'jb2';
1221:             $ImageTypesLookup[13] = 'swc';
1222:             $ImageTypesLookup[14] = 'iff';
1223:         }
1224:         return (isset($ImageTypesLookup[$imagetypeid]) ? $ImageTypesLookup[$imagetypeid] : '');
1225:     }
1226: 
1227:     public static function CopyTagsToComments(&$ThisFileInfo) {
1228: 
1229:         // Copy all entries from ['tags'] into common ['comments']
1230:         if (!empty($ThisFileInfo['tags'])) {
1231:             foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) {
1232:                 foreach ($tagarray as $tagname => $tagdata) {
1233:                     foreach ($tagdata as $key => $value) {
1234:                         if (!empty($value)) {
1235:                             if (empty($ThisFileInfo['comments'][$tagname])) {
1236: 
1237:                                 // fall through and append value
1238: 
1239:                             } elseif ($tagtype == 'id3v1') {
1240: 
1241:                                 $newvaluelength = strlen(trim($value));
1242:                                 foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
1243:                                     $oldvaluelength = strlen(trim($existingvalue));
1244:                                     if (($newvaluelength <= $oldvaluelength) && (substr($existingvalue, 0, $newvaluelength) == trim($value))) {
1245:                                         // new value is identical but shorter-than (or equal-length to) one already in comments - skip
1246:                                         break 2;
1247:                                     }
1248:                                 }
1249: 
1250:                             } elseif (!is_array($value)) {
1251: 
1252:                                 $newvaluelength = strlen(trim($value));
1253:                                 foreach ($ThisFileInfo['comments'][$tagname] as $existingkey => $existingvalue) {
1254:                                     $oldvaluelength = strlen(trim($existingvalue));
1255:                                     if ((strlen($existingvalue) > 10) && ($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) {
1256:                                         $ThisFileInfo['comments'][$tagname][$existingkey] = trim($value);
1257:                                         //break 2;
1258:                                         break;
1259:                                     }
1260:                                 }
1261: 
1262:                             }
1263:                             if (is_array($value) || empty($ThisFileInfo['comments'][$tagname]) || !in_array(trim($value), $ThisFileInfo['comments'][$tagname])) {
1264:                                 $value = (is_string($value) ? trim($value) : $value);
1265:                                 if (!is_numeric($key)) {
1266:                                     $ThisFileInfo['comments'][$tagname][$key] = $value;
1267:                                 } else {
1268:                                     $ThisFileInfo['comments'][$tagname][]     = $value;
1269:                                 }
1270:                             }
1271:                         }
1272:                     }
1273:                 }
1274:             }
1275: 
1276:             // Copy to ['comments_html']
1277:             if (!empty($ThisFileInfo['comments'])) {
1278:                 foreach ($ThisFileInfo['comments'] as $field => $values) {
1279:                     if ($field == 'picture') {
1280:                         // pictures can take up a lot of space, and we don't need multiple copies of them
1281:                         // let there be a single copy in [comments][picture], and not elsewhere
1282:                         continue;
1283:                     }
1284:                     foreach ($values as $index => $value) {
1285:                         if (is_array($value)) {
1286:                             $ThisFileInfo['comments_html'][$field][$index] = $value;
1287:                         } else {
1288:                             $ThisFileInfo['comments_html'][$field][$index] = str_replace('&#0;', '', self::MultiByteCharString2HTML($value, $ThisFileInfo['encoding']));
1289:                         }
1290:                     }
1291:                 }
1292:             }
1293: 
1294:         }
1295:         return true;
1296:     }
1297: 
1298: 
1299:     public static function EmbeddedLookup($key, $begin, $end, $file, $name) {
1300: 
1301:         // Cached
1302:         static $cache;
1303:         if (isset($cache[$file][$name])) {
1304:             return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
1305:         }
1306: 
1307:         // Init
1308:         $keylength  = strlen($key);
1309:         $line_count = $end - $begin - 7;
1310: 
1311:         // Open php file
1312:         $fp = fopen($file, 'r');
1313: 
1314:         // Discard $begin lines
1315:         for ($i = 0; $i < ($begin + 3); $i++) {
1316:             fgets($fp, 1024);
1317:         }
1318: 
1319:         // Loop thru line
1320:         while (0 < $line_count--) {
1321: 
1322:             // Read line
1323:             $line = ltrim(fgets($fp, 1024), "\t ");
1324: 
1325:             // METHOD A: only cache the matching key - less memory but slower on next lookup of not-previously-looked-up key
1326:             //$keycheck = substr($line, 0, $keylength);
1327:             //if ($key == $keycheck)  {
1328:             //  $cache[$file][$name][$keycheck] = substr($line, $keylength + 1);
1329:             //  break;
1330:             //}
1331: 
1332:             // METHOD B: cache all keys in this lookup - more memory but faster on next lookup of not-previously-looked-up key
1333:             //$cache[$file][$name][substr($line, 0, $keylength)] = trim(substr($line, $keylength + 1));
1334:             $explodedLine = explode("\t", $line, 2);
1335:             $ThisKey   = (isset($explodedLine[0]) ? $explodedLine[0] : '');
1336:             $ThisValue = (isset($explodedLine[1]) ? $explodedLine[1] : '');
1337:             $cache[$file][$name][$ThisKey] = trim($ThisValue);
1338:         }
1339: 
1340:         // Close and return
1341:         fclose($fp);
1342:         return (isset($cache[$file][$name][$key]) ? $cache[$file][$name][$key] : '');
1343:     }
1344: 
1345:     public static function IncludeDependency($filename, $sourcefile, $DieOnFailure=false) {
1346:         global $GETID3_ERRORARRAY;
1347: 
1348:         if (file_exists($filename)) {
1349:             if (include_once($filename)) {
1350:                 return true;
1351:             } else {
1352:                 $diemessage = basename($sourcefile).' depends on '.$filename.', which has errors';
1353:             }
1354:         } else {
1355:             $diemessage = basename($sourcefile).' depends on '.$filename.', which is missing';
1356:         }
1357:         if ($DieOnFailure) {
1358:             throw new Exception($diemessage);
1359:         } else {
1360:             $GETID3_ERRORARRAY[] = $diemessage;
1361:         }
1362:         return false;
1363:     }
1364: 
1365:     public static function trimNullByte($string) {
1366:         return trim($string, "\x00");
1367:     }
1368: 
1369:     public static function getFileSizeSyscall($path) {
1370:         $filesize = false;
1371: 
1372:         if (GETID3_OS_ISWINDOWS) {
1373:             if (class_exists('COM')) { // From PHP 5.3.15 and 5.4.5, COM and DOTNET is no longer built into the php core.you have to add COM support in php.ini:
1374:                 $filesystem = new COM('Scripting.FileSystemObject');
1375:                 $file = $filesystem->GetFile($path);
1376:                 $filesize = $file->Size();
1377:                 unset($filesystem, $file);
1378:             } else {
1379:                 $commandline = 'for %I in ('.escapeshellarg($path).') do @echo %~zI';
1380:             }
1381:         } else {
1382:             $commandline = 'ls -l '.escapeshellarg($path).' | awk \'{print $5}\'';
1383:         }
1384:         if (isset($commandline)) {
1385:             $output = trim(`$commandline`);
1386:             if (ctype_digit($output)) {
1387:                 $filesize = (float) $output;
1388:             }
1389:         }
1390:         return $filesize;
1391:     }
1392: 
1393: 
1394:     /**
1395:     * Workaround for Bug #37268 (https://bugs.php.net/bug.php?id=37268)
1396:     * @param string $path A path.
1397:     * @param string $suffix If the name component ends in suffix this will also be cut off.
1398:     * @return string
1399:     */
1400:     public static function mb_basename($path, $suffix = null) {
1401:         $splited = preg_split('#/#', rtrim($path, '/ '));
1402:         return substr(basename('X'.$splited[count($splited) - 1], $suffix), 1);
1403:     }
1404: 
1405: }
1406: 
Zenphoto doc API documentation generated by ApiGen