Overview

Namespaces

  • Composer
    • Autoload
  • Geekwright
    • RegDom
  • League
    • OAuth2
      • Client
        • Provider
  • None
  • Xmf
    • Database
    • Jwt
    • Key
    • Module
      • Helper

Classes

  • ArtObject
  • ArtObjectHandler
  • BloggerApi
  • CGIF
  • CGIFCOLORTABLE
  • CGIFFILEHEADER
  • CGIFIMAGE
  • CGIFIMAGEHEADER
  • CGIFLZW
  • Composer\Autoload\ClassLoader
  • Composer\Autoload\ComposerStaticInit274e5fff219a4f27a346e611b0580d6a
  • ComposerAutoloaderInit274e5fff219a4f27a346e611b0580d6a
  • Config_File
  • Cookie
  • Criteria
  • CriteriaCompo
  • CriteriaElement
  • Database
  • Db_manager
  • ErrorHandler
  • FormDhtmlTextArea
  • FormTextArea
  • Geekwright\RegDom\PublicSuffixList
  • Geekwright\RegDom\RegisteredDomain
  • HTMLPurifier
  • League\OAuth2\Client\Provider\Google
  • MetaWeblogApi
  • ModuleAdmin
  • MovableTypeApi
  • MyTextSanitizer
  • MyTextSanitizerExtended
  • MyTextSanitizerExtension
  • MytsCensor
  • MytsFlash
  • MytsIframe
  • MytsImage
  • MytsLi
  • MytsMms
  • MytsMp3
  • MytsRtsp
  • MytsSoundcloud
  • MytsSyntaxhighlight
  • MytsTextfilter
  • MytsUl
  • MytsWiki
  • MytsWmp
  • MytsYoutube
  • PathStuffController
  • PHPMailer
  • PHPMailerOAuth
  • PHPMailerOAuthGoogle
  • phpthumb
  • phpthumb_bmp
  • phpthumb_filters
  • phpthumb_functions
  • phpthumb_ico
  • phpUnsharpMask
  • PmCorePreload
  • PmMessage
  • PmMessageHandler
  • PmSystemPreload
  • POP3
  • ProfileCategory
  • ProfileCategoryHandler
  • ProfileCorePreload
  • ProfileField
  • ProfileFieldHandler
  • ProfileProfile
  • ProfileProfileHandler
  • ProfileRegstep
  • ProfileRegstepHandler
  • ProfileVisibility
  • ProfileVisibilityHandler
  • Protector
  • Protector_bruteforce_overrun_message
  • Protector_crawler_overrun_message
  • Protector_f5attack_overrun_message
  • Protector_postcommon_post_deny_by_httpbl
  • Protector_postcommon_post_deny_by_rbl
  • Protector_postcommon_post_htmlpurify4everyone
  • Protector_postcommon_post_htmlpurify4guest
  • Protector_postcommon_post_language_match
  • Protector_postcommon_post_need_multibyte
  • Protector_postcommon_post_register_moratorium
  • Protector_postcommon_post_stopforumspam
  • Protector_postcommon_register_insert_js_check
  • Protector_postcommon_register_stopforumspam
  • Protector_precommon_badip_errorlog
  • Protector_precommon_badip_message
  • Protector_precommon_badip_redirection
  • Protector_precommon_bwlimit_errorlog
  • Protector_precommon_bwlimit_message
  • Protector_prepurge_exit_message
  • Protector_spamcheck_overrun_message
  • ProtectorCorePreload
  • ProtectorFilterAbstract
  • ProtectorFilterHandler
  • ProtectorMySQLDatabase
  • ProtectorRegistry
  • ReCaptchaResponse
  • RpcArrayHandler
  • RpcBase64Handler
  • RpcBooleanHandler
  • RpcDateTimeHandler
  • RpcDoubleHandler
  • RpcIntHandler
  • RpcMemberHandler
  • RpcMethodNameHandler
  • RpcNameHandler
  • RpcStringHandler
  • RpcStructHandler
  • RpcValueHandler
  • RssAuthorHandler
  • RssCategoryHandler
  • RssChannelHandler
  • RssCommentsHandler
  • RssCopyrightHandler
  • RssDescriptionHandler
  • RssDocsHandler
  • RssGeneratorHandler
  • RssGuidHandler
  • RssHeightHandler
  • RssImageHandler
  • RssItemHandler
  • RssLanguageHandler
  • RssLastBuildDateHandler
  • RssLinkHandler
  • RssManagingEditorHandler
  • RssNameHandler
  • RssPubDateHandler
  • RssSourceHandler
  • RssTextInputHandler
  • RssTitleHandler
  • RssTtlHandler
  • RssUrlHandler
  • RssWebMasterHandler
  • RssWidthHandler
  • SaxParser
  • Smarty
  • Smarty_Compiler
  • SMTP
  • Snoopy
  • SqlUtility
  • SystemAvatar
  • SystemAvatarHandler
  • SystemBanner
  • SystemBannerclient
  • SystemBannerclientHandler
  • SystemBannerFinish
  • SystemBannerfinishHandler
  • SystemBannerHandler
  • SystemBlock
  • SystemBlockHandler
  • SystemBlockLinkModule
  • SystemBlockLinkModuleHandler
  • SystemBreadcrumb
  • SystemCorePreload
  • SystemFineAvatarUploadHandler
  • SystemFineImUploadHandler
  • SystemFineUploadHandler
  • SystemGroup
  • SystemGroupHandler
  • SystemMaintenance
  • SystemMenuHandler
  • SystemSmilies
  • SystemsmiliesHandler
  • SystemUserrank
  • SystemuserrankHandler
  • SystemUsers
  • SystemUsersHandler
  • Tar
  • ThemeSetAuthorHandler
  • ThemeSetDateCreatedHandler
  • ThemeSetDescriptionHandler
  • ThemeSetEmailHandler
  • ThemeSetFileTypeHandler
  • ThemeSetGeneratorHandler
  • ThemeSetImageHandler
  • ThemeSetLinkHandler
  • ThemeSetModuleHandler
  • ThemeSetNameHandler
  • ThemeSetTagHandler
  • ThemeSetTemplateHandler
  • TinyMCE
  • Xmf\Assert
  • Xmf\Database\Migrate
  • Xmf\Database\TableLoad
  • Xmf\Database\Tables
  • Xmf\Debug
  • Xmf\FilterInput
  • Xmf\Highlighter
  • Xmf\IPAddress
  • Xmf\Jwt\JsonWebToken
  • Xmf\Jwt\KeyFactory
  • Xmf\Jwt\TokenFactory
  • Xmf\Jwt\TokenReader
  • Xmf\Key\ArrayStorage
  • Xmf\Key\Basic
  • Xmf\Key\FileStorage
  • Xmf\Key\KeyAbstract
  • Xmf\Language
  • Xmf\Metagen
  • Xmf\Module\Admin
  • Xmf\Module\Helper
  • Xmf\Module\Helper\AbstractHelper
  • Xmf\Module\Helper\Cache
  • Xmf\Module\Helper\GenericHelper
  • Xmf\Module\Helper\Permission
  • Xmf\Module\Helper\Session
  • Xmf\Random
  • Xmf\Request
  • Xmf\StopWords
  • Xmf\Yaml
  • XmlTagHandler
  • XoopsApi
  • xoopsart
  • XoopsAuth
  • XoopsAuthAds
  • XoopsAuthFactory
  • XoopsAuthLdap
  • XoopsAuthProvisionning
  • XoopsAuthXoops
  • XoopsAvatar
  • XoopsAvatarHandler
  • XoopsBlock
  • XoopsBlockHandler
  • XoopsBlockInstance
  • XoopsBlockInstanceHandler
  • XoopsCache
  • XoopsCacheApc
  • XoopsCacheEngine
  • XoopsCacheFile
  • XoopsCacheMemcache
  • XoopsCacheModel
  • XoopsCacheModelHandler
  • XoopsCacheModelObject
  • XoopsCacheXcache
  • XoopsCaptcha
  • XoopsCaptchaImage
  • XoopsCaptchaImageHandler
  • XoopsCaptchaMethod
  • XoopsCaptchaRecaptcha
  • XoopsCaptchaRecaptcha2
  • XoopsCaptchaText
  • XoopsComment
  • XoopsCommentHandler
  • XoopsCommentRenderer
  • XoopsComments
  • XoopsConfigCategory
  • XoopsConfigCategoryHandler
  • XoopsConfigHandler
  • XoopsConfigItem
  • XoopsConfigItemHandler
  • XoopsConfigOption
  • XoopsConfigOptionHandler
  • XoopsDatabase
  • XoopsDatabaseFactory
  • XoopsDownloader
  • XoopsEditor
  • XoopsEditorHandler
  • XoopsErrorHandler
  • XoopsFile
  • XoopsFileHandler
  • XoopsFilterInput
  • XoopsFolderHandler
  • XoopsForm
  • XoopsFormButton
  • XoopsFormButtonTray
  • XoopsFormCaptcha
  • XoopsFormCheckBox
  • XoopsFormColorPicker
  • XoopsFormDateTime
  • XoopsFormDhtmlTextArea
  • XoopsFormEditor
  • XoopsFormElement
  • XoopsFormElementTray
  • XoopsFormFile
  • XoopsFormHidden
  • XoopsFormHiddenToken
  • XoopsFormLabel
  • XoopsFormPassword
  • XoopsFormRadio
  • XoopsFormRadioYN
  • XoopsFormRenderer
  • XoopsFormRendererBootstrap3
  • XoopsFormRendererLegacy
  • XoopsFormSelect
  • XoopsFormSelectCheckGroup
  • XoopsFormSelectCountry
  • XoopsFormSelectEditor
  • XoopsFormSelectGroup
  • XoopsFormSelectLang
  • XoopsFormSelectMatchOption
  • XoopsFormSelectTheme
  • XoopsFormSelectTimezone
  • XoopsFormSelectUser
  • XoopsFormText
  • XoopsFormTextArea
  • XoopsFormTextDateSelect
  • XoopsFormTinymce
  • XoopsGroup
  • XoopsGroupFormCheckBox
  • XoopsGroupHandler
  • XoopsGroupPerm
  • XoopsGroupPermForm
  • XoopsGroupPermHandler
  • XoopsGTicket
  • XoopsGuestUser
  • XoopsGuiDefault
  • XoopsGuiThadmin
  • XoopsGuiTransition
  • XoopsGuiZetadigme
  • XoopsHandlerRegistry
  • XoopsImage
  • XoopsImagecategory
  • XoopsImagecategoryHandler
  • XoopsImageHandler
  • XoopsImageSet
  • XoopsImagesetHandler
  • XoopsImagesetimg
  • XoopsImagesetimgHandler
  • XoopsInstallWizard
  • XoopsLists
  • XoopsLoad
  • XoopsLocal
  • XoopsLocalAbstract
  • XoopsLocalWrapper
  • XoopsLogger
  • XoopsMailer
  • XoopsMailerLocal
  • XoopsMediaUploader
  • XoopsMemberHandler
  • XoopsMembership
  • XoopsMembershipHandler
  • XoopsModelAbstract
  • XoopsModelFactory
  • XoopsModelJoint
  • XoopsModelRead
  • XoopsModelStats
  • XoopsModelSync
  • XoopsModelWrite
  • XoopsModule
  • XoopsModuleHandler
  • XoopsMultiMailer
  • XoopsMySQLDatabase
  • XoopsMySQLDatabaseProxy
  • XoopsMySQLDatabaseSafe
  • XoopsNotification
  • XoopsNotificationHandler
  • XoopsObject
  • XoopsObjectHandler
  • XoopsObjectTree
  • XoopsOnlineHandler
  • XoopsPageNav
  • XoopsPersistableObjectHandler
  • XoopsPreload
  • XoopsPreloadItem
  • XoopsPrivmessage
  • XoopsPrivmessageHandler
  • XoopsRank
  • XoopsRankHandler
  • XoopsRequest
  • XoopsSecurity
  • XoopsSessionHandler
  • XoopsSimpleForm
  • XoopsStory
  • XoopsSystemCpanel
  • XoopsSystemGui
  • XoopsTableForm
  • XoopsTarDownloader
  • XoopsThemeForm
  • XoopsThemeSetParser
  • XoopsTopic
  • XoopsTpl
  • XoopsTplfile
  • XoopsTplfileHandler
  • XoopsTplset
  • XoopsTplsetHandler
  • XoopsTree
  • XoopsUser
  • XoopsUserHandler
  • XoopsUserUtility
  • XoopsUtility
  • XoopsXmlRpcApi
  • XoopsXmlRpcArray
  • XoopsXmlRpcBase64
  • XoopsXmlRpcBoolean
  • XoopsXmlRpcDatetime
  • XoopsXmlRpcDocument
  • XoopsXmlRpcDouble
  • XoopsXmlRpcFault
  • XoopsXmlRpcInt
  • XoopsXmlRpcParser
  • XoopsXmlRpcRequest
  • XoopsXmlRpcResponse
  • XoopsXmlRpcString
  • XoopsXmlRpcStruct
  • XoopsXmlRpcTag
  • XoopsXmlRss2Parser
  • XoopsZipDownloader
  • xos_kernel_Xoops2
  • xos_logos_PageBuilder
  • xos_opal_AdminThemeFactory
  • xos_opal_Theme
  • xos_opal_ThemeFactory
  • XoUser
  • XoUserHandler
  • Zipfile

