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: /**
   4:  * Project:     Smarty: the PHP compiling template engine
   5:  * File:        Smarty.class.php
   6:  *
   7:  * This library is free software; you can redistribute it and/or
   8:  * modify it under the terms of the GNU Lesser General Public
   9:  * License as published by the Free Software Foundation; either
  10:  * version 2.1 of the License, or (at your option) any later version.
  11:  *
  12:  * This library is distributed in the hope that it will be useful,
  13:  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14:  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  15:  * Lesser General Public License for more details.
  16:  *
  17:  * You should have received a copy of the GNU Lesser General Public
  18:  * License along with this library; if not, write to the Free Software
  19:  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  20:  *
  21:  * For questions, help, comments, discussion, etc., please join the
  22:  * Smarty mailing list. Send a blank e-mail to
  23:  * smarty-discussion-subscribe@googlegroups.com
  24:  *
  25:  * @link http://www.smarty.net/
  26:  * @copyright 2001-2005 New Digital Group, Inc.
  27:  * @author Monte Ohrt <monte at ohrt dot com>
  28:  * @author Andrei Zmievski <andrei@php.net>
  29:  * @package Smarty
  30:  * @version 2.6.30
  31:  */
  32: 
  33: /* $Id$ */
  34: 
  35: /**
  36:  * DIR_SEP isn't used anymore, but third party apps might
  37:  */
  38: if(!defined('DIR_SEP')) {
  39:     define('DIR_SEP', DIRECTORY_SEPARATOR);
  40: }
  41: 
  42: /**
  43:  * set SMARTY_DIR to absolute path to Smarty library files.
  44:  * if not defined, include_path will be used. Sets SMARTY_DIR only if user
  45:  * application has not already defined it.
  46:  */
  47: 
  48: if (!defined('SMARTY_DIR')) {
  49:     define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
  50: }
  51: 
  52: if (!defined('SMARTY_CORE_DIR')) {
  53:     define('SMARTY_CORE_DIR', SMARTY_DIR . 'internals' . DIRECTORY_SEPARATOR);
  54: }
  55: 
  56: define('SMARTY_PHP_PASSTHRU',   0);
  57: define('SMARTY_PHP_QUOTE',      1);
  58: define('SMARTY_PHP_REMOVE',     2);
  59: define('SMARTY_PHP_ALLOW',      3);
  60: 
  61: /**
  62:  * @package Smarty
  63:  */
  64: class Smarty
  65: {
  66:     /**#@+
  67:      * Smarty Configuration Section
  68:      */
  69: 
  70:     /**
  71:      * The name of the directory where templates are located.
  72:      *
  73:      * @var string
  74:      */
  75:     var $template_dir    =  'templates';
  76: 
  77:     /**
  78:      * The directory where compiled templates are located.
  79:      *
  80:      * @var string
  81:      */
  82:     var $compile_dir     =  'templates_c';
  83: 
  84:     /**
  85:      * The directory where config files are located.
  86:      *
  87:      * @var string
  88:      */
  89:     var $config_dir      =  'configs';
  90: 
  91:     /**
  92:      * An array of directories searched for plugins.
  93:      *
  94:      * @var array
  95:      */
  96:     var $plugins_dir     =  array('plugins');
  97: 
  98:     /**
  99:      * If debugging is enabled, a debug console window will display
 100:      * when the page loads (make sure your browser allows unrequested
 101:      * popup windows)
 102:      *
 103:      * @var boolean
 104:      */
 105:     var $debugging       =  false;
 106: 
 107:     /**
 108:      * When set, smarty does uses this value as error_reporting-level.
 109:      *
 110:      * @var integer
 111:      */
 112:     var $error_reporting  =  null;
 113: 
 114:     /**
 115:      * This is the path to the debug console template. If not set,
 116:      * the default one will be used.
 117:      *
 118:      * @var string
 119:      */
 120:     var $debug_tpl       =  '';
 121: 
 122:     /**
 123:      * This determines if debugging is enable-able from the browser.
 124:      * <ul>
 125:      *  <li>NONE => no debugging control allowed</li>
 126:      *  <li>URL => enable debugging when SMARTY_DEBUG is found in the URL.</li>
 127:      * </ul>
 128:      * @link http://www.foo.dom/index.php?SMARTY_DEBUG
 129:      * @var string
 130:      */
 131:     var $debugging_ctrl  =  'NONE';
 132: 
 133:     /**
 134:      * This tells Smarty whether to check for recompiling or not. Recompiling
 135:      * does not need to happen unless a template or config file is changed.
 136:      * Typically you enable this during development, and disable for
 137:      * production.
 138:      *
 139:      * @var boolean
 140:      */
 141:     var $compile_check   =  true;
 142: 
 143:     /**
 144:      * This forces templates to compile every time. Useful for development
 145:      * or debugging.
 146:      *
 147:      * @var boolean
 148:      */
 149:     var $force_compile   =  false;
 150: 
 151:     /**
 152:      * This enables template caching.
 153:      * <ul>
 154:      *  <li>0 = no caching</li>
 155:      *  <li>1 = use class cache_lifetime value</li>
 156:      *  <li>2 = use cache_lifetime in cache file</li>
 157:      * </ul>
 158:      * @var integer
 159:      */
 160:     var $caching         =  0;
 161: 
 162:     /**
 163:      * The name of the directory for cache files.
 164:      *
 165:      * @var string
 166:      */
 167:     var $cache_dir       =  'cache';
 168: 
 169:     /**
 170:      * This is the number of seconds cached content will persist.
 171:      * <ul>
 172:      *  <li>0 = always regenerate cache</li>
 173:      *  <li>-1 = never expires</li>
 174:      * </ul>
 175:      *
 176:      * @var integer
 177:      */
 178:     var $cache_lifetime  =  3600;
 179: 
 180:     /**
 181:      * Only used when $caching is enabled. If true, then If-Modified-Since headers
 182:      * are respected with cached content, and appropriate HTTP headers are sent.
 183:      * This way repeated hits to a cached page do not send the entire page to the
 184:      * client every time.
 185:      *
 186:      * @var boolean
 187:      */
 188:     var $cache_modified_check = false;
 189: 
 190:     /**
 191:      * This determines how Smarty handles "<?php ... ?>" tags in templates.
 192:      * possible values:
 193:      * <ul>
 194:      *  <li>SMARTY_PHP_PASSTHRU -> print tags as plain text</li>
 195:      *  <li>SMARTY_PHP_QUOTE    -> escape tags as entities</li>
 196:      *  <li>SMARTY_PHP_REMOVE   -> remove php tags</li>
 197:      *  <li>SMARTY_PHP_ALLOW    -> execute php tags</li>
 198:      * </ul>
 199:      *
 200:      * @var integer
 201:      */
 202:     var $php_handling    =  SMARTY_PHP_PASSTHRU;
 203: 
 204:     /**
 205:      * This enables template security. When enabled, many things are restricted
 206:      * in the templates that normally would go unchecked. This is useful when
 207:      * untrusted parties are editing templates and you want a reasonable level
 208:      * of security. (no direct execution of PHP in templates for example)
 209:      *
 210:      * @var boolean
 211:      */
 212:     var $security       =   false;
 213: 
 214:     /**
 215:      * This is the list of template directories that are considered secure. This
 216:      * is used only if {@link $security} is enabled. One directory per array
 217:      * element.  {@link $template_dir} is in this list implicitly.
 218:      *
 219:      * @var array
 220:      */
 221:     var $secure_dir     =   array();
 222: 
 223:     /**
 224:      * These are the security settings for Smarty. They are used only when
 225:      * {@link $security} is enabled.
 226:      *
 227:      * @var array
 228:      */
 229:     var $security_settings  = array(
 230:                                     'PHP_HANDLING'    => false,
 231:                                     'IF_FUNCS'        => array('array', 'list',
 232:                                                                'isset', 'empty',
 233:                                                                'count', 'sizeof',
 234:                                                                'in_array', 'is_array',
 235:                                                                'true', 'false', 'null'),
 236:                                     'INCLUDE_ANY'     => false,
 237:                                     'PHP_TAGS'        => false,
 238:                                     'MODIFIER_FUNCS'  => array('count'),
 239:                                     'ALLOW_CONSTANTS'  => false,
 240:                                     'ALLOW_SUPER_GLOBALS' => true
 241:                                    );
 242: 
 243:     /**
 244:      * This is an array of directories where trusted php scripts reside.
 245:      * {@link $security} is disabled during their inclusion/execution.
 246:      *
 247:      * @var array
 248:      */
 249:     var $trusted_dir        = array();
 250: 
 251:     /**
 252:      * The left delimiter used for the template tags.
 253:      *
 254:      * @var string
 255:      */
 256:     var $left_delimiter  =  '{';
 257: 
 258:     /**
 259:      * The right delimiter used for the template tags.
 260:      *
 261:      * @var string
 262:      */
 263:     var $right_delimiter =  '}';
 264: 
 265:     /**
 266:      * The order in which request variables are registered, similar to
 267:      * variables_order in php.ini E = Environment, G = GET, P = POST,
 268:      * C = Cookies, S = Server
 269:      *
 270:      * @var string
 271:      */
 272:     var $request_vars_order    = 'EGPCS';
 273: 
 274:     /**
 275:      * Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false)
 276:      * are uses as request-vars or $_*[]-vars. note: if
 277:      * request_use_auto_globals is true, then $request_vars_order has
 278:      * no effect, but the php-ini-value "gpc_order"
 279:      *
 280:      * @var boolean
 281:      */
 282:     var $request_use_auto_globals      = true;
 283: 
 284:     /**
 285:      * Set this if you want different sets of compiled files for the same
 286:      * templates. This is useful for things like different languages.
 287:      * Instead of creating separate sets of templates per language, you
 288:      * set different compile_ids like 'en' and 'de'.
 289:      *
 290:      * @var string
 291:      */
 292:     var $compile_id            = null;
 293: 
 294:     /**
 295:      * This tells Smarty whether or not to use sub dirs in the cache/ and
 296:      * templates_c/ directories. sub directories better organized, but
 297:      * may not work well with PHP safe mode enabled.
 298:      *
 299:      * @var boolean
 300:      *
 301:      */
 302:     var $use_sub_dirs          = false;
 303: 
 304:     /**
 305:      * This is a list of the modifiers to apply to all template variables.
 306:      * Put each modifier in a separate array element in the order you want
 307:      * them applied. example: <code>array('escape:"htmlall"');</code>
 308:      *
 309:      * @var array
 310:      */
 311:     var $default_modifiers        = array();
 312: 
 313:     /**
 314:      * This is the resource type to be used when not specified
 315:      * at the beginning of the resource path. examples:
 316:      * $smarty->display('file:index.tpl');
 317:      * $smarty->display('db:index.tpl');
 318:      * $smarty->display('index.tpl'); // will use default resource type
 319:      * {include file="file:index.tpl"}
 320:      * {include file="db:index.tpl"}
 321:      * {include file="index.tpl"} {* will use default resource type *}
 322:      *
 323:      * @var array
 324:      */
 325:     var $default_resource_type    = 'file';
 326: 
 327:     /**
 328:      * The function used for cache file handling. If not set, built-in caching is used.
 329:      *
 330:      * @var null|string function name
 331:      */
 332:     var $cache_handler_func   = null;
 333: 
 334:     /**
 335:      * This indicates which filters are automatically loaded into Smarty.
 336:      *
 337:      * @var array array of filter names
 338:      */
 339:     var $autoload_filters = array();
 340: 
 341:     /**#@+
 342:      * @var boolean
 343:      */
 344:     /**
 345:      * This tells if config file vars of the same name overwrite each other or not.
 346:      * if disabled, same name variables are accumulated in an array.
 347:      */
 348:     var $config_overwrite = true;
 349: 
 350:     /**
 351:      * This tells whether or not to automatically booleanize config file variables.
 352:      * If enabled, then the strings "on", "true", and "yes" are treated as boolean
 353:      * true, and "off", "false" and "no" are treated as boolean false.
 354:      */
 355:     var $config_booleanize = true;
 356: 
 357:     /**
 358:      * This tells whether hidden sections [.foobar] are readable from the
 359:      * tempalates or not. Normally you would never allow this since that is
 360:      * the point behind hidden sections: the application can access them, but
 361:      * the templates cannot.
 362:      */
 363:     var $config_read_hidden = false;
 364: 
 365:     /**
 366:      * This tells whether or not automatically fix newlines in config files.
 367:      * It basically converts \r (mac) or \r\n (dos) to \n
 368:      */
 369:     var $config_fix_newlines = true;
 370:     /**#@-*/
 371: 
 372:     /**
 373:      * If a template cannot be found, this PHP function will be executed.
 374:      * Useful for creating templates on-the-fly or other special action.
 375:      *
 376:      * @var string function name
 377:      */
 378:     var $default_template_handler_func = '';
 379: 
 380:     /**
 381:      * The file that contains the compiler class. This can a full
 382:      * pathname, or relative to the php_include path.
 383:      *
 384:      * @var string
 385:      */
 386:     var $compiler_file        =    'Smarty_Compiler.class.php';
 387: 
 388:     /**
 389:      * The class used for compiling templates.
 390:      *
 391:      * @var string
 392:      */
 393:     var $compiler_class        =   'Smarty_Compiler';
 394: 
 395:     /**
 396:      * The class used to load config vars.
 397:      *
 398:      * @var string
 399:      */
 400:     var $config_class          =   'Config_File';
 401: 
 402: /**#@+
 403:  * END Smarty Configuration Section
 404:  * There should be no need to touch anything below this line.
 405:  * @access private
 406:  */
 407:     /**
 408:      * where assigned template vars are kept
 409:      *
 410:      * @var array
 411:      */
 412:     var $_tpl_vars             = array();
 413: 
 414:     /**
 415:      * stores run-time $smarty.* vars
 416:      *
 417:      * @var null|array
 418:      */
 419:     var $_smarty_vars          = null;
 420: 
 421:     /**
 422:      * keeps track of sections
 423:      *
 424:      * @var array
 425:      */
 426:     var $_sections             = array();
 427: 
 428:     /**
 429:      * keeps track of foreach blocks
 430:      *
 431:      * @var array
 432:      */
 433:     var $_foreach              = array();
 434: 
 435:     /**
 436:      * keeps track of tag hierarchy
 437:      *
 438:      * @var array
 439:      */
 440:     var $_tag_stack            = array();
 441: 
 442:     /**
 443:      * configuration object
 444:      *
 445:      * @var Config_file
 446:      */
 447:     var $_conf_obj             = null;
 448: 
 449:     /**
 450:      * loaded configuration settings
 451:      *
 452:      * @var array
 453:      */
 454:     var $_config               = array(array('vars'  => array(), 'files' => array()));
 455: 
 456:     /**
 457:      * md5 checksum of the string 'Smarty'
 458:      *
 459:      * @var string
 460:      */
 461:     var $_smarty_md5           = 'f8d698aea36fcbead2b9d5359ffca76f';
 462: 
 463:     /**
 464:      * Smarty version number
 465:      *
 466:      * @var string
 467:      */
 468:     var $_version              = '2.6.30';
 469: 
 470:     /**
 471:      * current template inclusion depth
 472:      *
 473:      * @var integer
 474:      */
 475:     var $_inclusion_depth      = 0;
 476: 
 477:     /**
 478:      * for different compiled templates
 479:      *
 480:      * @var string
 481:      */
 482:     var $_compile_id           = null;
 483: 
 484:     /**
 485:      * text in URL to enable debug mode
 486:      *
 487:      * @var string
 488:      */
 489:     var $_smarty_debug_id      = 'SMARTY_DEBUG';
 490: 
 491:     /**
 492:      * debugging information for debug console
 493:      *
 494:      * @var array
 495:      */
 496:     var $_smarty_debug_info    = array();
 497: 
 498:     /**
 499:      * info that makes up a cache file
 500:      *
 501:      * @var array
 502:      */
 503:     var $_cache_info           = array();
 504: 
 505:     /**
 506:      * default file permissions
 507:      *
 508:      * @var integer
 509:      */
 510:     var $_file_perms           = 0644;
 511: 
 512:     /**
 513:      * default dir permissions
 514:      *
 515:      * @var integer
 516:      */
 517:     var $_dir_perms               = 0771;
 518: 
 519:     /**
 520:      * registered objects
 521:      *
 522:      * @var array
 523:      */
 524:     var $_reg_objects           = array();
 525: 
 526:     /**
 527:      * table keeping track of plugins
 528:      *
 529:      * @var array
 530:      */
 531:     var $_plugins              = array(
 532:                                        'modifier'      => array(),
 533:                                        'function'      => array(),
 534:                                        'block'         => array(),
 535:                                        'compiler'      => array(),
 536:                                        'prefilter'     => array(),
 537:                                        'postfilter'    => array(),
 538:                                        'outputfilter'  => array(),
 539:                                        'resource'      => array(),
 540:                                        'insert'        => array());
 541: 
 542: 
 543:     /**
 544:      * cache serials
 545:      *
 546:      * @var array
 547:      */
 548:     var $_cache_serials = array();
 549: 
 550:     /**
 551:      * name of optional cache include file
 552:      *
 553:      * @var string
 554:      */
 555:     var $_cache_include = null;
 556: 
 557:     /**
 558:      * indicate if the current code is used in a compiled
 559:      * include
 560:      *
 561:      * @var string
 562:      */
 563:     var $_cache_including = false;
 564: 
 565:     /**
 566:      * plugin filepath cache
 567:      *
 568:      * @var array
 569:      */
 570:     var $_filepaths_cache = array();
 571:     /**#@-*/
 572:     /**
 573:      * The class constructor.
 574:      */
 575:     public function __construct()
 576:     {
 577:       $this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME']
 578:                     : @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);
 579:     }
 580: 
 581:     /**
 582:      * assigns values to template variables
 583:      *
 584:      * @param array|string $tpl_var the template variable name(s)
 585:      * @param mixed $value the value to assign
 586:      */
 587:     function assign($tpl_var, $value = null)
 588:     {
 589:         if (is_array($tpl_var)){
 590:             foreach ($tpl_var as $key => $val) {
 591:                 if ($key != '') {
 592:                     $this->_tpl_vars[$key] = $val;
 593:                 }
 594:             }
 595:         } else {
 596:             if ($tpl_var != '')
 597:                 $this->_tpl_vars[$tpl_var] = $value;
 598:         }
 599:     }
 600: 
 601:     /**
 602:      * assigns values to template variables by reference
 603:      *
 604:      * @param string $tpl_var the template variable name
 605:      * @param mixed $value the referenced value to assign
 606:      */
 607:     function assign_by_ref($tpl_var, &$value)
 608:     {
 609:         if ($tpl_var != '')
 610:             $this->_tpl_vars[$tpl_var] = &$value;
 611:     }
 612: 
 613:     /**
 614:      * appends values to template variables
 615:      *
 616:      * @param array|string $tpl_var the template variable name(s)
 617:      * @param mixed $value the value to append
 618:      */
 619:     function append($tpl_var, $value=null, $merge=false)
 620:     {
 621:         if (is_array($tpl_var)) {
 622:             // $tpl_var is an array, ignore $value
 623:             foreach ($tpl_var as $_key => $_val) {
 624:                 if ($_key != '') {
 625:                     if(!@is_array($this->_tpl_vars[$_key])) {
 626:                         settype($this->_tpl_vars[$_key],'array');
 627:                     }
 628:                     if($merge && is_array($_val)) {
 629:                         foreach($_val as $_mkey => $_mval) {
 630:                             $this->_tpl_vars[$_key][$_mkey] = $_mval;
 631:                         }
 632:                     } else {
 633:                         $this->_tpl_vars[$_key][] = $_val;
 634:                     }
 635:                 }
 636:             }
 637:         } else {
 638:             if ($tpl_var != '' && isset($value)) {
 639:                 if(!@is_array($this->_tpl_vars[$tpl_var])) {
 640:                     settype($this->_tpl_vars[$tpl_var],'array');
 641:                 }
 642:                 if($merge && is_array($value)) {
 643:                     foreach($value as $_mkey => $_mval) {
 644:                         $this->_tpl_vars[$tpl_var][$_mkey] = $_mval;
 645:                     }
 646:                 } else {
 647:                     $this->_tpl_vars[$tpl_var][] = $value;
 648:                 }
 649:             }
 650:         }
 651:     }
 652: 
 653:     /**
 654:      * appends values to template variables by reference
 655:      *
 656:      * @param string $tpl_var the template variable name
 657:      * @param mixed $value the referenced value to append
 658:      */
 659:     function append_by_ref($tpl_var, &$value, $merge=false)
 660:     {
 661:         if ($tpl_var != '' && isset($value)) {
 662:             if(!@is_array($this->_tpl_vars[$tpl_var])) {
 663:              settype($this->_tpl_vars[$tpl_var],'array');
 664:             }
 665:             if ($merge && is_array($value)) {
 666:                 foreach($value as $_key => $_val) {
 667:                     $this->_tpl_vars[$tpl_var][$_key] = &$value[$_key];
 668:                 }
 669:             } else {
 670:                 $this->_tpl_vars[$tpl_var][] = &$value;
 671:             }
 672:         }
 673:     }
 674: 
 675: 
 676:     /**
 677:      * clear the given assigned template variable.
 678:      *
 679:      * @param string $tpl_var the template variable to clear
 680:      */
 681:     function clear_assign($tpl_var)
 682:     {
 683:         if (is_array($tpl_var))
 684:             foreach ($tpl_var as $curr_var)
 685:                 unset($this->_tpl_vars[$curr_var]);
 686:         else
 687:             unset($this->_tpl_vars[$tpl_var]);
 688:     }
 689: 
 690: 
 691:     /**
 692:      * Registers custom function to be used in templates
 693:      *
 694:      * @param string $function the name of the template function
 695:      * @param string $function_impl the name of the PHP function to register
 696:      */
 697:     function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null)
 698:     {
 699:         $this->_plugins['function'][$function] =
 700:             array($function_impl, null, null, false, $cacheable, $cache_attrs);
 701: 
 702:     }
 703: 
 704:     /**
 705:      * Unregisters custom function
 706:      *
 707:      * @param string $function name of template function
 708:      */
 709:     function unregister_function($function)
 710:     {
 711:         unset($this->_plugins['function'][$function]);
 712:     }
 713: 
 714:     /**
 715:      * Registers object to be used in templates
 716:      *
 717:      * @param string $object name of template object
 718:      * @param object &$object_impl the referenced PHP object to register
 719:      * @param null|array $allowed list of allowed methods (empty = all)
 720:      * @param boolean $smarty_args smarty argument format, else traditional
 721:      * @param null|array $block_functs list of methods that are block format
 722:      */
 723:     function register_object($object, &$object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
 724:     {
 725:         settype($allowed, 'array');
 726:         settype($smarty_args, 'boolean');
 727:         $this->_reg_objects[$object] =
 728:             array(&$object_impl, $allowed, $smarty_args, $block_methods);
 729:     }
 730: 
 731:     /**
 732:      * Unregisters object
 733:      *
 734:      * @param string $object name of template object
 735:      */
 736:     function unregister_object($object)
 737:     {
 738:         unset($this->_reg_objects[$object]);
 739:     }
 740: 
 741: 
 742:     /**
 743:      * Registers block function to be used in templates
 744:      *
 745:      * @param string $block name of template block
 746:      * @param string $block_impl PHP function to register
 747:      */
 748:     function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null)
 749:     {
 750:         $this->_plugins['block'][$block] =
 751:             array($block_impl, null, null, false, $cacheable, $cache_attrs);
 752:     }
 753: 
 754:     /**
 755:      * Unregisters block function
 756:      *
 757:      * @param string $block name of template function
 758:      */
 759:     function unregister_block($block)
 760:     {
 761:         unset($this->_plugins['block'][$block]);
 762:     }
 763: 
 764:     /**
 765:      * Registers compiler function
 766:      *
 767:      * @param string $function name of template function
 768:      * @param string $function_impl name of PHP function to register
 769:      */
 770:     function register_compiler_function($function, $function_impl, $cacheable=true)
 771:     {
 772:         $this->_plugins['compiler'][$function] =
 773:             array($function_impl, null, null, false, $cacheable);
 774:     }
 775: 
 776:     /**
 777:      * Unregisters compiler function
 778:      *
 779:      * @param string $function name of template function
 780:      */
 781:     function unregister_compiler_function($function)
 782:     {
 783:         unset($this->_plugins['compiler'][$function]);
 784:     }
 785: 
 786:     /**
 787:      * Registers modifier to be used in templates
 788:      *
 789:      * @param string $modifier name of template modifier
 790:      * @param string $modifier_impl name of PHP function to register
 791:      */
 792:     function register_modifier($modifier, $modifier_impl)
 793:     {
 794:         $this->_plugins['modifier'][$modifier] =
 795:             array($modifier_impl, null, null, false);
 796:     }
 797: 
 798:     /**
 799:      * Unregisters modifier
 800:      *
 801:      * @param string $modifier name of template modifier
 802:      */
 803:     function unregister_modifier($modifier)
 804:     {
 805:         unset($this->_plugins['modifier'][$modifier]);
 806:     }
 807: 
 808:     /**
 809:      * Registers a resource to fetch a template
 810:      *
 811:      * @param string $type name of resource
 812:      * @param array $functions array of functions to handle resource
 813:      */
 814:     function register_resource($type, $functions)
 815:     {
 816:         if (count($functions)==4) {
 817:             $this->_plugins['resource'][$type] =
 818:                 array($functions, false);
 819: 
 820:         } elseif (count($functions)==5) {
 821:             $this->_plugins['resource'][$type] =
 822:                 array(array(array(&$functions[0], $functions[1])
 823:                             ,array(&$functions[0], $functions[2])
 824:                             ,array(&$functions[0], $functions[3])
 825:                             ,array(&$functions[0], $functions[4]))
 826:                       ,false);
 827: 
 828:         } else {
 829:             $this->trigger_error("malformed function-list for '$type' in register_resource");
 830: 
 831:         }
 832:     }
 833: 
 834:     /**
 835:      * Unregisters a resource
 836:      *
 837:      * @param string $type name of resource
 838:      */
 839:     function unregister_resource($type)
 840:     {
 841:         unset($this->_plugins['resource'][$type]);
 842:     }
 843: 
 844:     /**
 845:      * Registers a prefilter function to apply
 846:      * to a template before compiling
 847:      *
 848:      * @param callback $function
 849:      */
 850:     function register_prefilter($function)
 851:     {
 852:         $this->_plugins['prefilter'][$this->_get_filter_name($function)]
 853:             = array($function, null, null, false);
 854:     }
 855: 
 856:     /**
 857:      * Unregisters a prefilter function
 858:      *
 859:      * @param callback $function
 860:      */
 861:     function unregister_prefilter($function)
 862:     {
 863:         unset($this->_plugins['prefilter'][$this->_get_filter_name($function)]);
 864:     }
 865: 
 866:     /**
 867:      * Registers a postfilter function to apply
 868:      * to a compiled template after compilation
 869:      *
 870:      * @param callback $function
 871:      */
 872:     function register_postfilter($function)
 873:     {
 874:         $this->_plugins['postfilter'][$this->_get_filter_name($function)]
 875:             = array($function, null, null, false);
 876:     }
 877: 
 878:     /**
 879:      * Unregisters a postfilter function
 880:      *
 881:      * @param callback $function
 882:      */
 883:     function unregister_postfilter($function)
 884:     {
 885:         unset($this->_plugins['postfilter'][$this->_get_filter_name($function)]);
 886:     }
 887: 
 888:     /**
 889:      * Registers an output filter function to apply
 890:      * to a template output
 891:      *
 892:      * @param callback $function
 893:      */
 894:     function register_outputfilter($function)
 895:     {
 896:         $this->_plugins['outputfilter'][$this->_get_filter_name($function)]
 897:             = array($function, null, null, false);
 898:     }
 899: 
 900:     /**
 901:      * Unregisters an outputfilter function
 902:      *
 903:      * @param callback $function
 904:      */
 905:     function unregister_outputfilter($function)
 906:     {
 907:         unset($this->_plugins['outputfilter'][$this->_get_filter_name($function)]);
 908:     }
 909: 
 910:     /**
 911:      * load a filter of specified type and name
 912:      *
 913:      * @param string $type filter type
 914:      * @param string $name filter name
 915:      */
 916:     function load_filter($type, $name)
 917:     {
 918:         switch ($type) {
 919:             case 'output':
 920:                 $_params = array('plugins' => array(array($type . 'filter', $name, null, null, false)));
 921:                 require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
 922:                 smarty_core_load_plugins($_params, $this);
 923:                 break;
 924: 
 925:             case 'pre':
 926:             case 'post':
 927:                 if (!isset($this->_plugins[$type . 'filter'][$name]))
 928:                     $this->_plugins[$type . 'filter'][$name] = false;
 929:                 break;
 930:         }
 931:     }
 932: 
 933:     /**
 934:      * clear cached content for the given template and cache id
 935:      *
 936:      * @param string $tpl_file name of template file
 937:      * @param string $cache_id name of cache_id
 938:      * @param string $compile_id name of compile_id
 939:      * @param string $exp_time expiration time
 940:      * @return boolean
 941:      */
 942:     function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
 943:     {
 944: 
 945:         if (!isset($compile_id))
 946:             $compile_id = $this->compile_id;
 947: 
 948:         if (!isset($tpl_file))
 949:             $compile_id = null;
 950: 
 951:         $_auto_id = $this->_get_auto_id($cache_id, $compile_id);
 952: 
 953:         if (!empty($this->cache_handler_func)) {
 954:             return call_user_func_array($this->cache_handler_func,
 955:                                   array('clear', &$this, &$dummy, $tpl_file, $cache_id, $compile_id, $exp_time));
 956:         } else {
 957:             $_params = array('auto_base' => $this->cache_dir,
 958:                             'auto_source' => $tpl_file,
 959:                             'auto_id' => $_auto_id,
 960:                             'exp_time' => $exp_time);
 961:             require_once(SMARTY_CORE_DIR . 'core.rm_auto.php');
 962:             return smarty_core_rm_auto($_params, $this);
 963:         }
 964: 
 965:     }
 966: 
 967: 
 968:     /**
 969:      * clear the entire contents of cache (all templates)
 970:      *
 971:      * @param string $exp_time expire time
 972:      * @return boolean results of {@link smarty_core_rm_auto()}
 973:      */
 974:     function clear_all_cache($exp_time = null)
 975:     {
 976:         return $this->clear_cache(null, null, null, $exp_time);
 977:     }
 978: 
 979: 
 980:     /**
 981:      * test to see if valid cache exists for this template
 982:      *
 983:      * @param string $tpl_file name of template file
 984:      * @param string $cache_id
 985:      * @param string $compile_id
 986:      * @return string|false results of {@link _read_cache_file()}
 987:      */
 988:     function is_cached($tpl_file, $cache_id = null, $compile_id = null)
 989:     {
 990:         if (!$this->caching)
 991:             return false;
 992: 
 993:         if (!isset($compile_id))
 994:             $compile_id = $this->compile_id;
 995: 
 996:         $_params = array(
 997:             'tpl_file' => $tpl_file,
 998:             'cache_id' => $cache_id,
 999:             'compile_id' => $compile_id
1000:         );
1001:         require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php');
1002:         return smarty_core_read_cache_file($_params, $this);
1003:     }
1004: 
1005: 
1006:     /**
1007:      * clear all the assigned template variables.
1008:      *
1009:      */
1010:     function clear_all_assign()
1011:     {
1012:         $this->_tpl_vars = array();
1013:     }
1014: 
1015:     /**
1016:      * clears compiled version of specified template resource,
1017:      * or all compiled template files if one is not specified.
1018:      * This function is for advanced use only, not normally needed.
1019:      *
1020:      * @param string $tpl_file
1021:      * @param string $compile_id
1022:      * @param string $exp_time
1023:      * @return boolean results of {@link smarty_core_rm_auto()}
1024:      */
1025:     function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
1026:     {
1027:         if (!isset($compile_id)) {
1028:             $compile_id = $this->compile_id;
1029:         }
1030:         $_params = array('auto_base' => $this->compile_dir,
1031:                         'auto_source' => $tpl_file,
1032:                         'auto_id' => $compile_id,
1033:                         'exp_time' => $exp_time,
1034:                         'extensions' => array('.inc', '.php'));
1035:         require_once(SMARTY_CORE_DIR . 'core.rm_auto.php');
1036:         return smarty_core_rm_auto($_params, $this);
1037:     }
1038: 
1039:     /**
1040:      * Checks whether requested template exists.
1041:      *
1042:      * @param string $tpl_file
1043:      * @return boolean
1044:      */
1045:     function template_exists($tpl_file)
1046:     {
1047:         $_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false);
1048:         return $this->_fetch_resource_info($_params);
1049:     }
1050: 
1051:     /**
1052:      * Returns an array containing template variables
1053:      *
1054:      * @param string $name
1055:      * @param string $type
1056:      * @return array
1057:      */
1058:     function &get_template_vars($name=null)
1059:     {
1060:         if(!isset($name)) {
1061:             return $this->_tpl_vars;
1062:         } elseif(isset($this->_tpl_vars[$name])) {
1063:             return $this->_tpl_vars[$name];
1064:         } else {
1065:             // var non-existant, return valid reference
1066:             $_tmp = null;
1067:             return $_tmp;
1068:         }
1069:     }
1070: 
1071:     /**
1072:      * Returns an array containing config variables
1073:      *
1074:      * @param string $name
1075:      * @param string $type
1076:      * @return array
1077:      */
1078:     function &get_config_vars($name=null)
1079:     {
1080:         if(!isset($name) && is_array($this->_config[0])) {
1081:             return $this->_config[0]['vars'];
1082:         } else if(isset($this->_config[0]['vars'][$name])) {
1083:             return $this->_config[0]['vars'][$name];
1084:         } else {
1085:             // var non-existant, return valid reference
1086:             $_tmp = null;
1087:             return $_tmp;
1088:         }
1089:     }
1090: 
1091:     /**
1092:      * trigger Smarty error
1093:      *
1094:      * @param string $error_msg
1095:      * @param integer $error_type
1096:      */
1097:     function trigger_error($error_msg, $error_type = E_USER_WARNING)
1098:     {
1099:         $msg = htmlentities($error_msg);
1100:         trigger_error("Smarty error: $msg", $error_type);
1101:     }
1102: 
1103: 
1104:     /**
1105:      * executes & displays the template results
1106:      *
1107:      * @param string $resource_name
1108:      * @param string $cache_id
1109:      * @param string $compile_id
1110:      */
1111:     function display($resource_name, $cache_id = null, $compile_id = null)
1112:     {
1113:         $this->fetch($resource_name, $cache_id, $compile_id, true);
1114:     }
1115: 
1116:     /**
1117:      * executes & returns or displays the template results
1118:      *
1119:      * @param string $resource_name
1120:      * @param string $cache_id
1121:      * @param string $compile_id
1122:      * @param boolean $display
1123:      */
1124:     function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false)
1125:     {
1126:         static $_cache_info = array();
1127: 
1128:         $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting)
1129:                ? $this->error_reporting : error_reporting() & ~E_NOTICE);
1130: 
1131:         if (!$this->debugging && $this->debugging_ctrl == 'URL') {
1132:             $_query_string = $this->request_use_auto_globals ? $_SERVER['QUERY_STRING'] : $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'];
1133:             if (@strstr($_query_string, $this->_smarty_debug_id)) {
1134:                 if (@strstr($_query_string, $this->_smarty_debug_id . '=on')) {
1135:                     // enable debugging for this browser session
1136:                     @setcookie('SMARTY_DEBUG', true);
1137:                     $this->debugging = true;
1138:                 } elseif (@strstr($_query_string, $this->_smarty_debug_id . '=off')) {
1139:                     // disable debugging for this browser session
1140:                     @setcookie('SMARTY_DEBUG', false);
1141:                     $this->debugging = false;
1142:                 } else {
1143:                     // enable debugging for this page
1144:                     $this->debugging = true;
1145:                 }
1146:             } else {
1147:                 $this->debugging = (bool)($this->request_use_auto_globals ? @$_COOKIE['SMARTY_DEBUG'] : @$GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']);
1148:             }
1149:         }
1150: 
1151:         if ($this->debugging) {
1152:             // capture time for debugging info
1153:             $_params = array();
1154:             require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
1155:             $_debug_start_time = smarty_core_get_microtime($_params, $this);
1156:             $this->_smarty_debug_info[] = array('type'      => 'template',
1157:                                                 'filename'  => $resource_name,
1158:                                                 'depth'     => 0);
1159:             $_included_tpls_idx = count($this->_smarty_debug_info) - 1;
1160:         }
1161: 
1162:         if (!isset($compile_id)) {
1163:             $compile_id = $this->compile_id;
1164:         }
1165: 
1166:         $this->_compile_id = $compile_id;
1167:         $this->_inclusion_depth = 0;
1168: 
1169:         if ($this->caching) {
1170:             // save old cache_info, initialize cache_info
1171:             array_push($_cache_info, $this->_cache_info);
1172:             $this->_cache_info = array();
1173:             $_params = array(
1174:                 'tpl_file' => $resource_name,
1175:                 'cache_id' => $cache_id,
1176:                 'compile_id' => $compile_id,
1177:                 'results' => null
1178:             );
1179:             require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php');
1180:             if (smarty_core_read_cache_file($_params, $this)) {
1181:                 $_smarty_results = $_params['results'];
1182:                 if (!empty($this->_cache_info['insert_tags'])) {
1183:                     $_params = array('plugins' => $this->_cache_info['insert_tags']);
1184:                     require_once(SMARTY_CORE_DIR . 'core.load_plugins.php');
1185:                     smarty_core_load_plugins($_params, $this);
1186:                     $_params = array('results' => $_smarty_results);
1187:                     require_once(SMARTY_CORE_DIR . 'core.process_cached_inserts.php');
1188:                     $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
1189:                 }
1190:                 if (!empty($this->_cache_info['cache_serials'])) {
1191:                     $_params = array('results' => $_smarty_results);
1192:                     require_once(SMARTY_CORE_DIR . 'core.process_compiled_include.php');
1193:                     $_smarty_results = smarty_core_process_compiled_include($_params, $this);
1194:                 }
1195: 
1196: 
1197:                 if ($display) {
1198:                     if ($this->debugging)
1199:                     {
1200:                         // capture time for debugging info
1201:                         $_params = array();
1202:                         require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
1203:                         $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time;
1204:                         require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
1205:                         $_smarty_results .= smarty_core_display_debug_console($_params, $this);
1206:                     }
1207:                     if ($this->cache_modified_check) {
1208:                         $_server_vars = ($this->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
1209:                         $_last_modified_date = @substr($_server_vars['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_server_vars['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
1210:                         $_gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']).' GMT';
1211:                         if (@count($this->_cache_info['insert_tags']) == 0
1212:                             && !$this->_cache_serials
1213:                             && $_gmt_mtime == $_last_modified_date) {
1214:                             if (php_sapi_name()=='cgi')
1215:                                 header('Status: 304 Not Modified');
1216:                             else
1217:                                 header('HTTP/1.1 304 Not Modified');
1218: 
1219:                         } else {
1220:                             header('Last-Modified: '.$_gmt_mtime);
1221:                             echo $_smarty_results;
1222:                         }
1223:                     } else {
1224:                             echo $_smarty_results;
1225:                     }
1226:                     error_reporting($_smarty_old_error_level);
1227:                     // restore initial cache_info
1228:                     $this->_cache_info = array_pop($_cache_info);
1229:                     return true;
1230:                 } else {
1231:                     error_reporting($_smarty_old_error_level);
1232:                     // restore initial cache_info
1233:                     $this->_cache_info = array_pop($_cache_info);
1234:                     return $_smarty_results;
1235:                 }
1236:             } else {
1237:                 $this->_cache_info['template'][$resource_name] = true;
1238:                 if ($this->cache_modified_check && $display) {
1239:                     header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT');
1240:                 }
1241:             }
1242:         }
1243: 
1244:         // load filters that are marked as autoload
1245:         if (count($this->autoload_filters)) {
1246:             foreach ($this->autoload_filters as $_filter_type => $_filters) {
1247:                 foreach ($_filters as $_filter) {
1248:                     $this->load_filter($_filter_type, $_filter);
1249:                 }
1250:             }
1251:         }
1252: 
1253:         $_smarty_compile_path = $this->_get_compile_path($resource_name);
1254: 
1255:         // if we just need to display the results, don't perform output
1256:         // buffering - for speed
1257:         $_cache_including = $this->_cache_including;
1258:         $this->_cache_including = false;
1259:         if ($display && !$this->caching && count($this->_plugins['outputfilter']) == 0) {
1260:             if ($this->_is_compiled($resource_name, $_smarty_compile_path)
1261:                     || $this->_compile_resource($resource_name, $_smarty_compile_path))
1262:             {
1263:                 include($_smarty_compile_path);
1264:             }
1265:         } else {
1266:             ob_start();
1267:             if ($this->_is_compiled($resource_name, $_smarty_compile_path)
1268:                     || $this->_compile_resource($resource_name, $_smarty_compile_path))
1269:             {
1270:                 include($_smarty_compile_path);
1271:             }
1272:             $_smarty_results = ob_get_contents();
1273:             ob_end_clean();
1274: 
1275:             foreach ((array)$this->_plugins['outputfilter'] as $_output_filter) {
1276:                 $_smarty_results = call_user_func_array($_output_filter[0], array($_smarty_results, &$this));
1277:             }
1278:         }
1279: 
1280:         if ($this->caching) {
1281:             $_params = array('tpl_file' => $resource_name,
1282:                         'cache_id' => $cache_id,
1283:                         'compile_id' => $compile_id,
1284:                         'results' => $_smarty_results);
1285:             require_once(SMARTY_CORE_DIR . 'core.write_cache_file.php');
1286:             smarty_core_write_cache_file($_params, $this);
1287:             require_once(SMARTY_CORE_DIR . 'core.process_cached_inserts.php');
1288:             $_smarty_results = smarty_core_process_cached_inserts($_params, $this);
1289: 
1290:             if ($this->_cache_serials) {
1291:                 // strip nocache-tags from output
1292:                 $_smarty_results = preg_replace('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!s'
1293:                                                 ,''
1294:                                                 ,$_smarty_results);
1295:             }
1296:             // restore initial cache_info
1297:             $this->_cache_info = array_pop($_cache_info);
1298:         }
1299:         $this->_cache_including = $_cache_including;
1300: 
1301:         if ($display) {
1302:             if (isset($_smarty_results)) { echo $_smarty_results; }
1303:             if ($this->debugging) {
1304:                 // capture time for debugging info
1305:                 $_params = array();
1306:                 require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
1307:                 $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time);
1308:                 require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php');
1309:                 echo smarty_core_display_debug_console($_params, $this);
1310:             }
1311:             error_reporting($_smarty_old_error_level);
1312:             return;
1313:         } else {
1314:             error_reporting($_smarty_old_error_level);
1315:             if (isset($_smarty_results)) { return $_smarty_results; }
1316:         }
1317:     }
1318: 
1319:     /**
1320:      * load configuration values
1321:      *
1322:      * @param string $file
1323:      * @param string $section
1324:      * @param string $scope
1325:      */
1326:     function config_load($file, $section = null, $scope = 'global')
1327:     {
1328:         require_once($this->_get_plugin_filepath('function', 'config_load'));
1329:         smarty_function_config_load(array('file' => $file, 'section' => $section, 'scope' => $scope), $this);
1330:     }
1331: 
1332:     /**
1333:      * return a reference to a registered object
1334:      *
1335:      * @param string $name
1336:      * @return object
1337:      */
1338:     function &get_registered_object($name) {
1339:         if (!isset($this->_reg_objects[$name]))
1340:         $this->_trigger_fatal_error("'$name' is not a registered object");
1341: 
1342:         if (!is_object($this->_reg_objects[$name][0]))
1343:         $this->_trigger_fatal_error("registered '$name' is not an object");
1344: 
1345:         return $this->_reg_objects[$name][0];
1346:     }
1347: 
1348:     /**
1349:      * clear configuration values
1350:      *
1351:      * @param string $var
1352:      */
1353:     function clear_config($var = null)
1354:     {
1355:         if(!isset($var)) {
1356:             // clear all values
1357:             $this->_config = array(array('vars'  => array(),
1358:                                          'files' => array()));
1359:         } else {
1360:             unset($this->_config[0]['vars'][$var]);
1361:         }
1362:     }
1363: 
1364:     /**
1365:      * get filepath of requested plugin
1366:      *
1367:      * @param string $type
1368:      * @param string $name
1369:      * @return string|false
1370:      */
1371:     function _get_plugin_filepath($type, $name)
1372:     {
1373:         $_params = array('type' => $type, 'name' => $name);
1374:         require_once(SMARTY_CORE_DIR . 'core.assemble_plugin_filepath.php');
1375:         return smarty_core_assemble_plugin_filepath($_params, $this);
1376:     }
1377: 
1378:    /**
1379:      * test if resource needs compiling
1380:      *
1381:      * @param string $resource_name
1382:      * @param string $compile_path
1383:      * @return boolean
1384:      */
1385:     function _is_compiled($resource_name, $compile_path)
1386:     {
1387:         if (!$this->force_compile && file_exists($compile_path)) {
1388:             if (!$this->compile_check) {
1389:                 // no need to check compiled file
1390:                 return true;
1391:             } else {
1392:                 // get file source and timestamp
1393:                 $_params = array('resource_name' => $resource_name, 'get_source'=>false);
1394:                 if (!$this->_fetch_resource_info($_params)) {
1395:                     return false;
1396:                 }
1397:                 if ($_params['resource_timestamp'] <= filemtime($compile_path)) {
1398:                     // template not expired, no recompile
1399:                     return true;
1400:                 } else {
1401:                     // compile template
1402:                     return false;
1403:                 }
1404:             }
1405:         } else {
1406:             // compiled template does not exist, or forced compile
1407:             return false;
1408:         }
1409:     }
1410: 
1411:    /**
1412:      * compile the template
1413:      *
1414:      * @param string $resource_name
1415:      * @param string $compile_path
1416:      * @return boolean
1417:      */
1418:     function _compile_resource($resource_name, $compile_path)
1419:     {
1420: 
1421:         $_params = array('resource_name' => $resource_name);
1422:         if (!$this->_fetch_resource_info($_params)) {
1423:             return false;
1424:         }
1425: 
1426:         $_source_content = $_params['source_content'];
1427:         $_cache_include    = substr($compile_path, 0, -4).'.inc';
1428: 
1429:         if ($this->_compile_source($resource_name, $_source_content, $_compiled_content, $_cache_include)) {
1430:             // if a _cache_serial was set, we also have to write an include-file:
1431:             if ($this->_cache_include_info) {
1432:                 require_once(SMARTY_CORE_DIR . 'core.write_compiled_include.php');
1433:                 smarty_core_write_compiled_include(array_merge($this->_cache_include_info, array('compiled_content'=>$_compiled_content, 'resource_name'=>$resource_name)),  $this);
1434:             }
1435: 
1436:             $_params = array('compile_path'=>$compile_path, 'compiled_content' => $_compiled_content);
1437:             require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php');
1438:             smarty_core_write_compiled_resource($_params, $this);
1439: 
1440:             return true;
1441:         } else {
1442:             return false;
1443:         }
1444: 
1445:     }
1446: 
1447:    /**
1448:      * compile the given source
1449:      *
1450:      * @param string $resource_name
1451:      * @param string $source_content
1452:      * @param string $compiled_content
1453:      * @return boolean
1454:      */
1455:     function _compile_source($resource_name, &$source_content, &$compiled_content, $cache_include_path=null)
1456:     {
1457:         if (file_exists(SMARTY_DIR . $this->compiler_file)) {
1458:             require_once(SMARTY_DIR . $this->compiler_file);
1459:         } else {
1460:             // use include_path
1461:             require_once($this->compiler_file);
1462:         }
1463: 
1464: 
1465:         $smarty_compiler = new $this->compiler_class;
1466: 
1467:         $smarty_compiler->template_dir      = $this->template_dir;
1468:         $smarty_compiler->compile_dir       = $this->compile_dir;
1469:         $smarty_compiler->plugins_dir       = $this->plugins_dir;
1470:         $smarty_compiler->config_dir        = $this->config_dir;
1471:         $smarty_compiler->force_compile     = $this->force_compile;
1472:         $smarty_compiler->caching           = $this->caching;
1473:         $smarty_compiler->php_handling      = $this->php_handling;
1474:         $smarty_compiler->left_delimiter    = $this->left_delimiter;
1475:         $smarty_compiler->right_delimiter   = $this->right_delimiter;
1476:         $smarty_compiler->_version          = $this->_version;
1477:         $smarty_compiler->security          = $this->security;
1478:         $smarty_compiler->secure_dir        = $this->secure_dir;
1479:         $smarty_compiler->security_settings = $this->security_settings;
1480:         $smarty_compiler->trusted_dir       = $this->trusted_dir;
1481:         $smarty_compiler->use_sub_dirs      = $this->use_sub_dirs;
1482:         $smarty_compiler->_reg_objects      = &$this->_reg_objects;
1483:         $smarty_compiler->_plugins          = &$this->_plugins;
1484:         $smarty_compiler->_tpl_vars         = &$this->_tpl_vars;
1485:         $smarty_compiler->default_modifiers = $this->default_modifiers;
1486:         $smarty_compiler->compile_id        = $this->_compile_id;
1487:         $smarty_compiler->_config            = $this->_config;
1488:         $smarty_compiler->request_use_auto_globals  = $this->request_use_auto_globals;
1489: 
1490:         if (isset($cache_include_path) && isset($this->_cache_serials[$cache_include_path])) {
1491:             $smarty_compiler->_cache_serial = $this->_cache_serials[$cache_include_path];
1492:         }
1493:         $smarty_compiler->_cache_include = $cache_include_path;
1494: 
1495: 
1496:         $_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content);
1497: 
1498:         if ($smarty_compiler->_cache_serial) {
1499:             $this->_cache_include_info = array(
1500:                 'cache_serial'=>$smarty_compiler->_cache_serial
1501:                 ,'plugins_code'=>$smarty_compiler->_plugins_code
1502:                 ,'include_file_path' => $cache_include_path);
1503: 
1504:         } else {
1505:             $this->_cache_include_info = null;
1506: 
1507:         }
1508: 
1509:         return $_results;
1510:     }
1511: 
1512:     /**
1513:      * Get the compile path for this resource
1514:      *
1515:      * @param string $resource_name
1516:      * @return string results of {@link _get_auto_filename()}
1517:      */
1518:     function _get_compile_path($resource_name)
1519:     {
1520:         return $this->_get_auto_filename($this->compile_dir, $resource_name,
1521:                                          $this->_compile_id) . '.php';
1522:     }
1523: 
1524:     /**
1525:      * fetch the template info. Gets timestamp, and source
1526:      * if get_source is true
1527:      *
1528:      * sets $source_content to the source of the template, and
1529:      * $resource_timestamp to its time stamp
1530:      * @param string $resource_name
1531:      * @param string $source_content
1532:      * @param integer $resource_timestamp
1533:      * @param boolean $get_source
1534:      * @param boolean $quiet
1535:      * @return boolean
1536:      */
1537: 
1538:     function _fetch_resource_info(&$params)
1539:     {
1540:         if(!isset($params['get_source'])) { $params['get_source'] = true; }
1541:         if(!isset($params['quiet'])) { $params['quiet'] = false; }
1542: 
1543:         $_return = false;
1544:         $_params = array('resource_name' => $params['resource_name']) ;
1545:         if (isset($params['resource_base_path']))
1546:             $_params['resource_base_path'] = $params['resource_base_path'];
1547:         else
1548:             $_params['resource_base_path'] = $this->template_dir;
1549: 
1550:         if ($this->_parse_resource_name($_params)) {
1551:             $_resource_type = $_params['resource_type'];
1552:             $_resource_name = $_params['resource_name'];
1553:             switch ($_resource_type) {
1554:                 case 'file':
1555:                     if ($params['get_source']) {
1556:                         $params['source_content'] = $this->_read_file($_resource_name);
1557:                     }
1558:                     $params['resource_timestamp'] = filemtime($_resource_name);
1559:                     $_return = is_file($_resource_name) && is_readable($_resource_name);
1560:                     break;
1561: 
1562:                 default:
1563:                     // call resource functions to fetch the template source and timestamp
1564:                     if ($params['get_source']) {
1565:                         $_source_return = isset($this->_plugins['resource'][$_resource_type]) &&
1566:                             call_user_func_array($this->_plugins['resource'][$_resource_type][0][0],
1567:                                                  array($_resource_name, &$params['source_content'], &$this));
1568:                     } else {
1569:                         $_source_return = true;
1570:                     }
1571: 
1572:                     $_timestamp_return = isset($this->_plugins['resource'][$_resource_type]) &&
1573:                         call_user_func_array($this->_plugins['resource'][$_resource_type][0][1],
1574:                                              array($_resource_name, &$params['resource_timestamp'], &$this));
1575: 
1576:                     $_return = $_source_return && $_timestamp_return;
1577:                     break;
1578:             }
1579:         }
1580: 
1581:         if (!$_return) {
1582:             // see if we can get a template with the default template handler
1583:             if (!empty($this->default_template_handler_func)) {
1584:                 if (!is_callable($this->default_template_handler_func)) {
1585:                     $this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist.");
1586:                 } else {
1587:                     $_return = call_user_func_array(
1588:                         $this->default_template_handler_func,
1589:                         array($_params['resource_type'], $_params['resource_name'], &$params['source_content'], &$params['resource_timestamp'], &$this));
1590:                 }
1591:             }
1592:         }
1593: 
1594:         if (!$_return) {
1595:             if (!$params['quiet']) {
1596:                 $this->trigger_error('unable to read resource: "' . $params['resource_name'] . '"');
1597:             }
1598:         } else if ($_return && $this->security) {
1599:             require_once(SMARTY_CORE_DIR . 'core.is_secure.php');
1600:             if (!smarty_core_is_secure($_params, $this)) {
1601:                 if (!$params['quiet'])
1602:                     $this->trigger_error('(secure mode) accessing "' . $params['resource_name'] . '" is not allowed');
1603:                 $params['source_content'] = null;
1604:                 $params['resource_timestamp'] = null;
1605:                 return false;
1606:             }
1607:         }
1608:         return $_return;
1609:     }
1610: 
1611: 
1612:     /**
1613:      * parse out the type and name from the resource
1614:      *
1615:      * @param string $resource_base_path
1616:      * @param string $resource_name
1617:      * @param string $resource_type
1618:      * @param string $resource_name
1619:      * @return boolean
1620:      */
1621: 
1622:     function _parse_resource_name(&$params)
1623:     {
1624: 
1625:         // split tpl_path by the first colon
1626:         $_resource_name_parts = explode(':', $params['resource_name'], 2);
1627: 
1628:         if (count($_resource_name_parts) == 1) {
1629:             // no resource type given
1630:             $params['resource_type'] = $this->default_resource_type;
1631:             $params['resource_name'] = $_resource_name_parts[0];
1632:         } else {
1633:             if(strlen($_resource_name_parts[0]) == 1) {
1634:                 // 1 char is not resource type, but part of filepath
1635:                 $params['resource_type'] = $this->default_resource_type;
1636:                 $params['resource_name'] = $params['resource_name'];
1637:             } else {
1638:                 $params['resource_type'] = $_resource_name_parts[0];
1639:                 $params['resource_name'] = $_resource_name_parts[1];
1640:             }
1641:         }
1642: 
1643:         if ($params['resource_type'] == 'file') {
1644:             if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $params['resource_name'])) {
1645:                 // relative pathname to $params['resource_base_path']
1646:                 // use the first directory where the file is found
1647:                 foreach ((array)$params['resource_base_path'] as $_curr_path) {
1648:                     $_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name'];
1649:                     if (file_exists($_fullpath) && is_file($_fullpath)) {
1650:                         $params['resource_name'] = $_fullpath;
1651:                         return true;
1652:                     }
1653:                     // didn't find the file, try include_path
1654:                     $_params = array('file_path' => $_fullpath);
1655:                     require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
1656:                     if(smarty_core_get_include_path($_params, $this)) {
1657:                         $params['resource_name'] = $_params['new_file_path'];
1658:                         return true;
1659:                     }
1660:                 }
1661:                 return false;
1662:             } else {
1663:                 /* absolute path */
1664:                 return file_exists($params['resource_name']);
1665:             }
1666:         } elseif (empty($this->_plugins['resource'][$params['resource_type']])) {
1667:             $_params = array('type' => $params['resource_type']);
1668:             require_once(SMARTY_CORE_DIR . 'core.load_resource_plugin.php');
1669:             smarty_core_load_resource_plugin($_params, $this);
1670:         }
1671: 
1672:         return true;
1673:     }
1674: 
1675: 
1676:     /**
1677:      * Handle modifiers
1678:      *
1679:      * @param string|null $modifier_name
1680:      * @param array|null $map_array
1681:      * @return string result of modifiers
1682:      */
1683:     function _run_mod_handler()
1684:     {
1685:         $_args = func_get_args();
1686:         list($_modifier_name, $_map_array) = array_splice($_args, 0, 2);
1687:         list($_func_name, $_tpl_file, $_tpl_line) =
1688:             $this->_plugins['modifier'][$_modifier_name];
1689: 
1690:         $_var = $_args[0];
1691:         foreach ($_var as $_key => $_val) {
1692:             $_args[0] = $_val;
1693:             $_var[$_key] = call_user_func_array($_func_name, $_args);
1694:         }
1695:         return $_var;
1696:     }
1697: 
1698:     /**
1699:      * Remove starting and ending quotes from the string
1700:      *
1701:      * @param string $string
1702:      * @return string
1703:      */
1704:     function _dequote($string)
1705:     {
1706:         if ((substr($string, 0, 1) == "'" || substr($string, 0, 1) == '"') &&
1707:             substr($string, -1) == substr($string, 0, 1))
1708:             return substr($string, 1, -1);
1709:         else
1710:             return $string;
1711:     }
1712: 
1713: 
1714:     /**
1715:      * read in a file
1716:      *
1717:      * @param string $filename
1718:      * @return string
1719:      */
1720:     function _read_file($filename)
1721:     {
1722:         if ( file_exists($filename) && is_readable($filename) && ($fd = @fopen($filename, 'rb')) ) {
1723:             $contents = '';
1724:             while (!feof($fd)) {
1725:                 $contents .= fread($fd, 8192);
1726:             }
1727:             fclose($fd);
1728:             return $contents;
1729:         } else {
1730:             return false;
1731:         }
1732:     }
1733: 
1734:     /**
1735:      * get a concrete filename for automagically created content
1736:      *
1737:      * @param string $auto_base
1738:      * @param string $auto_source
1739:      * @param string $auto_id
1740:      * @return string
1741:      * @staticvar string|null
1742:      * @staticvar string|null
1743:      */
1744:     function _get_auto_filename($auto_base, $auto_source = null, $auto_id = null)
1745:     {
1746:         $_compile_dir_sep =  $this->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
1747:         $_return = $auto_base . DIRECTORY_SEPARATOR;
1748: 
1749:         if(isset($auto_id)) {
1750:             // make auto_id safe for directory names
1751:             $auto_id = str_replace('%7C',$_compile_dir_sep,(urlencode($auto_id)));
1752:             // split into separate directories
1753:             $_return .= $auto_id . $_compile_dir_sep;
1754:         }
1755: 
1756:         if(isset($auto_source)) {
1757:             // make source name safe for filename
1758:             $_filename = urlencode(basename($auto_source));
1759:             $_crc32 = sprintf('%08X', crc32($auto_source));
1760:             // prepend %% to avoid name conflicts with
1761:             // with $params['auto_id'] names
1762:             $_crc32 = substr($_crc32, 0, 2) . $_compile_dir_sep .
1763:                       substr($_crc32, 0, 3) . $_compile_dir_sep . $_crc32;
1764:             $_return .= '%%' . $_crc32 . '%%' . $_filename;
1765:         }
1766: 
1767:         return $_return;
1768:     }
1769: 
1770:     /**
1771:      * unlink a file, possibly using expiration time
1772:      *
1773:      * @param string $resource
1774:      * @param integer $exp_time
1775:      */
1776:     function _unlink($resource, $exp_time = null)
1777:     {
1778:         if(isset($exp_time)) {
1779:             if(time() - @filemtime($resource) >= $exp_time) {
1780:                 return @unlink($resource);
1781:             }
1782:         } else {
1783:             return @unlink($resource);
1784:         }
1785:     }
1786: 
1787:     /**
1788:      * returns an auto_id for auto-file-functions
1789:      *
1790:      * @param string $cache_id
1791:      * @param string $compile_id
1792:      * @return string|null
1793:      */
1794:     function _get_auto_id($cache_id=null, $compile_id=null) {
1795:     if (isset($cache_id))
1796:         return (isset($compile_id)) ? $cache_id . '|' . $compile_id  : $cache_id;
1797:     elseif(isset($compile_id))
1798:         return $compile_id;
1799:     else
1800:         return null;
1801:     }
1802: 
1803:     /**
1804:      * trigger Smarty plugin error
1805:      *
1806:      * @param string $error_msg
1807:      * @param string $tpl_file
1808:      * @param integer $tpl_line
1809:      * @param string $file
1810:      * @param integer $line
1811:      * @param integer $error_type
1812:      */
1813:     function _trigger_fatal_error($error_msg, $tpl_file = null, $tpl_line = null,
1814:             $file = null, $line = null, $error_type = E_USER_ERROR)
1815:     {
1816:         if(isset($file) && isset($line)) {
1817:             $info = ' ('.basename($file).", line $line)";
1818:         } else {
1819:             $info = '';
1820:         }
1821:         if (isset($tpl_line) && isset($tpl_file)) {
1822:             $this->trigger_error('[in ' . $tpl_file . ' line ' . $tpl_line . "]: $error_msg$info", $error_type);
1823:         } else {
1824:             $this->trigger_error($error_msg . $info, $error_type);
1825:         }
1826:     }
1827: 
1828: 
1829:     /**
1830:      * callback function for preg_replace, to call a non-cacheable block
1831:      * @return string
1832:      */
1833:     function _process_compiled_include_callback($match) {
1834:         $_func = '_smarty_tplfunc_'.$match[2].'_'.$match[3];
1835:         ob_start();
1836:         $_func($this);
1837:         $_ret = ob_get_contents();
1838:         ob_end_clean();
1839:         return $_ret;
1840:     }
1841: 
1842: 
1843:     /**
1844:      * called for included templates
1845:      *
1846:      * @param string $_smarty_include_tpl_file
1847:      * @param string $_smarty_include_vars
1848:      */
1849: 
1850:     // $_smarty_include_tpl_file, $_smarty_include_vars
1851: 
1852:     function _smarty_include($params)
1853:     {
1854:         if ($this->debugging) {
1855:             $_params = array();
1856:             require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
1857:             $debug_start_time = smarty_core_get_microtime($_params, $this);
1858:             $this->_smarty_debug_info[] = array('type'      => 'template',
1859:                                                   'filename'  => $params['smarty_include_tpl_file'],
1860:                                                   'depth'     => ++$this->_inclusion_depth);
1861:             $included_tpls_idx = count($this->_smarty_debug_info) - 1;
1862:         }
1863: 
1864:         $this->_tpl_vars = array_merge($this->_tpl_vars, $params['smarty_include_vars']);
1865: 
1866:         // config vars are treated as local, so push a copy of the
1867:         // current ones onto the front of the stack
1868:         array_unshift($this->_config, $this->_config[0]);
1869: 
1870:         $_smarty_compile_path = $this->_get_compile_path($params['smarty_include_tpl_file']);
1871: 
1872: 
1873:         if ($this->_is_compiled($params['smarty_include_tpl_file'], $_smarty_compile_path)
1874:             || $this->_compile_resource($params['smarty_include_tpl_file'], $_smarty_compile_path))
1875:         {
1876:             include($_smarty_compile_path);
1877:         }
1878: 
1879:         // pop the local vars off the front of the stack
1880:         array_shift($this->_config);
1881: 
1882:         $this->_inclusion_depth--;
1883: 
1884:         if ($this->debugging) {
1885:             // capture time for debugging info
1886:             $_params = array();
1887:             require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
1888:             $this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $debug_start_time;
1889:         }
1890: 
1891:         if ($this->caching) {
1892:             $this->_cache_info['template'][$params['smarty_include_tpl_file']] = true;
1893:         }
1894:     }
1895: 
1896: 
1897:     /**
1898:      * get or set an array of cached attributes for function that is
1899:      * not cacheable
1900:      * @return array
1901:      */
1902:     function &_smarty_cache_attrs($cache_serial, $count) {
1903:         $_cache_attrs =& $this->_cache_info['cache_attrs'][$cache_serial][$count];
1904: 
1905:         if ($this->_cache_including) {
1906:             /* return next set of cache_attrs */
1907:             $_return = current($_cache_attrs);
1908:             next($_cache_attrs);
1909:             return $_return;
1910: 
1911:         } else {
1912:             /* add a reference to a new set of cache_attrs */
1913:             $_cache_attrs[] = array();
1914:             return $_cache_attrs[count($_cache_attrs)-1];
1915: 
1916:         }
1917: 
1918:     }
1919: 
1920: 
1921:     /**
1922:      * wrapper for include() retaining $this
1923:      * @return mixed
1924:      */
1925:     function _include($filename, $once=false, $params=null)
1926:     {
1927:         if ($once) {
1928:             return include_once($filename);
1929:         } else {
1930:             return include($filename);
1931:         }
1932:     }
1933: 
1934: 
1935:     /**
1936:      * wrapper for eval() retaining $this
1937:      * @return mixed
1938:      */
1939:     function _eval($code, $params=null)
1940:     {
1941:         return eval($code);
1942:     }
1943: 
1944:     /**
1945:      * Extracts the filter name from the given callback
1946:      *
1947:      * @param callback $function
1948:      * @return string
1949:      */
1950:     function _get_filter_name($function)
1951:     {
1952:         if (is_array($function)) {
1953:             $_class_name = (is_object($function[0]) ?
1954:                 get_class($function[0]) : $function[0]);
1955:             return $_class_name . '_' . $function[1];
1956:         }
1957:         else {
1958:             return $function;
1959:         }
1960:     }
1961: 
1962:     /**#@-*/
1963: 
1964: }
1965: 
1966: /* vim: set expandtab: */
1967: 
1968: ?>
1969: 
API documentation generated by ApiGen