Interfaces

  • Xmf\Key\StorageInterface
  • XoopsFormRendererInterface

Exceptions

  • phpmailerException

Functions

  • __autoload
  • _recaptcha_aes_encrypt
  • _recaptcha_aes_pad
  • _recaptcha_http_post
  • _recaptcha_mailhide_email_parts
  • _recaptcha_mailhide_urlbase64
  • _recaptcha_qsencode
  • _smarty_regex_replace_check
  • _smarty_sort_length
  • admin_refcheck
  • b_system_comments_edit
  • b_system_comments_show
  • b_system_info_edit
  • b_system_info_show
  • b_system_login_show
  • b_system_main_show
  • b_system_newmembers_edit
  • b_system_newmembers_show
  • b_system_notification_show
  • b_system_online_show
  • b_system_search_show
  • b_system_themes_edit
  • b_system_themes_show
  • b_system_topposters_edit
  • b_system_topposters_show
  • b_system_user_show
  • b_system_waiting_show
  • bannerstats
  • change_banner_url_by_client
  • checkEmail
  • clickbanner
  • clientlogin
  • closeTable
  • closeThread
  • CloseWaitBox
  • Composer\Autoload\includeFile
  • composerRequire274e5fff219a4f27a346e611b0580d6a
  • createConfigform
  • createThemeform
  • doConditionalGet
  • emailStats
  • exit404BadReq
  • fatalPhpErrorHandler
  • file_get_contents
  • file_put_contents
  • findSharp
  • form_user
  • formatTimestamp
  • formatURL
  • gd_info
  • genPathCheckHtml
  • get_request_method
  • get_writeoks_from_protector
  • getcss
  • getDbCharsets
  • getDbCollations
  • getDirList
  • getMailer
  • getTheme
  • gif_getSize
  • gif_loadFile
  • gif_loadFileToGDimageResource
  • gif_outputAsBmp
  • gif_outputAsJpeg
  • gif_outputAsPng
  • HTMLPurifier
  • imagealphablending
  • imageBrowser
  • imageCreateCorners
  • imageFilenameCheck
  • imagesavealpha
  • install_acceptUser
  • install_finalize
  • is_executable
  • kses
  • langDropdown
  • load_functions
  • load_object
  • load_objectHandler
  • loadModuleAdminMenu
  • make_cblock
  • make_data
  • make_groups
  • make_sidebar
  • mod_clearCacheFile
  • mod_clearConfg
  • mod_clearConfig
  • mod_clearFile
  • mod_clearSmartyCache
  • mod_constant
  • mod_createCacheFile
  • mod_createCacheFile_byGroup
  • mod_createFile
  • mod_DB_prefix
  • mod_fetchConfg
  • mod_fetchConfig
  • mod_generateCacheId
  • mod_generateCacheId_byGroup
  • mod_getDirname
  • mod_getIP
  • mod_getMysqlVersion
  • mod_getUnameFromId
  • mod_getUnameFromIds
  • mod_isModuleAction
  • mod_loadCacheFile
  • mod_loadCacheFile_byGroup
  • mod_loadConfg
  • mod_loadConfig
  • mod_loadFile
  • mod_loadFunctions
  • mod_loadRenderer
  • mod_message
  • modify_chmod
  • myTextForm
  • notificationCategoryInfo
  • notificationCommentCategoryInfo
  • notificationEnabled
  • notificationEventEnabled
  • notificationEventInfo
  • notificationEvents
  • notificationGenerateConfig
  • notificationSubscribableCategoryInfo
  • openTable
  • openThread
  • OpenWaitBox
  • PHPMailerAutoload
  • phpThumbURL
  • preg_quote
  • profile_getFieldForm
  • profile_getRegisterForm
  • profile_getStepForm
  • profile_getUserForm
  • profile_install_addCategory
  • profile_install_addField
  • profile_install_addStep
  • profile_install_initializeProfiles
  • profile_install_setPermissions
  • protector_message_append_oninstall
  • protector_message_append_onuninstall
  • protector_message_append_onupdate
  • protector_notify_base
  • protector_oninstall_base
  • protector_onuninstall_base
  • protector_onupdate_base
  • protector_postcommon
  • protector_prepare
  • recaptcha_check_answer
  • recaptcha_get_html
  • recaptcha_get_signup_url
  • recaptcha_mailhide_html
  • recaptcha_mailhide_url
  • redirect_header
  • RedirectToCachedFile
  • SendSaveAsFileHeaderIfNeeded
  • showbanner
  • showThread
  • smarty_block_textformat
  • smarty_compiler_assign
  • smarty_compiler_foreachq
  • smarty_compiler_includeq
  • smarty_compiler_xoAdminIcons
  • smarty_compiler_xoAdminNav
  • smarty_compiler_xoAppUrl
  • smarty_compiler_xoImgUrl
  • smarty_compiler_xoModuleIcons16
  • smarty_compiler_xoModuleIcons32
  • smarty_compiler_xoModuleIconsBookmarks
  • smarty_core_assemble_plugin_filepath
  • smarty_core_assign_smarty_interface
  • smarty_core_create_dir_structure
  • smarty_core_display_debug_console
  • smarty_core_get_include_path
  • smarty_core_get_microtime
  • smarty_core_get_php_resource
  • smarty_core_is_secure
  • smarty_core_is_trusted
  • smarty_core_load_plugins
  • smarty_core_load_resource_plugin
  • smarty_core_process_cached_inserts
  • smarty_core_process_compiled_include
  • smarty_core_read_cache_file
  • smarty_core_rm_auto
  • smarty_core_rmdir
  • smarty_core_run_insert_handler
  • smarty_core_smarty_include_php
  • smarty_core_write_cache_file
  • smarty_core_write_compiled_include
  • smarty_core_write_compiled_resource
  • smarty_core_write_file
  • smarty_function_assign_debug_info
  • smarty_function_block
  • smarty_function_config_load
  • smarty_function_counter
  • smarty_function_cycle
  • smarty_function_debug
  • smarty_function_escape_special_chars
  • smarty_function_eval
  • smarty_function_fetch
  • smarty_function_html_checkboxes
  • smarty_function_html_checkboxes_output
  • smarty_function_html_image
  • smarty_function_html_options
  • smarty_function_html_options_optgroup
  • smarty_function_html_options_optoutput
  • smarty_function_html_radios
  • smarty_function_html_radios_output
  • smarty_function_html_select_date
  • smarty_function_html_select_time
  • smarty_function_html_table
  • smarty_function_html_table_cycle
  • smarty_function_mailto
  • smarty_function_math
  • smarty_function_popup
  • smarty_function_popup_init
  • smarty_function_securityToken
  • smarty_function_xoInboxCount
  • smarty_function_xoMemberInfo
  • smarty_function_xoops_link
  • smarty_function_xoPageNav
  • smarty_make_timestamp
  • smarty_modifier_capitalize
  • smarty_modifier_capitalize_ucfirst
  • smarty_modifier_cat
  • smarty_modifier_count_characters
  • smarty_modifier_count_paragraphs
  • smarty_modifier_count_sentences
  • smarty_modifier_count_words
  • smarty_modifier_date_format
  • smarty_modifier_debug_print_var
  • smarty_modifier_default
  • smarty_modifier_escape
  • smarty_modifier_indent
  • smarty_modifier_lower
  • smarty_modifier_nl2br
  • smarty_modifier_regex_replace
  • smarty_modifier_replace
  • smarty_modifier_spacify
  • smarty_modifier_string_format
  • smarty_modifier_strip
  • smarty_modifier_strip_tags
  • smarty_modifier_truncate
  • smarty_modifier_upper
  • smarty_modifier_wordwrap
  • smarty_outputfilter_trimwhitespace
  • smarty_outputfilter_trimwhitespace_replace
  • smarty_resource_db_secure
  • smarty_resource_db_source
  • smarty_resource_db_timestamp
  • smarty_resource_db_tplinfo
  • smarty_resource_db_trusted
  • synchronize
  • system_AdminIcons
  • system_adminVersion
  • system_CleanVars
  • system_loadLanguage
  • system_loadTemplate
  • themecenterposts
  • update_system_v211
  • userCheck
  • userTimeToServerTime
  • validateDbCharset
  • writeLicenseKey
  • xoBuildLicenceKey
  • xoDiag
  • xoDiagBoolSetting
  • xoDiagIfWritable
  • xoFormBlockCollation
  • xoFormField
  • xoFormFieldCharset
  • xoFormFieldCollation
  • xoFormSelect
  • xoops_aw_decode
  • xoops_aw_encode
  • xoops_bin2hex
  • xoops_comment_count
  • xoops_comment_delete
  • xoops_confirm
  • xoops_convert_decode
  • xoops_convert_encode
  • xoops_convert_encoding
  • xoops_cp_footer
  • xoops_cp_header
  • xoops_error
  • xoops_footer
  • xoops_getActiveModules
  • xoops_getbanner
  • xoops_getBaseDomain
  • xoops_getConfigOption
  • xoops_getcss
  • xoops_getenv
  • xoops_getHandler
  • xoops_getLinkedUnameFromId
  • xoops_getMailer
  • xoops_getModuleHandler
  • xoops_getModuleOption
  • xoops_getOption
  • xoops_getrank
  • xoops_getUrlDomain
  • xoops_getUserTimestamp
  • xoops_groupperm_deletebymoditem
  • xoops_header
  • xoops_hex2bin
  • xoops_isActiveModule
  • xoops_ishexstr
  • xoops_load
  • xoops_load_lang_file
  • xoops_loadLanguage
  • xoops_local
  • xoops_makepass
  • xoops_message
  • xoops_module_activate
  • xoops_module_change
  • xoops_module_deactivate
  • xoops_module_delayed_clean_cache
  • xoops_module_get_admin_menu
  • xoops_module_gettemplate
  • xoops_module_install
  • xoops_module_install_pm
  • xoops_module_install_profile
  • xoops_module_log_header
  • xoops_module_uninstall
  • xoops_module_update
  • xoops_module_update_pm
  • xoops_module_update_profile
  • xoops_module_update_system
  • xoops_module_write_admin_menu
  • xoops_notification_deletebyitem
  • xoops_notification_deletebymodule
  • xoops_notification_deletebyuser
  • xoops_refcheck
  • xoops_result
  • xoops_setActiveModules
  • xoops_setConfigOption
  • xoops_substr
  • xoops_template_clear_module_cache
  • xoops_template_touch
  • xoops_trim
  • xoops_utf8_encode
  • xoops_write_index_file
  • xoopsCodeTarea
  • xoopseditor_get_rootpath
  • XoopsErrorHandler_HandleError
  • xoopsfwrite
  • xoopsSmilies
  • xoPassField
  • xoPhpVersion
  • xoPutLicenseKey
  • xoStripeKey
  • Overview
  • Namespace
  • Class
  • Tree
   1: <?php
   2: ///////////////////////////////////////////////////////////////////////////////////////////////////
   3: // GIF Util - (C) 2003 Yamasoft (S/C)
   4: // http://www.yamasoft.com
   5: // All Rights Reserved
   6: // This file can be freely copied, distributed, modified, updated by anyone under the only
   7: // condition to leave the original address (Yamasoft, http://www.yamasoft.com) and this header.
   8: ///////////////////////////////////////////////////////////////////////////////////////////////////
   9: // <gif>  = gif_loadFile(filename, [index])
  10: // <bool> = gif_getSize(<gif> or filename, &width, &height)
  11: // <bool> = gif_outputAsPng(<gif>, filename, [bgColor])
  12: // <bool> = gif_outputAsBmp(<gif>, filename, [bgcolor])
  13: // <bool> = gif_outputAsJpeg(<gif>, filename, [bgcolor]) - use cjpeg if available otherwise uses GD
  14: ///////////////////////////////////////////////////////////////////////////////////////////////////
  15: // Original code by Fabien Ezber
  16: // Modified by James Heinrich <info@silisoftware.com> for use in phpThumb() - December 10, 2003
  17: // * Added function gif_loadFileToGDimageResource() - this returns a GD image resource
  18: // * Modified gif_outputAsJpeg() to check if it's running under Windows, or if cjpeg is not
  19: //   available, in which case it will attempt to output JPEG using GD functions
  20: // * added @ error-suppression to two lines where it checks: if ($this->m_img->m_bTrans)
  21: //   otherwise warnings are generated if error_reporting == E_ALL
  22: ///////////////////////////////////////////////////////////////////////////////////////////////////
  23: 
  24: function gif_loadFile($lpszFileName, $iIndex = 0)
  25: {
  26:     $gif = new CGIF();
  27:     if ($gif->loadFile($lpszFileName, $iIndex)) {
  28:         return $gif;
  29:     }
  30:     return false;
  31: }
  32: 
  33: ///////////////////////////////////////////////////////////////////////////////////////////////////
  34: 
  35: // Added by James Heinrich <info@silisoftware.com> - December 10, 2003
  36: function gif_loadFileToGDimageResource($gifFilename, $bgColor = -1)
  37: {
  38:     if ($gif = gif_loadFile($gifFilename)) {
  39: 
  40:         if (!phpthumb_functions::FunctionIsDisabled('set_time_limit')) {
  41:             // shouldn't take nearly this long
  42:             set_time_limit(120);
  43:         }
  44:         // general strategy: convert raw data to PNG then convert PNG data to GD image resource
  45:         $PNGdata = $gif->getPng($bgColor);
  46:         if ($img = @imagecreatefromstring($PNGdata)) {
  47: 
  48:             // excellent - PNG image data successfully converted to GD image
  49:             return $img;
  50: 
  51:         } elseif ($img = $gif->getGD_PixelPlotterVersion()) {
  52: 
  53:             // problem: imagecreatefromstring() didn't like the PNG image data.
  54:             //   This has been known to happen in PHP v4.0.6
  55:             // solution: take the raw image data and create a new GD image and plot
  56:             //   pixel-by-pixel on the GD image. This is extremely slow, but it does
  57:             //   work and a slow solution is better than no solution, right? :)
  58:             return $img;
  59: 
  60:         }
  61:     }
  62:     return false;
  63: }
  64: 
  65: ///////////////////////////////////////////////////////////////////////////////////////////////////
  66: 
  67: function gif_outputAsBmp($gif, $lpszFileName, $bgColor = -1)
  68: {
  69:     if (!isset($gif) || (@get_class($gif) <> 'cgif') || !$gif->loaded() || ($lpszFileName == '')) {
  70:         return false;
  71:     }
  72: 
  73:     $fd = $gif->getBmp($bgColor);
  74:     if (strlen($fd) <= 0) {
  75:         return false;
  76:     }
  77: 
  78:     if (!($fh = @fopen($lpszFileName, 'wb'))) {
  79:         return false;
  80:     }
  81:     @fwrite($fh, $fd, strlen($fd));
  82:     @fflush($fh);
  83:     @fclose($fh);
  84:     return true;
  85: }
  86: 
  87: ///////////////////////////////////////////////////////////////////////////////////////////////////
  88: 
  89: function gif_outputAsPng($gif, $lpszFileName, $bgColor = -1)
  90: {
  91:     if (!isSet($gif) || (@get_class($gif) <> 'cgif') || !$gif->loaded() || ($lpszFileName == '')) {
  92:         return false;
  93:     }
  94: 
  95:     $fd = $gif->getPng($bgColor);
  96:     if (strlen($fd) <= 0) {
  97:         return false;
  98:     }
  99: 
 100:     if (!($fh = @fopen($lpszFileName, 'wb'))) {
 101:         return false;
 102:     }
 103:     @fwrite($fh, $fd, strlen($fd));
 104:     @fflush($fh);
 105:     @fclose($fh);
 106:     return true;
 107: }
 108: 
 109: ///////////////////////////////////////////////////////////////////////////////////////////////////
 110: 
 111: function gif_outputAsJpeg($gif, $lpszFileName, $bgColor = -1)
 112: {
 113:     // JPEG output that does not require cjpeg added by James Heinrich <info@silisoftware.com> - December 10, 2003
 114:     if ((strtoupper(substr(PHP_OS, 0, 3)) != 'WIN') && (file_exists('/usr/local/bin/cjpeg') || `which cjpeg`)) {
 115: 
 116:         if (gif_outputAsBmp($gif, $lpszFileName.'.bmp', $bgColor)) {
 117:             exec('cjpeg '.$lpszFileName.'.bmp >'.$lpszFileName.' 2>/dev/null');
 118:             @unlink($lpszFileName.'.bmp');
 119: 
 120:             if (@file_exists($lpszFileName)) {
 121:                 if (@filesize($lpszFileName) > 0) {
 122:                     return true;
 123:                 }
 124: 
 125:                 @unlink($lpszFileName);
 126:             }
 127:         }
 128: 
 129:     } else {
 130: 
 131:         // either Windows, or cjpeg not found in path
 132:         if ($img = @imagecreatefromstring($gif->getPng($bgColor))) {
 133:             if (@imagejpeg($img, $lpszFileName)) {
 134:                 return true;
 135:             }
 136:         }
 137: 
 138:     }
 139: 
 140:     return false;
 141: }
 142: 
 143: ///////////////////////////////////////////////////////////////////////////////////////////////////
 144: 
 145: function gif_getSize($gif, &$width, &$height)
 146: {
 147:     if (isSet($gif) && (@get_class($gif) == 'cgif') && $gif->loaded()) {
 148:         $width  = $gif->width();
 149:         $height = $gif->height();
 150:     } elseif (@file_exists($gif)) {
 151:         $myGIF = new CGIF();
 152:         if (!$myGIF->getSize($gif, $width, $height)) {
 153:             return false;
 154:         }
 155:     } else {
 156:         return false;
 157:     }
 158: 
 159:     return true;
 160: }
 161: 
 162: ///////////////////////////////////////////////////////////////////////////////////////////////////
 163: 
 164: class CGIFLZW
 165: {
 166:     var $MAX_LZW_BITS;
 167:     var $Fresh, $CodeSize, $SetCodeSize, $MaxCode, $MaxCodeSize, $FirstCode, $OldCode;
 168:     var $ClearCode, $EndCode, $Next, $Vals, $Stack, $sp, $Buf, $CurBit, $LastBit, $Done, $LastByte;
 169: 
 170:     ///////////////////////////////////////////////////////////////////////////
 171: 
 172:     // CONSTRUCTOR
 173:     function __construct()
 174:     {
 175:         $this->MAX_LZW_BITS = 12;
 176:         unSet($this->Next);
 177:         unSet($this->Vals);
 178:         unSet($this->Stack);
 179:         unSet($this->Buf);
 180: 
 181:         $this->Next  = range(0, (1 << $this->MAX_LZW_BITS)       - 1);
 182:         $this->Vals  = range(0, (1 << $this->MAX_LZW_BITS)       - 1);
 183:         $this->Stack = range(0, (1 << ($this->MAX_LZW_BITS + 1)) - 1);
 184:         $this->Buf   = range(0, 279);
 185:     }
 186: 
 187:     ///////////////////////////////////////////////////////////////////////////
 188: 
 189:     function deCompress($data, &$datLen)
 190:     {
 191:         $stLen  = strlen($data);
 192:         $datLen = 0;
 193:         $ret    = '';
 194: 
 195:         // INITIALIZATION
 196:         $this->LZWCommand($data, true);
 197: 
 198:         while (($iIndex = $this->LZWCommand($data, false)) >= 0) {
 199:             $ret .= chr($iIndex);
 200:         }
 201: 
 202:         $datLen = $stLen - strlen($data);
 203: 
 204:         if ($iIndex != -2) {
 205:             return false;
 206:         }
 207: 
 208:         return $ret;
 209:     }
 210: 
 211:     ///////////////////////////////////////////////////////////////////////////
 212: 
 213:     function LZWCommand(&$data, $bInit)
 214:     {
 215:         if ($bInit) {
 216:             $this->SetCodeSize = ord($data{0});
 217:             $data = substr($data, 1);
 218: 
 219:             $this->CodeSize    = $this->SetCodeSize + 1;
 220:             $this->ClearCode   = 1 << $this->SetCodeSize;
 221:             $this->EndCode     = $this->ClearCode + 1;
 222:             $this->MaxCode     = $this->ClearCode + 2;
 223:             $this->MaxCodeSize = $this->ClearCode << 1;
 224: 
 225:             $this->GetCode($data, $bInit);
 226: 
 227:             $this->Fresh = 1;
 228:             for ($i = 0; $i < $this->ClearCode; $i++) {
 229:                 $this->Next[$i] = 0;
 230:                 $this->Vals[$i] = $i;
 231:             }
 232: 
 233:             for (; $i < (1 << $this->MAX_LZW_BITS); $i++) {
 234:                 $this->Next[$i] = 0;
 235:                 $this->Vals[$i] = 0;
 236:             }
 237: 
 238:             $this->sp = 0;
 239:             return 1;
 240:         }
 241: 
 242:         if ($this->Fresh) {
 243:             $this->Fresh = 0;
 244:             do {
 245:                 $this->FirstCode = $this->GetCode($data, $bInit);
 246:                 $this->OldCode   = $this->FirstCode;
 247:             }
 248:             while ($this->FirstCode == $this->ClearCode);
 249: 
 250:             return $this->FirstCode;
 251:         }
 252: 
 253:         if ($this->sp > 0) {
 254:             $this->sp--;
 255:             return $this->Stack[$this->sp];
 256:         }
 257: 
 258:         while (($Code = $this->GetCode($data, $bInit)) >= 0) {
 259:             if ($Code == $this->ClearCode) {
 260:                 for ($i = 0; $i < $this->ClearCode; $i++) {
 261:                     $this->Next[$i] = 0;
 262:                     $this->Vals[$i] = $i;
 263:                 }
 264: 
 265:                 for (; $i < (1 << $this->MAX_LZW_BITS); $i++) {
 266:                     $this->Next[$i] = 0;
 267:                     $this->Vals[$i] = 0;
 268:                 }
 269: 
 270:                 $this->CodeSize    = $this->SetCodeSize + 1;
 271:                 $this->MaxCodeSize = $this->ClearCode << 1;
 272:                 $this->MaxCode     = $this->ClearCode + 2;
 273:                 $this->sp          = 0;
 274:                 $this->FirstCode   = $this->GetCode($data, $bInit);
 275:                 $this->OldCode     = $this->FirstCode;
 276: 
 277:                 return $this->FirstCode;
 278:             }
 279: 
 280:             if ($Code == $this->EndCode) {
 281:                 return -2;
 282:             }
 283: 
 284:             $InCode = $Code;
 285:             if ($Code >= $this->MaxCode) {
 286:                 $this->Stack[$this->sp] = $this->FirstCode;
 287:                 $this->sp++;
 288:                 $Code = $this->OldCode;
 289:             }
 290: 
 291:             while ($Code >= $this->ClearCode) {
 292:                 $this->Stack[$this->sp] = $this->Vals[$Code];
 293:                 $this->sp++;
 294: 
 295:                 if ($Code == $this->Next[$Code]) // Circular table entry, big GIF Error!
 296:                     return -1;
 297: 
 298:                 $Code = $this->Next[$Code];
 299:             }
 300: 
 301:             $this->FirstCode = $this->Vals[$Code];
 302:             $this->Stack[$this->sp] = $this->FirstCode;
 303:             $this->sp++;
 304: 
 305:             if (($Code = $this->MaxCode) < (1 << $this->MAX_LZW_BITS)) {
 306:                 $this->Next[$Code] = $this->OldCode;
 307:                 $this->Vals[$Code] = $this->FirstCode;
 308:                 $this->MaxCode++;
 309: 
 310:                 if (($this->MaxCode >= $this->MaxCodeSize) && ($this->MaxCodeSize < (1 << $this->MAX_LZW_BITS))) {
 311:                     $this->MaxCodeSize *= 2;
 312:                     $this->CodeSize++;
 313:                 }
 314:             }
 315: 
 316:             $this->OldCode = $InCode;
 317:             if ($this->sp > 0) {
 318:                 $this->sp--;
 319:                 return $this->Stack[$this->sp];
 320:             }
 321:         }
 322: 
 323:         return $Code;
 324:     }
 325: 
 326:     ///////////////////////////////////////////////////////////////////////////
 327: 
 328:     function GetCode(&$data, $bInit)
 329:     {
 330:         if ($bInit) {
 331:             $this->CurBit   = 0;
 332:             $this->LastBit  = 0;
 333:             $this->Done     = 0;
 334:             $this->LastByte = 2;
 335:             return 1;
 336:         }
 337: 
 338:         if (($this->CurBit + $this->CodeSize) >= $this->LastBit) {
 339:             if ($this->Done) {
 340:                 if ($this->CurBit >= $this->LastBit) {
 341:                     // Ran off the end of my bits
 342:                     return 0;
 343:                 }
 344:                 return -1;
 345:             }
 346: 
 347:             $this->Buf[0] = $this->Buf[$this->LastByte - 2];
 348:             $this->Buf[1] = $this->Buf[$this->LastByte - 1];
 349: 
 350:             $Count = ord($data{0});
 351:             $data  = substr($data, 1);
 352: 
 353:             if ($Count) {
 354:                 for ($i = 0; $i < $Count; $i++) {
 355:                     $this->Buf[2 + $i] = ord($data{$i});
 356:                 }
 357:                 $data = substr($data, $Count);
 358:             } else {
 359:                 $this->Done = 1;
 360:             }
 361: 
 362:             $this->LastByte = 2 + $Count;
 363:             $this->CurBit   = ($this->CurBit - $this->LastBit) + 16;
 364:             $this->LastBit  = (2 + $Count) << 3;
 365:         }
 366: 
 367:         $iRet = 0;
 368:         for ($i = $this->CurBit, $j = 0; $j < $this->CodeSize; $i++, $j++) {
 369:             $iRet |= (($this->Buf[intval($i / 8)] & (1 << ($i % 8))) != 0) << $j;
 370:         }
 371: 
 372:         $this->CurBit += $this->CodeSize;
 373:         return $iRet;
 374:     }
 375: }
 376: 
 377: ///////////////////////////////////////////////////////////////////////////////////////////////////
 378: 
 379: class CGIFCOLORTABLE
 380: {
 381:     var $m_nColors;
 382:     var $m_arColors;
 383: 
 384:     ///////////////////////////////////////////////////////////////////////////
 385: 
 386:     // CONSTRUCTOR
 387:     function __construct()
 388:     {
 389:         unSet($this->m_nColors);
 390:         unSet($this->m_arColors);
 391:     }
 392: 
 393:     ///////////////////////////////////////////////////////////////////////////
 394: 
 395:     function load($lpData, $num)
 396:     {
 397:         $this->m_nColors  = 0;
 398:         $this->m_arColors = array();
 399: 
 400:         for ($i = 0; $i < $num; $i++) {
 401:             $rgb = substr($lpData, $i * 3, 3);
 402:             if (strlen($rgb) < 3) {
 403:                 return false;
 404:             }
 405: 
 406:             $this->m_arColors[] = (ord($rgb{2}) << 16) + (ord($rgb{1}) << 8) + ord($rgb{0});
 407:             $this->m_nColors++;
 408:         }
 409: 
 410:         return true;
 411:     }
 412: 
 413:     ///////////////////////////////////////////////////////////////////////////
 414: 
 415:     function toString()
 416:     {
 417:         $ret = '';
 418: 
 419:         for ($i = 0; $i < $this->m_nColors; $i++) {
 420:             $ret .=
 421:                 chr(($this->m_arColors[$i] & 0x000000FF))       . // R
 422:                 chr(($this->m_arColors[$i] & 0x0000FF00) >>  8) . // G
 423:                 chr(($this->m_arColors[$i] & 0x00FF0000) >> 16);  // B
 424:         }
 425: 
 426:         return $ret;
 427:     }
 428: 
 429:     ///////////////////////////////////////////////////////////////////////////
 430: 
 431:     function toRGBQuad()
 432:     {
 433:         $ret = '';
 434: 
 435:         for ($i = 0; $i < $this->m_nColors; $i++) {
 436:             $ret .=
 437:                 chr(($this->m_arColors[$i] & 0x00FF0000) >> 16) . // B
 438:                 chr(($this->m_arColors[$i] & 0x0000FF00) >>  8) . // G
 439:                 chr(($this->m_arColors[$i] & 0x000000FF))       . // R
 440:                 "\x00";
 441:         }
 442: 
 443:         return $ret;
 444:     }
 445: 
 446:     ///////////////////////////////////////////////////////////////////////////
 447: 
 448:     function colorIndex($rgb)
 449:     {
 450:         $rgb = intval($rgb) & 0xFFFFFF;
 451:         $r1  = ($rgb & 0x0000FF);
 452:         $g1  = ($rgb & 0x00FF00) >>  8;
 453:         $b1  = ($rgb & 0xFF0000) >> 16;
 454:         $idx = -1;
 455:         $dif = 0;
 456: 
 457:         for ($i = 0; $i < $this->m_nColors; $i++) {
 458:             $r2 = ($this->m_arColors[$i] & 0x000000FF);
 459:             $g2 = ($this->m_arColors[$i] & 0x0000FF00) >>  8;
 460:             $b2 = ($this->m_arColors[$i] & 0x00FF0000) >> 16;
 461:             $d  = abs($r2 - $r1) + abs($g2 - $g1) + abs($b2 - $b1);
 462: 
 463:             if (($idx == -1) || ($d < $dif)) {
 464:                 $idx = $i;
 465:                 $dif = $d;
 466:             }
 467:         }
 468: 
 469:         return $idx;
 470:     }
 471: }
 472: 
 473: ///////////////////////////////////////////////////////////////////////////////////////////////////
 474: 
 475: class CGIFFILEHEADER
 476: {
 477:     var $m_lpVer;
 478:     var $m_nWidth;
 479:     var $m_nHeight;
 480:     var $m_bGlobalClr;
 481:     var $m_nColorRes;
 482:     var $m_bSorted;
 483:     var $m_nTableSize;
 484:     var $m_nBgColor;
 485:     var $m_nPixelRatio;
 486:     var $m_colorTable;
 487: 
 488:     ///////////////////////////////////////////////////////////////////////////
 489: 
 490:     // CONSTRUCTOR
 491:     function __construct()
 492:     {
 493:         unSet($this->m_lpVer);
 494:         unSet($this->m_nWidth);
 495:         unSet($this->m_nHeight);
 496:         unSet($this->m_bGlobalClr);
 497:         unSet($this->m_nColorRes);
 498:         unSet($this->m_bSorted);
 499:         unSet($this->m_nTableSize);
 500:         unSet($this->m_nBgColor);
 501:         unSet($this->m_nPixelRatio);
 502:         unSet($this->m_colorTable);
 503:     }
 504: 
 505:     ///////////////////////////////////////////////////////////////////////////
 506: 
 507:     function load($lpData, &$hdrLen)
 508:     {
 509:         $hdrLen = 0;
 510: 
 511:         $this->m_lpVer = substr($lpData, 0, 6);
 512:         if (($this->m_lpVer <> 'GIF87a') && ($this->m_lpVer <> 'GIF89a')) {
 513:             return false;
 514:         }
 515: 
 516:         $this->m_nWidth  = $this->w2i(substr($lpData, 6, 2));
 517:         $this->m_nHeight = $this->w2i(substr($lpData, 8, 2));
 518:         if (!$this->m_nWidth || !$this->m_nHeight) {
 519:             return false;
 520:         }
 521: 
 522:         $b = ord(substr($lpData, 10, 1));
 523:         $this->m_bGlobalClr  = ($b & 0x80) ? true : false;
 524:         $this->m_nColorRes   = ($b & 0x70) >> 4;
 525:         $this->m_bSorted     = ($b & 0x08) ? true : false;
 526:         $this->m_nTableSize  = 2 << ($b & 0x07);
 527:         $this->m_nBgColor    = ord(substr($lpData, 11, 1));
 528:         $this->m_nPixelRatio = ord(substr($lpData, 12, 1));
 529:         $hdrLen = 13;
 530: 
 531:         if ($this->m_bGlobalClr) {
 532:             $this->m_colorTable = new CGIFCOLORTABLE();
 533:             if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) {
 534:                 return false;
 535:             }
 536:             $hdrLen += 3 * $this->m_nTableSize;
 537:         }
 538: 
 539:         return true;
 540:     }
 541: 
 542:     ///////////////////////////////////////////////////////////////////////////
 543: 
 544:     function w2i($str)
 545:     {
 546:         return ord(substr($str, 0, 1)) + (ord(substr($str, 1, 1)) << 8);
 547:     }
 548: }
 549: 
 550: ///////////////////////////////////////////////////////////////////////////////////////////////////
 551: 
 552: class CGIFIMAGEHEADER
 553: {
 554:     var $m_nLeft;
 555:     var $m_nTop;
 556:     var $m_nWidth;
 557:     var $m_nHeight;
 558:     var $m_bLocalClr;
 559:     var $m_bInterlace;
 560:     var $m_bSorted;
 561:     var $m_nTableSize;
 562:     var $m_colorTable;
 563: 
 564:     ///////////////////////////////////////////////////////////////////////////
 565: 
 566:     // CONSTRUCTOR
 567:     function __construct()
 568:     {
 569:         unSet($this->m_nLeft);
 570:         unSet($this->m_nTop);
 571:         unSet($this->m_nWidth);
 572:         unSet($this->m_nHeight);
 573:         unSet($this->m_bLocalClr);
 574:         unSet($this->m_bInterlace);
 575:         unSet($this->m_bSorted);
 576:         unSet($this->m_nTableSize);
 577:         unSet($this->m_colorTable);
 578:     }
 579: 
 580:     ///////////////////////////////////////////////////////////////////////////
 581: 
 582:     function load($lpData, &$hdrLen)
 583:     {
 584:         $hdrLen = 0;
 585: 
 586:         $this->m_nLeft   = $this->w2i(substr($lpData, 0, 2));
 587:         $this->m_nTop    = $this->w2i(substr($lpData, 2, 2));
 588:         $this->m_nWidth  = $this->w2i(substr($lpData, 4, 2));
 589:         $this->m_nHeight = $this->w2i(substr($lpData, 6, 2));
 590: 
 591:         if (!$this->m_nWidth || !$this->m_nHeight) {
 592:             return false;
 593:         }
 594: 
 595:         $b = ord($lpData{8});
 596:         $this->m_bLocalClr  = ($b & 0x80) ? true : false;
 597:         $this->m_bInterlace = ($b & 0x40) ? true : false;
 598:         $this->m_bSorted    = ($b & 0x20) ? true : false;
 599:         $this->m_nTableSize = 2 << ($b & 0x07);
 600:         $hdrLen = 9;
 601: 
 602:         if ($this->m_bLocalClr) {
 603:             $this->m_colorTable = new CGIFCOLORTABLE();
 604:             if (!$this->m_colorTable->load(substr($lpData, $hdrLen), $this->m_nTableSize)) {
 605:                 return false;
 606:             }
 607:             $hdrLen += 3 * $this->m_nTableSize;
 608:         }
 609: 
 610:         return true;
 611:     }
 612: 
 613:     ///////////////////////////////////////////////////////////////////////////
 614: 
 615:     function w2i($str)
 616:     {
 617:         return ord(substr($str, 0, 1)) + (ord(substr($str, 1, 1)) << 8);
 618:     }
 619: }
 620: 
 621: ///////////////////////////////////////////////////////////////////////////////////////////////////
 622: 
 623: class CGIFIMAGE
 624: {
 625:     var $m_disp;
 626:     var $m_bUser;
 627:     var $m_bTrans;
 628:     var $m_nDelay;
 629:     var $m_nTrans;
 630:     var $m_lpComm;
 631:     var $m_gih;
 632:     var $m_data;
 633:     var $m_lzw;
 634: 
 635:     ///////////////////////////////////////////////////////////////////////////
 636: 
 637:     function __construct()
 638:     {
 639:         unSet($this->m_disp);
 640:         unSet($this->m_bUser);
 641:         unSet($this->m_bTrans);
 642:         unSet($this->m_nDelay);
 643:         unSet($this->m_nTrans);
 644:         unSet($this->m_lpComm);
 645:         unSet($this->m_data);
 646:         $this->m_gih = new CGIFIMAGEHEADER();
 647:         $this->m_lzw = new CGIFLZW();
 648:     }
 649: 
 650:     ///////////////////////////////////////////////////////////////////////////
 651: 
 652:     function load($data, &$datLen)
 653:     {
 654:         $datLen = 0;
 655: 
 656:         while (true) {
 657:             $b = ord($data{0});
 658:             $data = substr($data, 1);
 659:             $datLen++;
 660: 
 661:             switch($b) {
 662:             case 0x21: // Extension
 663:                 if (!$this->skipExt($data, $len = 0)) {
 664:                     return false;
 665:                 }
 666:                 $datLen += $len;
 667:                 break;
 668: 
 669:             case 0x2C: // Image
 670:                 // LOAD HEADER & COLOR TABLE
 671:                 if (!$this->m_gih->load($data, $len = 0)) {
 672:                     return false;
 673:                 }
 674:                 $data = substr($data, $len);
 675:                 $datLen += $len;
 676: 
 677:                 // ALLOC BUFFER
 678:                 if (!($this->m_data = $this->m_lzw->deCompress($data, $len = 0))) {
 679:                     return false;
 680:                 }
 681:                 $data = substr($data, $len);
 682:                 $datLen += $len;
 683: 
 684:                 if ($this->m_gih->m_bInterlace) {
 685:                     $this->deInterlace();
 686:                 }
 687:                 return true;
 688: 
 689:             case 0x3B: // EOF
 690:             default:
 691:                 return false;
 692:             }
 693:         }
 694:         return false;
 695:     }
 696: 
 697:     ///////////////////////////////////////////////////////////////////////////
 698: 
 699:     function skipExt(&$data, &$extLen)
 700:     {
 701:         $extLen = 0;
 702: 
 703:         $b = ord($data{0});
 704:         $data = substr($data, 1);
 705:         $extLen++;
 706: 
 707:         switch($b) {
 708:         case 0xF9: // Graphic Control
 709:             $b = ord($data{1});
 710:             $this->m_disp   = ($b & 0x1C) >> 2;
 711:             $this->m_bUser  = ($b & 0x02) ? true : false;
 712:             $this->m_bTrans = ($b & 0x01) ? true : false;
 713:             $this->m_nDelay = $this->w2i(substr($data, 2, 2));
 714:             $this->m_nTrans = ord($data{4});
 715:             break;
 716: 
 717:         case 0xFE: // Comment
 718:             $this->m_lpComm = substr($data, 1, ord($data{0}));
 719:             break;
 720: 
 721:         case 0x01: // Plain text
 722:             break;
 723: 
 724:         case 0xFF: // Application
 725:             break;
 726:         }
 727: 
 728:         // SKIP DEFAULT AS DEFS MAY CHANGE
 729:         $b = ord($data{0});
 730:         $data = substr($data, 1);
 731:         $extLen++;
 732:         while ($b > 0) {
 733:             $data = substr($data, $b);
 734:             $extLen += $b;
 735:             $b    = ord($data{0});
 736:             $data = substr($data, 1);
 737:             $extLen++;
 738:         }
 739:         return true;
 740:     }
 741: 
 742:     ///////////////////////////////////////////////////////////////////////////
 743: 
 744:     function w2i($str)
 745:     {
 746:         return ord(substr($str, 0, 1)) + (ord(substr($str, 1, 1)) << 8);
 747:     }
 748: 
 749:     ///////////////////////////////////////////////////////////////////////////
 750: 
 751:     function deInterlace()
 752:     {
 753:         $data = $this->m_data;
 754:         $s = 0;
 755:         $y = 0;
 756: 
 757:         for ($i = 0; $i < 4; $i++) {
 758:             switch($i) {
 759:             case 0:
 760:                 $s = 8;
 761:                 $y = 0;
 762:                 break;
 763: 
 764:             case 1:
 765:                 $s = 8;
 766:                 $y = 4;
 767:                 break;
 768: 
 769:             case 2:
 770:                 $s = 4;
 771:                 $y = 2;
 772:                 break;
 773: 
 774:             case 3:
 775:                 $s = 2;
 776:                 $y = 1;
 777:                 break;
 778:             }
 779: 
 780:             for (; $y < $this->m_gih->m_nHeight; $y += $s) {
 781:                 $lne = substr($this->m_data, 0, $this->m_gih->m_nWidth);
 782:                 $this->m_data = substr($this->m_data, $this->m_gih->m_nWidth);
 783: 
 784:                 $data =
 785:                     substr($data, 0, $y * $this->m_gih->m_nWidth) .
 786:                     $lne .
 787:                     substr($data, ($y + 1) * $this->m_gih->m_nWidth);
 788:             }
 789:         }
 790: 
 791:         $this->m_data = $data;
 792:     }
 793: }
 794: 
 795: ///////////////////////////////////////////////////////////////////////////////////////////////////
 796: 
 797: class CGIF
 798: {
 799:     var $m_gfh;
 800:     var $m_lpData;
 801:     var $m_img;
 802:     var $m_bLoaded;
 803: 
 804:     ///////////////////////////////////////////////////////////////////////////
 805: 
 806:     // CONSTRUCTOR
 807:     function __construct()
 808:     {
 809:         $this->m_gfh     = new CGIFFILEHEADER();
 810:         $this->m_img     = new CGIFIMAGE();
 811:         $this->m_lpData  = '';
 812:         $this->m_bLoaded = false;
 813:     }
 814: 
 815:     ///////////////////////////////////////////////////////////////////////////
 816: 
 817:     function loadFile($lpszFileName, $iIndex)
 818:     {
 819:         if ($iIndex < 0) {
 820:             return false;
 821:         }
 822: 
 823:         // READ FILE
 824:         if (!($fh = @fopen($lpszFileName, 'rb'))) {
 825:             return false;
 826:         }
 827:         $this->m_lpData = @fread($fh, @filesize($lpszFileName));
 828:         fclose($fh);
 829: 
 830:         // GET FILE HEADER
 831:         if (!$this->m_gfh->load($this->m_lpData, $len = 0)) {
 832:             return false;
 833:         }
 834:         $this->m_lpData = substr($this->m_lpData, $len);
 835: 
 836:         do {
 837:             if (!$this->m_img->load($this->m_lpData, $imgLen = 0)) {
 838:                 return false;
 839:             }
 840:             $this->m_lpData = substr($this->m_lpData, $imgLen);
 841:         }
 842:         while ($iIndex-- > 0);
 843: 
 844:         $this->m_bLoaded = true;
 845:         return true;
 846:     }
 847: 
 848:     ///////////////////////////////////////////////////////////////////////////
 849: 
 850:     function getSize($lpszFileName, &$width, &$height)
 851:     {
 852:         if (!($fh = @fopen($lpszFileName, 'rb'))) {
 853:             return false;
 854:         }
 855:         $data = @fread($fh, @filesize($lpszFileName));
 856:         @fclose($fh);
 857: 
 858:         $gfh = new CGIFFILEHEADER();
 859:         if (!$gfh->load($data, $len = 0)) {
 860:             return false;
 861:         }
 862: 
 863:         $width  = $gfh->m_nWidth;
 864:         $height = $gfh->m_nHeight;
 865:         return true;
 866:     }
 867: 
 868:     ///////////////////////////////////////////////////////////////////////////
 869: 
 870:     function getBmp($bgColor)
 871:     {
 872:         $out = '';
 873: 
 874:         if (!$this->m_bLoaded) {
 875:             return false;
 876:         }
 877: 
 878:         // PREPARE COLOR TABLE (RGBQUADs)
 879:         if ($this->m_img->m_gih->m_bLocalClr) {
 880:             $nColors = $this->m_img->m_gih->m_nTableSize;
 881:             $rgbq    = $this->m_img->m_gih->m_colorTable->toRGBQuad();
 882:             if ($bgColor != -1) {
 883:                 $bgColor = $this->m_img->m_gih->m_colorTable->colorIndex($bgColor);
 884:             }
 885:         } elseif ($this->m_gfh->m_bGlobalClr) {
 886:             $nColors = $this->m_gfh->m_nTableSize;
 887:             $rgbq    = $this->m_gfh->m_colorTable->toRGBQuad();
 888:             if ($bgColor != -1) {
 889:                 $bgColor = $this->m_gfh->m_colorTable->colorIndex($bgColor);
 890:             }
 891:         } else {
 892:             $nColors =  0;
 893:             $rgbq    = '';
 894:             $bgColor = -1;
 895:         }
 896: 
 897:         // PREPARE BITMAP BITS
 898:         $data = $this->m_img->m_data;
 899:         $nPxl = ($this->m_gfh->m_nHeight - 1) * $this->m_gfh->m_nWidth;
 900:         $bmp  = '';
 901:         $nPad = ($this->m_gfh->m_nWidth % 4) ? 4 - ($this->m_gfh->m_nWidth % 4) : 0;
 902:         for ($y = 0; $y < $this->m_gfh->m_nHeight; $y++) {
 903:             for ($x = 0; $x < $this->m_gfh->m_nWidth; $x++, $nPxl++) {
 904:                 if (
 905:                     ($x >= $this->m_img->m_gih->m_nLeft) &&
 906:                     ($y >= $this->m_img->m_gih->m_nTop) &&
 907:                     ($x <  ($this->m_img->m_gih->m_nLeft + $this->m_img->m_gih->m_nWidth)) &&
 908:                     ($y <  ($this->m_img->m_gih->m_nTop  + $this->m_img->m_gih->m_nHeight))) {
 909:                     // PART OF IMAGE
 910:                     if (@$this->m_img->m_bTrans && (ord($data{$nPxl}) == $this->m_img->m_nTrans)) {
 911:                         // TRANSPARENT -> BACKGROUND
 912:                         if ($bgColor == -1) {
 913:                             $bmp .= chr($this->m_gfh->m_nBgColor);
 914:                         } else {
 915:                             $bmp .= chr($bgColor);
 916:                         }
 917:                     } else {
 918:                         $bmp .= $data{$nPxl};
 919:                     }
 920:                 } else {
 921:                     // BACKGROUND
 922:                     if ($bgColor == -1) {
 923:                         $bmp .= chr($this->m_gfh->m_nBgColor);
 924:                     } else {
 925:                         $bmp .= chr($bgColor);
 926:                     }
 927:                 }
 928:             }
 929:             $nPxl -= $this->m_gfh->m_nWidth << 1;
 930: 
 931:             // ADD PADDING
 932:             for ($x = 0; $x < $nPad; $x++) {
 933:                 $bmp .= "\x00";
 934:             }
 935:         }
 936: 
 937:         // BITMAPFILEHEADER
 938:         $out .= 'BM';
 939:         $out .= $this->dword(14 + 40 + ($nColors << 2) + strlen($bmp));
 940:         $out .= "\x00\x00";
 941:         $out .= "\x00\x00";
 942:         $out .= $this->dword(14 + 40 + ($nColors << 2));
 943: 
 944:         // BITMAPINFOHEADER
 945:         $out .= $this->dword(40);
 946:         $out .= $this->dword($this->m_gfh->m_nWidth);
 947:         $out .= $this->dword($this->m_gfh->m_nHeight);
 948:         $out .= "\x01\x00";
 949:         $out .= "\x08\x00";
 950:         $out .= "\x00\x00\x00\x00";
 951:         $out .= "\x00\x00\x00\x00";
 952:         $out .= "\x12\x0B\x00\x00";
 953:         $out .= "\x12\x0B\x00\x00";
 954:         $out .= $this->dword($nColors % 256);
 955:         $out .= "\x00\x00\x00\x00";
 956: 
 957:         // COLOR TABLE
 958:         if ($nColors > 0) {
 959:             $out .= $rgbq;
 960:         }
 961: 
 962:         // DATA
 963:         $out .= $bmp;
 964: 
 965:         return $out;
 966:     }
 967: 
 968:     ///////////////////////////////////////////////////////////////////////////
 969: 
 970:     function getPng($bgColor)
 971:     {
 972:         $out = '';
 973: 
 974:         if (!$this->m_bLoaded) {
 975:             return false;
 976:         }
 977: 
 978:         // PREPARE COLOR TABLE (RGBQUADs)
 979:         if ($this->m_img->m_gih->m_bLocalClr) {
 980:             $nColors = $this->m_img->m_gih->m_nTableSize;
 981:             $pal     = $this->m_img->m_gih->m_colorTable->toString();
 982:             if ($bgColor != -1) {
 983:                 $bgColor = $this->m_img->m_gih->m_colorTable->colorIndex($bgColor);
 984:             }
 985:         } elseif ($this->m_gfh->m_bGlobalClr) {
 986:             $nColors = $this->m_gfh->m_nTableSize;
 987:             $pal     = $this->m_gfh->m_colorTable->toString();
 988:             if ($bgColor != -1) {
 989:                 $bgColor = $this->m_gfh->m_colorTable->colorIndex($bgColor);
 990:             }
 991:         } else {
 992:             $nColors =  0;
 993:             $pal     = '';
 994:             $bgColor = -1;
 995:         }
 996: 
 997:         // PREPARE BITMAP BITS
 998:         $data = $this->m_img->m_data;
 999:         $nPxl = 0;
1000:         $bmp  = '';
1001:         for ($y = 0; $y < $this->m_gfh->m_nHeight; $y++) {
1002:             $bmp .= "\x00";
1003:             for ($x = 0; $x < $this->m_gfh->m_nWidth; $x++, $nPxl++) {
1004:                 if (
1005:                     ($x >= $this->m_img->m_gih->m_nLeft) &&
1006:                     ($y >= $this->m_img->m_gih->m_nTop) &&
1007:                     ($x <  ($this->m_img->m_gih->m_nLeft + $this->m_img->m_gih->m_nWidth)) &&
1008:                     ($y <  ($this->m_img->m_gih->m_nTop  + $this->m_img->m_gih->m_nHeight))) {
1009:                     // PART OF IMAGE
1010:                     $bmp .= $data{$nPxl};
1011:                 } else {
1012:                     // BACKGROUND
1013:                     if ($bgColor == -1) {
1014:                         $bmp .= chr($this->m_gfh->m_nBgColor);
1015:                     } else {
1016:                         $bmp .= chr($bgColor);
1017:                     }
1018:                 }
1019:             }
1020:         }
1021:         $bmp = gzcompress($bmp, 9);
1022: 
1023:         ///////////////////////////////////////////////////////////////////////
1024:         // SIGNATURE
1025:         $out .= "\x89\x50\x4E\x47\x0D\x0A\x1A\x0A";
1026:         ///////////////////////////////////////////////////////////////////////
1027:         // HEADER
1028:         $out .= "\x00\x00\x00\x0D";
1029:         $tmp  = 'IHDR';
1030:         $tmp .= $this->ndword($this->m_gfh->m_nWidth);
1031:         $tmp .= $this->ndword($this->m_gfh->m_nHeight);
1032:         $tmp .= "\x08\x03\x00\x00\x00";
1033:         $out .= $tmp;
1034:         $out .= $this->ndword(crc32($tmp));
1035:         ///////////////////////////////////////////////////////////////////////
1036:         // PALETTE
1037:         if ($nColors > 0) {
1038:             $out .= $this->ndword($nColors * 3);
1039:             $tmp  = 'PLTE';
1040:             $tmp .= $pal;
1041:             $out .= $tmp;
1042:             $out .= $this->ndword(crc32($tmp));
1043:         }
1044:         ///////////////////////////////////////////////////////////////////////
1045:         // TRANSPARENCY
1046:         if (@$this->m_img->m_bTrans && ($nColors > 0)) {
1047:             $out .= $this->ndword($nColors);
1048:             $tmp  = 'tRNS';
1049:             for ($i = 0; $i < $nColors; $i++) {
1050:                 $tmp .= ($i == $this->m_img->m_nTrans) ? "\x00" : "\xFF";
1051:             }
1052:             $out .= $tmp;
1053:             $out .= $this->ndword(crc32($tmp));
1054:         }
1055:         ///////////////////////////////////////////////////////////////////////
1056:         // DATA BITS
1057:         $out .= $this->ndword(strlen($bmp));
1058:         $tmp  = 'IDAT';
1059:         $tmp .= $bmp;
1060:         $out .= $tmp;
1061:         $out .= $this->ndword(crc32($tmp));
1062:         ///////////////////////////////////////////////////////////////////////
1063:         // END OF FILE
1064:         $out .= "\x00\x00\x00\x00IEND\xAE\x42\x60\x82";
1065: 
1066:         return $out;
1067:     }
1068: 
1069:     ///////////////////////////////////////////////////////////////////////////
1070: 
1071:     // Added by James Heinrich <info@silisoftware.com> - January 5, 2003
1072: 
1073:     // Takes raw image data and plots it pixel-by-pixel on a new GD image and returns that
1074:     // It's extremely slow, but the only solution when imagecreatefromstring() fails
1075:     function getGD_PixelPlotterVersion()
1076:     {
1077:         if (!$this->m_bLoaded) {
1078:             return false;
1079:         }
1080: 
1081:         // PREPARE COLOR TABLE (RGBQUADs)
1082:         if ($this->m_img->m_gih->m_bLocalClr) {
1083:             $pal = $this->m_img->m_gih->m_colorTable->toString();
1084:         } elseif ($this->m_gfh->m_bGlobalClr) {
1085:             $pal = $this->m_gfh->m_colorTable->toString();
1086:         } else {
1087:             die('No color table available in getGD_PixelPlotterVersion()');
1088:         }
1089: 
1090:         $PlottingIMG = imagecreate($this->m_gfh->m_nWidth, $this->m_gfh->m_nHeight);
1091:         $NumColorsInPal = floor(strlen($pal) / 3);
1092:         $ThisImageColor = array();
1093:         for ($i = 0; $i < $NumColorsInPal; $i++) {
1094:             $ThisImageColor[$i] = imagecolorallocate(
1095:                                     $PlottingIMG,
1096:                                     ord($pal{(($i * 3) + 0)}),
1097:                                     ord($pal{(($i * 3) + 1)}),
1098:                                     ord($pal{(($i * 3) + 2)}));
1099:         }
1100: 
1101:         // PREPARE BITMAP BITS
1102:         $data = $this->m_img->m_data;
1103:         $nPxl = ($this->m_gfh->m_nHeight - 1) * $this->m_gfh->m_nWidth;
1104:         for ($y = 0; $y < $this->m_gfh->m_nHeight; $y++) {
1105:             if (!phpthumb_functions::FunctionIsDisabled('set_time_limit')) {
1106:                 set_time_limit(30);
1107:             }
1108:             for ($x = 0; $x < $this->m_gfh->m_nWidth; $x++, $nPxl++) {
1109:                 if (
1110:                     ($x >= $this->m_img->m_gih->m_nLeft) &&
1111:                     ($y >= $this->m_img->m_gih->m_nTop) &&
1112:                     ($x <  ($this->m_img->m_gih->m_nLeft + $this->m_img->m_gih->m_nWidth)) &&
1113:                     ($y <  ($this->m_img->m_gih->m_nTop  + $this->m_img->m_gih->m_nHeight))) {
1114:                     // PART OF IMAGE
1115:                     if (@$this->m_img->m_bTrans && (ord($data{$nPxl}) == $this->m_img->m_nTrans)) {
1116:                         imagesetpixel($PlottingIMG, $x, $this->m_gfh->m_nHeight - $y - 1, $ThisImageColor[$this->m_gfh->m_nBgColor]);
1117:                     } else {
1118:                         imagesetpixel($PlottingIMG, $x, $this->m_gfh->m_nHeight - $y - 1, $ThisImageColor[ord($data{$nPxl})]);
1119:                     }
1120:                 } else {
1121:                     // BACKGROUND
1122:                     imagesetpixel($PlottingIMG, $x, $this->m_gfh->m_nHeight - $y - 1, $ThisImageColor[$this->m_gfh->m_nBgColor]);
1123:                 }
1124:             }
1125:             $nPxl -= $this->m_gfh->m_nWidth << 1;
1126: 
1127:         }
1128: 
1129:         return $PlottingIMG;
1130:     }
1131: 
1132:     ///////////////////////////////////////////////////////////////////////////
1133: 
1134:     function dword($val)
1135:     {
1136:         $val = intval($val);
1137:         return chr($val & 0xFF).chr(($val & 0xFF00) >> 8).chr(($val & 0xFF0000) >> 16).chr(($val & 0xFF000000) >> 24);
1138:     }
1139: 
1140:     ///////////////////////////////////////////////////////////////////////////
1141: 
1142:     function ndword($val)
1143:     {
1144:         $val = intval($val);
1145:         return chr(($val & 0xFF000000) >> 24).chr(($val & 0xFF0000) >> 16).chr(($val & 0xFF00) >> 8).chr($val & 0xFF);
1146:     }
1147: 
1148:     ///////////////////////////////////////////////////////////////////////////
1149: 
1150:     function width()
1151:     {
1152:         return $this->m_gfh->m_nWidth;
1153:     }
1154: 
1155:     ///////////////////////////////////////////////////////////////////////////
1156: 
1157:     function height()
1158:     {
1159:         return $this->m_gfh->m_nHeight;
1160:     }
1161: 
1162:     ///////////////////////////////////////////////////////////////////////////
1163: 
1164:     function comment()
1165:     {
1166:         return $this->m_img->m_lpComm;
1167:     }
1168: 
1169:     ///////////////////////////////////////////////////////////////////////////
1170: 
1171:     function loaded()
1172:     {
1173:         return $this->m_bLoaded;
1174:     }
1175: }
1176: 
API documentation generated by ApiGen