JOOMLA中国
  • Joomla中国首页
  • 社区
  • 教程
  • 应用市场
  • B计划
Joomla! Framework TM
  • Namespace
  • Class
  • Tree
  • Deprecated

Namespaces

  • Composer
    • Autoload
  • Joomla
    • Application
      • Cli
        • Output
          • Processor
      • Web
    • Data
    • DI
      • Exception
    • Event
    • Filter
    • Input
    • Ldap
    • Registry
      • Format
    • Session
      • Storage
    • String
    • Uri
    • Utilities
  • None
  • PasswordCompat
    • binary
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Yaml
        • Exception
    • Polyfill
      • Util

Classes

  • CallbackFilterIterator
  • ComposerAutoloaderInit205c915b9c7d3e718e7c95793ee67ffe
  • easyparse
  • EasyPeasyICS
  • FOFAutoloaderComponent
  • FOFAutoloaderFof
  • FOFConfigDomainDispatcher
  • FOFConfigDomainTables
  • FOFConfigDomainViews
  • FOFConfigProvider
  • FOFController
  • FOFDatabase
  • FOFDatabaseDriver
  • FOFDatabaseDriverJoomla
  • FOFDatabaseDriverMysql
  • FOFDatabaseDriverMysqli
  • FOFDatabaseDriverOracle
  • FOFDatabaseDriverPdo
  • FOFDatabaseDriverPdomysql
  • FOFDatabaseDriverPostgresql
  • FOFDatabaseDriverSqlazure
  • FOFDatabaseDriverSqlite
  • FOFDatabaseDriverSqlsrv
  • FOFDatabaseFactory
  • FOFDatabaseInstaller
  • FOFDatabaseIterator
  • FOFDatabaseIteratorAzure
  • FOFDatabaseIteratorMysql
  • FOFDatabaseIteratorMysqli
  • FOFDatabaseIteratorOracle
  • FOFDatabaseIteratorPdo
  • FOFDatabaseIteratorPdomysql
  • FOFDatabaseIteratorPostgresql
  • FOFDatabaseIteratorSqlite
  • FOFDatabaseIteratorSqlsrv
  • FOFDatabaseQuery
  • FOFDatabaseQueryElement
  • FOFDatabaseQueryMysql
  • FOFDatabaseQueryMysqli
  • FOFDatabaseQueryOracle
  • FOFDatabaseQueryPdo
  • FOFDatabaseQueryPdomysql
  • FOFDatabaseQueryPostgresql
  • FOFDatabaseQuerySqlazure
  • FOFDatabaseQuerySqlite
  • FOFDatabaseQuerySqlsrv
  • FOFDispatcher
  • FOFDownload
  • FOFDownloadAdapterAbstract
  • FOFDownloadAdapterCurl
  • FOFDownloadAdapterFopen
  • FOFEncryptAes
  • FOFEncryptAesAbstract
  • FOFEncryptAesMcrypt
  • FOFEncryptAesOpenssl
  • FOFEncryptBase32
  • FOFEncryptRandval
  • FOFEncryptTotp
  • FOFForm
  • FOFFormFieldAccesslevel
  • FOFFormFieldActions
  • FOFFormFieldButton
  • FOFFormFieldCachehandler
  • FOFFormFieldCalendar
  • FOFFormFieldCaptcha
  • FOFFormFieldCheckbox
  • FOFFormFieldCheckboxes
  • FOFFormFieldComponents
  • FOFFormFieldEditor
  • FOFFormFieldEmail
  • FOFFormFieldGroupedbutton
  • FOFFormFieldGroupedlist
  • FOFFormFieldHidden
  • FOFFormFieldImage
  • FOFFormFieldImagelist
  • FOFFormFieldInteger
  • FOFFormFieldLanguage
  • FOFFormFieldList
  • FOFFormFieldMedia
  • FOFFormFieldModel
  • FOFFormFieldOrdering
  • FOFFormFieldPassword
  • FOFFormFieldPlugins
  • FOFFormFieldPublished
  • FOFFormFieldRadio
  • FOFFormFieldRelation
  • FOFFormFieldRules
  • FOFFormFieldSelectrow
  • FOFFormFieldSessionhandler
  • FOFFormFieldSpacer
  • FOFFormFieldSql
  • FOFFormFieldTag
  • FOFFormFieldTel
  • FOFFormFieldText
  • FOFFormFieldTextarea
  • FOFFormFieldTimezone
  • FOFFormFieldTitle
  • FOFFormFieldUrl
  • FOFFormFieldUser
  • FOFFormFieldUsergroup
  • FOFFormHeader
  • FOFFormHeaderAccesslevel
  • FOFFormHeaderField
  • FOFFormHeaderFielddate
  • FOFFormHeaderFieldfilterable
  • FOFFormHeaderFieldsearchable
  • FOFFormHeaderFieldselectable
  • FOFFormHeaderFieldsql
  • FOFFormHeaderFilterdate
  • FOFFormHeaderFilterfilterable
  • FOFFormHeaderFiltersearchable
  • FOFFormHeaderFilterselectable
  • FOFFormHeaderFiltersql
  • FOFFormHeaderLanguage
  • FOFFormHeaderModel
  • FOFFormHeaderOrdering
  • FOFFormHeaderPublished
  • FOFFormHeaderRowselect
  • FOFFormHelper
  • FOFHalDocument
  • FOFHalLink
  • FOFHalLinks
  • FOFHalRenderJson
  • FOFInflector
  • FOFInput
  • FOFIntegrationJoomlaFilesystem
  • FOFIntegrationJoomlaPlatform
  • FOFLayoutFile
  • FOFLayoutHelper
  • FOFLess
  • FOFLessFormatterClassic
  • FOFLessFormatterCompressed
  • FOFLessFormatterJoomla
  • FOFLessFormatterLessjs
  • FOFLessParser
  • FOFModel
  • FOFModelBehavior
  • FOFModelBehaviorAccess
  • FOFModelBehaviorEmptynonzero
  • FOFModelBehaviorEnabled
  • FOFModelBehaviorFilters
  • FOFModelBehaviorLanguage
  • FOFModelBehaviorPrivate
  • FOFModelDispatcherBehavior
  • FOFModelField
  • FOFModelFieldBoolean
  • FOFModelFieldDate
  • FOFModelFieldNumber
  • FOFModelFieldText
  • FOFPlatform
  • FOFPlatformFilesystem
  • FOFQueryAbstract
  • FOFRenderAbstract
  • FOFRenderJoomla
  • FOFRenderJoomla3
  • FOFRenderStrapper
  • FOFStringUtils
  • FOFTable
  • FOFTableBehavior
  • FOFTableBehaviorAssets
  • FOFTableBehaviorContenthistory
  • FOFTableBehaviorTags
  • FOFTableDispatcherBehavior
  • FOFTableNested
  • FOFTableRelations
  • FOFTemplateUtils
  • FOFToolbar
  • FOFUtilsArray
  • FOFUtilsCacheCleaner
  • FOFUtilsConfigHelper
  • FOFUtilsFilescheck
  • FOFUtilsIniParser
  • FOFUtilsInstallscript
  • FOFUtilsIp
  • FOFUtilsObject
  • FOFUtilsObservableDispatcher
  • FOFUtilsObservableEvent
  • FOFUtilsPhpfunc
  • FOFUtilsTimer
  • FOFUtilsUpdate
  • FOFUtilsUpdateCollection
  • FOFUtilsUpdateExtension
  • FOFUtilsUpdateJoomla
  • FOFView
  • FOFViewCsv
  • FOFViewForm
  • FOFViewHtml
  • FOFViewJson
  • FOFViewRaw
  • idna_convert
  • JAccess
  • JAccessRule
  • JAccessRules
  • JAccessWrapperAccess
  • JAdapter
  • JAdapterInstance
  • JApplication
  • JApplicationAdministrator
  • JApplicationBase
  • JApplicationCli
  • JApplicationCms
  • JApplicationDaemon
  • JApplicationHelper
  • JApplicationSite
  • JApplicationWeb
  • JApplicationWebRouter
  • JApplicationWebRouterBase
  • JApplicationWebRouterRest
  • JArchive
  • JArchiveBzip2
  • JArchiveGzip
  • JArchiveTar
  • JArchiveWrapperArchive
  • JArchiveZip
  • JArrayHelper
  • JAssociationExtensionHelper
  • JAuthentication
  • JAuthenticationHelper
  • JAuthenticationResponse
  • JBrowser
  • JBuffer
  • JButton
  • JCache
  • JCacheController
  • JCacheControllerCallback
  • JCacheControllerOutput
  • JCacheControllerPage
  • JCacheControllerView
  • JCacheStorage
  • JCacheStorageApc
  • JCacheStorageApcu
  • JCacheStorageCachelite
  • JCacheStorageFile
  • JCacheStorageHelper
  • JCacheStorageMemcache
  • JCacheStorageMemcached
  • JCacheStorageRedis
  • JCacheStorageWincache
  • JCacheStorageXcache
  • JCaptcha
  • JCategories
  • JCategoryNode
  • JClassLoader
  • JCli
  • JClientFtp
  • JClientHelper
  • JClientLdap
  • JClientWrapperHelper
  • JComponentHelper
  • JComponentRecord
  • JComponentRouterBase
  • JComponentRouterLegacy
  • JComponentRouterRulesMenu
  • JComponentRouterRulesNomenu
  • JComponentRouterRulesStandard
  • JComponentRouterView
  • JComponentRouterViewconfiguration
  • JControllerAdmin
  • JControllerBase
  • JControllerForm
  • JControllerLegacy
  • JCrypt
  • JCryptCipher3Des
  • JCryptCipherBlowfish
  • JCryptCipherCrypto
  • JCryptCipherMcrypt
  • JCryptCipherRijndael256
  • JCryptCipherSimple
  • JCryptKey
  • JCryptPasswordSimple
  • JDaemon
  • JDatabase
  • JDatabaseDriver
  • JDatabaseDriverMysql
  • JDatabaseDriverMysqli
  • JDatabaseDriverOracle
  • JDatabaseDriverPdo
  • JDatabaseDriverPdomysql
  • JDatabaseDriverPostgresql
  • JDatabaseDriverSqlazure
  • JDatabaseDriverSqlite
  • JDatabaseDriverSqlsrv
  • JDatabaseExporter
  • JDatabaseExporterMysql
  • JDatabaseExporterMysqli
  • JDatabaseExporterPdomysql
  • JDatabaseExporterPostgresql
  • JDatabaseFactory
  • JDatabaseImporter
  • JDatabaseImporterMysql
  • JDatabaseImporterMysqli
  • JDatabaseImporterPdomysql
  • JDatabaseImporterPostgresql
  • JDatabaseInterface
  • JDatabaseIterator
  • JDatabaseIteratorMysql
  • JDatabaseIteratorMysqli
  • JDatabaseIteratorOracle
  • JDatabaseIteratorPdo
  • JDatabaseIteratorPdomysql
  • JDatabaseIteratorPostgresql
  • JDatabaseIteratorSqlazure
  • JDatabaseIteratorSqlite
  • JDatabaseIteratorSqlsrv
  • JDatabaseMysql
  • JDatabaseMysqli
  • JDatabaseQuery
  • JDatabaseQueryElement
  • JDatabaseQueryLimitable
  • JDatabaseQueryMysql
  • JDatabaseQueryMysqli
  • JDatabaseQueryOracle
  • JDatabaseQueryPdo
  • JDatabaseQueryPdomysql
  • JDatabaseQueryPostgresql
  • JDatabaseQueryPreparable
  • JDatabaseQuerySqlazure
  • JDatabaseQuerySqlite
  • JDatabaseQuerySqlsrv
  • JDatabaseSqlazure
  • JDatabaseSqlsrv
  • JDate
  • JDispatcher
  • JDocument
  • JDocumentError
  • JDocumentFeed
  • JDocumentHtml
  • JDocumentImage
  • JDocumentJson
  • JDocumentOpensearch
  • JDocumentRaw
  • JDocumentRenderer
  • JDocumentRendererAtom
  • JDocumentRendererComponent
  • JDocumentRendererFeedAtom
  • JDocumentRendererFeedRss
  • JDocumentRendererHead
  • JDocumentRendererHtmlComponent
  • JDocumentRendererHtmlHead
  • JDocumentRendererHtmlMessage
  • JDocumentRendererHtmlModule
  • JDocumentRendererHtmlModules
  • JDocumentRendererMessage
  • JDocumentRendererModule
  • JDocumentRendererModules
  • JDocumentRendererRSS
  • JDocumentXml
  • JEditor
  • JError
  • JErrorPage
  • JEvent
  • JEventDispatcher
  • JExtension
  • JFacebook
  • JFacebookAlbum
  • JFacebookCheckin
  • JFacebookComment
  • JFacebookEvent
  • JFacebookGroup
  • JFacebookLink
  • JFacebookNote
  • JFacebookOAuth
  • JFacebookObject
  • JFacebookPhoto
  • JFacebookPost
  • JFacebookStatus
  • JFacebookUser
  • JFacebookVideo
  • JFactory
  • JFeed
  • JFeedEnclosure
  • JFeedEntry
  • JFeedFactory
  • JFeedImage
  • JFeedItem
  • JFeedLink
  • JFeedParser
  • JFeedParserAtom
  • JFeedParserRss
  • JFeedParserRssItunes
  • JFeedParserRssMedia
  • JFeedPerson
  • JFile
  • JFilesystemHelper
  • JFilesystemPatcher
  • JFilesystemWrapperFile
  • JFilesystemWrapperFolder
  • JFilesystemWrapperPath
  • JFilterInput
  • JFilterOutput
  • JFilterWrapperOutput
  • JFolder
  • JForm
  • JFormField
  • JFormFieldAccessLevel
  • JFormFieldAliastag
  • JFormFieldAuthor
  • JFormFieldCacheHandler
  • JFormFieldCalendar
  • JFormFieldCaptcha
  • JFormFieldCategory
  • JFormFieldCheckbox
  • JFormFieldCheckboxes
  • JFormFieldChromeStyle
  • JFormFieldColor
  • JFormFieldCombo
  • JFormFieldComponentlayout
  • JFormFieldComponents
  • JFormFieldContenthistory
  • JFormFieldContentlanguage
  • JFormFieldContenttype
  • JFormFieldDatabaseConnection
  • JFormFieldEditor
  • JFormFieldEMail
  • JFormFieldFile
  • JFormFieldFileList
  • JFormFieldFolderList
  • JFormFieldFrontend_Language
  • JFormFieldGroupedList
  • JFormFieldHeadertag
  • JFormFieldHelpsite
  • JFormFieldHidden
  • JFormFieldImageList
  • JFormFieldInteger
  • JFormFieldLanguage
  • JFormFieldLastvisitDateRange
  • JFormFieldLimitbox
  • JFormFieldList
  • JFormFieldMedia
  • JFormFieldMenu
  • JFormFieldMenuitem
  • JFormFieldMeter
  • JFormFieldModulelayout
  • JFormFieldModuleOrder
  • JFormFieldModulePosition
  • JFormFieldModuletag
  • JFormFieldNote
  • JFormFieldNumber
  • JFormFieldOrdering
  • JFormFieldPassword
  • JFormFieldPlugin_Status
  • JFormFieldPlugins
  • JFormFieldPredefinedList
  • JFormFieldRadio
  • JFormFieldRange
  • JFormFieldRegistrationDateRange
  • JFormFieldRepeatable
  • JFormFieldRules
  • JFormFieldSessionHandler
  • JFormFieldSpacer
  • JFormFieldSQL
  • JFormFieldStatus
  • JFormFieldSubform
  • JFormFieldTag
  • JFormFieldTel
  • JFormFieldTemplatestyle
  • JFormFieldText
  • JFormFieldTextarea
  • JFormFieldTimezone
  • JFormFieldUrl
  • JFormFieldUser
  • JFormFieldUserActive
  • JFormFieldUsergroup
  • JFormFieldUserGroupList
  • JFormFieldUserState
  • JFormHelper
  • JFormRule
  • JFormRuleBoolean
  • JFormRuleCalendar
  • JFormRuleCaptcha
  • JFormRuleColor
  • JFormRuleEmail
  • JFormRuleEquals
  • JFormRuleNotequals
  • JFormRuleNumber
  • JFormRuleOptions
  • JFormRulePassword
  • JFormRuleRules
  • JFormRuleTel
  • JFormRuleUrl
  • JFormRuleUsername
  • JFormWrapperHelper
  • JFTP
  • JGithub
  • JGithubAccount
  • JGithubCommits
  • JGithubForks
  • JGithubHooks
  • JGithubHttp
  • JGithubMeta
  • JGithubMilestones
  • JGithubObject
  • JGithubPackage
  • JGithubPackageActivity
  • JGithubPackageActivityEvents
  • JGithubPackageActivityNotifications
  • JGithubPackageActivityStarring
  • JGithubPackageActivityWatching
  • JGithubPackageAuthorization
  • JGithubPackageData
  • JGithubPackageDataBlobs
  • JGithubPackageDataCommits
  • JGithubPackageDataRefs
  • JGithubPackageDataTags
  • JGithubPackageDataTrees
  • JGithubPackageGists
  • JGithubPackageGistsComments
  • JGithubPackageGitignore
  • JGithubPackageIssues
  • JGithubPackageIssuesAssignees
  • JGithubPackageIssuesComments
  • JGithubPackageIssuesEvents
  • JGithubPackageIssuesLabels
  • JGithubPackageIssuesMilestones
  • JGithubPackageMarkdown
  • JGithubPackageOrgs
  • JGithubPackageOrgsMembers
  • JGithubPackageOrgsTeams
  • JGithubPackagePulls
  • JGithubPackagePullsComments
  • JGithubPackageRepositories
  • JGithubPackageRepositoriesCollaborators
  • JGithubPackageRepositoriesComments
  • JGithubPackageRepositoriesCommits
  • JGithubPackageRepositoriesContents
  • JGithubPackageRepositoriesDownloads
  • JGithubPackageRepositoriesForks
  • JGithubPackageRepositoriesHooks
  • JGithubPackageRepositoriesKeys
  • JGithubPackageRepositoriesMerging
  • JGithubPackageRepositoriesStatistics
  • JGithubPackageRepositoriesStatuses
  • JGithubPackageSearch
  • JGithubPackageUsers
  • JGithubPackageUsersEmails
  • JGithubPackageUsersFollowers
  • JGithubPackageUsersKeys
  • JGithubRefs
  • JGithubStatuses
  • JGoogle
  • JGoogleAuth
  • JGoogleAuthOauth2
  • JGoogleData
  • JGoogleDataAdsense
  • JGoogleDataCalendar
  • JGoogleDataPicasa
  • JGoogleDataPicasaAlbum
  • JGoogleDataPicasaPhoto
  • JGoogleDataPlus
  • JGoogleDataPlusActivities
  • JGoogleDataPlusComments
  • JGoogleDataPlusPeople
  • JGoogleEmbed
  • JGoogleEmbedAnalytics
  • JGoogleEmbedMaps
  • JGrid
  • JHelp
  • JHelper
  • JHelperContent
  • JHelperContenthistory
  • JHelperMedia
  • JHelperRoute
  • JHelperTags
  • JHelperUsergroups
  • JHtml
  • JHtmlAccess
  • JHtmlActionsDropdown
  • JHtmlBatch
  • JHtmlBehavior
  • JHtmlBootstrap
  • JHtmlCategory
  • JHtmlContent
  • JHtmlContentLanguage
  • JHtmlDate
  • JHtmlDebug
  • JHtmlDropdown
  • JHtmlEmail
  • JHtmlForm
  • JHtmlFormbehavior
  • JHtmlGrid
  • JHtmlIcons
  • JHtmlJGrid
  • JHtmlJquery
  • JHtmlLinks
  • JHtmlList
  • JHtmlMenu
  • JHtmlNumber
  • JHtmlRules
  • JHtmlSearchtools
  • JHtmlSelect
  • JHtmlSidebar
  • JHtmlSliders
  • JHtmlSortablelist
  • JHtmlString
  • JHtmlTabs
  • JHtmlTag
  • JHtmlTel
  • JHtmlUser
  • JHttp
  • JHttpFactory
  • JHttpResponse
  • JHttpTransportCurl
  • JHttpTransportSocket
  • JHttpTransportStream
  • JHttpWrapperFactory
  • JImage
  • JImageFilter
  • JImageFilterBackgroundfill
  • JImageFilterBrightness
  • JImageFilterContrast
  • JImageFilterEdgedetect
  • JImageFilterEmboss
  • JImageFilterGrayscale
  • JImageFilterNegate
  • JImageFilterSketchy
  • JImageFilterSmooth
  • JInput
  • JInputCli
  • JInputCookie
  • JInputFiles
  • JInputJSON
  • JInstaller
  • JInstallerAdapter
  • JInstallerAdapterComponent
  • JInstallerAdapterFile
  • JInstallerAdapterLanguage
  • JInstallerAdapterLibrary
  • JInstallerAdapterModule
  • JInstallerAdapterPackage
  • JInstallerAdapterPlugin
  • JInstallerAdapterTemplate
  • JInstallerComponent
  • JInstallerExtension
  • JInstallerFile
  • JInstallerHelper
  • JInstallerLanguage
  • JInstallerLibrary
  • JInstallerManifest
  • JInstallerManifestLibrary
  • JInstallerManifestPackage
  • JInstallerModule
  • JInstallerPackage
  • JInstallerPlugin
  • JInstallerScript
  • JInstallerTemplate
  • JKeychain
  • JLanguage
  • JLanguageAssociations
  • JLanguageHelper
  • JLanguageMultilang
  • JLanguageStemmer
  • JLanguageStemmerPorteren
  • JLanguageTransliterate
  • JLanguageWrapperHelper
  • JLanguageWrapperText
  • JLanguageWrapperTransliterate
  • JLayoutBase
  • JLayoutFile
  • JLayoutHelper
  • JLDAP
  • JLess
  • JLessFormatterJoomla
  • JLibraryHelper
  • JLinkedin
  • JLinkedinCommunications
  • JLinkedinCompanies
  • JLinkedinGroups
  • JLinkedinJobs
  • JLinkedinOauth
  • JLinkedinObject
  • JLinkedinPeople
  • JLinkedinStream
  • JLoader
  • JLog
  • JLogEntry
  • JLogger
  • JLogLogger
  • JLogLoggerCallback
  • JLogLoggerDatabase
  • JLogLoggerEcho
  • JLogLoggerFormattedtext
  • JLogLoggerMessagequeue
  • JLogLoggerSyslog
  • JLogLoggerW3c
  • JMail
  • JMailHelper
  • JMailWrapperHelper
  • JMediawiki
  • JMediawikiCategories
  • JMediawikiHttp
  • JMediawikiImages
  • JMediawikiLinks
  • JMediawikiObject
  • JMediawikiPages
  • JMediawikiSearch
  • JMediawikiSites
  • JMediawikiUsers
  • JMenu
  • JMenuAdministrator
  • JMenuItem
  • JMenuSite
  • JMicrodata
  • JModelAdmin
  • JModelBase
  • JModelDatabase
  • JModelForm
  • JModelItem
  • JModelLegacy
  • JModelList
  • JModuleHelper
  • JNode
  • JOAuth1Client
  • JOAuth2Client
  • JObject
  • JObservable
  • JObserver
  • JObserverMapper
  • JObserverUpdater
  • JObserverWrapperMapper
  • JOpenSearchImage
  • JOpenSearchUrl
  • JOpenstreetmap
  • JOpenstreetmapChangesets
  • JOpenstreetmapElements
  • JOpenstreetmapGps
  • JOpenstreetmapInfo
  • JOpenstreetmapOauth
  • JOpenstreetmapObject
  • JOpenstreetmapUser
  • JPagination
  • JPaginationObject
  • JPath
  • JPathway
  • JPathwaySite
  • JPlatform
  • JPlugin
  • JPluginHelper
  • JProfiler
  • JRequest
  • JResponse
  • JResponseJson
  • JRoute
  • JRouter
  • JRouterAdministrator
  • JRouterSite
  • JRouteWrapperRoute
  • JRule
  • JRules
  • JSchemaChangeitem
  • JSchemaChangeitemMysql
  • JSchemaChangeitemPostgresql
  • JSchemaChangeitemSqlsrv
  • JSchemaChangeset
  • JSearchHelper
  • JSession
  • JSessionHandlerJoomla
  • JSessionHandlerNative
  • JSessionStorage
  • JSessionStorageApc
  • JSessionStorageDatabase
  • JSessionStorageMemcache
  • JSessionStorageMemcached
  • JSessionStorageNone
  • JSessionStorageWincache
  • JSessionStorageXcache
  • JSimplecrypt
  • JSimplepieFactory
  • JStream
  • JStreamString
  • JString
  • JStringController
  • JStringPunycode
  • JStringWrapperNormalise
  • JStringWrapperPunycode
  • JTable
  • JTableAsset
  • JTableCategory
  • JTableContent
  • JTableContenthistory
  • JTableContenttype
  • JTableCorecontent
  • JTableExtension
  • JTableInterface
  • JTableLanguage
  • JTableMenu
  • JTableMenuType
  • JTableModule
  • JTableNested
  • JTableObserver
  • JTableObserverContenthistory
  • JTableObserverTags
  • JTableSession
  • JTableUcm
  • JTableUpdate
  • JTableUpdatesite
  • JTableUser
  • JTableUsergroup
  • JTableViewlevel
  • JText
  • JToolbar
  • JToolbarButton
  • JToolbarButtonConfirm
  • JToolbarButtonCustom
  • JToolbarButtonHelp
  • JToolbarButtonLink
  • JToolbarButtonPopup
  • JToolbarButtonSeparator
  • JToolbarButtonSlider
  • JToolbarButtonStandard
  • JTree
  • JTwitter
  • JTwitterBlock
  • JTwitterDirectmessages
  • JTwitterFavorites
  • JTwitterFriends
  • JTwitterHelp
  • JTwitterLists
  • JTwitterOAuth
  • JTwitterObject
  • JTwitterPlaces
  • JTwitterProfile
  • JTwittersearch
  • JTwitterStatuses
  • JTwitterTrends
  • JTwitterUsers
  • JUcmBase
  • JUcmContent
  • JUcmType
  • JUpdate
  • JUpdateAdapter
  • JUpdater
  • JUpdaterCollection
  • JUpdaterExtension
  • JUri
  • JUser
  • JUserHelper
  • JUserWrapperHelper
  • JUtility
  • JVersion
  • JViewBase
  • JViewCategories
  • JViewCategory
  • JViewCategoryfeed
  • JViewHtml
  • JViewLegacy
  • JWeb
  • JWebClient
  • JXMLElement
  • lessc
  • lessc_formatter_classic
  • lessc_formatter_compressed
  • lessc_formatter_lessjs
  • lessc_parser
  • lessify
  • Net_IDNA_php4
  • nodecounter
  • ntlm_sasl_client_class
  • PHPMailer
  • PHPMailerOAuth
  • PHPMailerOAuthGoogle
  • POP3
  • SimplePie
  • SimplePie_Author
  • SimplePie_Autoloader
  • SimplePie_Cache
  • SimplePie_Cache_DB
  • SimplePie_Cache_File
  • SimplePie_Cache_Memcache
  • SimplePie_Cache_MySQL
  • SimplePie_Caption
  • SimplePie_Category
  • SimplePie_Content_Type_Sniffer
  • SimplePie_Copyright
  • SimplePie_Core
  • SimplePie_Credit
  • SimplePie_Decode_HTML_Entities
  • SimplePie_Enclosure
  • SimplePie_File
  • SimplePie_gzdecode
  • SimplePie_HTTP_Parser
  • SimplePie_IRI
  • SimplePie_Item
  • SimplePie_Locator
  • SimplePie_Misc
  • SimplePie_Net_IPv6
  • SimplePie_Parse_Date
  • SimplePie_Parser
  • SimplePie_Rating
  • SimplePie_Registry
  • SimplePie_Restriction
  • SimplePie_Sanitize
  • SimplePie_Source
  • SimplePie_XML_Declaration_Parser
  • SMTP
  • tagparse
  • TypeError

Interfaces

  • FOFConfigDomainInterface
  • FOFDatabaseInterface
  • FOFDatabaseQueryLimitable
  • FOFDatabaseQueryPreparable
  • FOFDownloadInterface
  • FOFEncryptAesInterface
  • FOFEncryptRandvalinterface
  • FOFFormField
  • FOFHalRenderInterface
  • FOFPlatformFilesystemInterface
  • FOFPlatformInterface
  • JArchiveExtractable
  • JAssociationExtensionInterface
  • JCacheException
  • JComponentRouterInterface
  • JComponentRouterRulesInterface
  • JController
  • JCryptCipher
  • JCryptPassword
  • JFeedParserNamespace
  • JHttpTransport
  • JLayout
  • JModel
  • JObservableInterface
  • JObserverInterface
  • JObserverUpdaterInterface
  • JSessionHandlerInterface
  • JsonSerializable
  • JUcm
  • JView
  • SimplePie_Cache_Base

Exceptions

  • Error
  • JAccessExceptionNotallowed
  • JCacheExceptionConnecting
  • JCacheExceptionUnsupported
  • JComponentExceptionMissing
  • JDatabaseException
  • JDatabaseExceptionConnecting
  • JDatabaseExceptionExecuting
  • JDatabaseExceptionUnsupported
  • JException
  • JSessionExceptionUnsupported
  • LogException
  • phpmailerException
  • SimplePie_Exception

Constants

  • JERROR_CALLBACK_NOT_CALLABLE
  • JERROR_ILLEGAL_MODE
  • JERROR_ILLEGAL_OPTIONS
  • JREQUEST_ALLOWHTML
  • JREQUEST_ALLOWRAW
  • JREQUEST_NOTRIM
  • JROUTER_MODE_RAW
  • JROUTER_MODE_SEF

Functions

  • __autoload
  • array_column
  • boolval
  • composerRequire205c915b9c7d3e718e7c95793ee67ffe
  • gzopen
  • gzseek
  • gztell
  • hash_equals
  • hash_pbkdf2
  • HTMLFilter
  • jexit
  • jimport
  • json_last_error_msg
  • ldap_escape
  • password_get_info
  • password_hash
  • password_needs_rehash
  • password_verify
  • PHPMailerAutoload
  • random_bytes
  • random_int
  • RandomCompat_intval
  • RandomCompat_strlen
  • RandomCompat_substr
  • tln_body2div
  • tln_casenormalize
  • tln_deent
  • tln_defang
  • tln_findnxreg
  • tln_findnxstr
  • tln_fixatts
  • tln_fixstyle
  • tln_fixurl
  • tln_getnxtag
  • tln_sanitize
  • tln_skipspace
  • tln_tagprint
  • tln_unspace
  • utf8_accents_to_ascii
  • utf8_bad_explain
  • utf8_bad_find
  • utf8_bad_findall
  • utf8_bad_identify
  • utf8_bad_replace
  • utf8_bad_strip
  • utf8_byte_position
  • utf8_compliant
  • utf8_from_unicode
  • utf8_ireplace
  • utf8_is_ascii
  • utf8_is_ascii_ctrl
  • utf8_is_valid
  • utf8_is_word_chars
  • utf8_locate_current_chr
  • utf8_locate_next_chr
  • utf8_ltrim
  • utf8_ord
  • utf8_rtrim
  • utf8_specials_pattern
  • utf8_str_pad
  • utf8_str_split
  • utf8_strcasecmp
  • utf8_strcspn
  • utf8_strip_ascii_ctrl
  • utf8_strip_non_ascii
  • utf8_strip_non_ascii_ctrl
  • utf8_strip_specials
  • utf8_stristr
  • utf8_strlen
  • utf8_strpos
  • utf8_strrev
  • utf8_strrpos
  • utf8_strspn
  • utf8_strtolower
  • utf8_strtoupper
  • utf8_substr
  • utf8_substr_replace
  • utf8_to_unicode
  • utf8_trim
  • utf8_ucfirst
  • utf8_ucwords
  • utf8_ucwords_callback
   1 <?php
   2 /**
   3  * @package     Joomla.Platform
   4  * @subpackage  Client
   5  *
   6  * @copyright   Copyright (C) 2005 - 2017 Open Source Matters, Inc. All rights reserved.
   7  * @license     GNU General Public License version 2 or later; see LICENSE
   8  */
   9 
  10 defined('JPATH_PLATFORM') or die;
  11 
  12 /** Error Codes:
  13  * - 30 : Unable to connect to host
  14  * - 31 : Not connected
  15  * - 32 : Unable to send command to server
  16  * - 33 : Bad username
  17  * - 34 : Bad password
  18  * - 35 : Bad response
  19  * - 36 : Passive mode failed
  20  * - 37 : Data transfer error
  21  * - 38 : Local filesystem error
  22  */
  23 
  24 if (!defined('CRLF'))
  25 {
  26     define('CRLF', "\r\n");
  27 }
  28 
  29 if (!defined('FTP_AUTOASCII'))
  30 {
  31     define('FTP_AUTOASCII', -1);
  32 }
  33 
  34 if (!defined('FTP_BINARY'))
  35 {
  36     define('FTP_BINARY', 1);
  37 }
  38 
  39 if (!defined('FTP_ASCII'))
  40 {
  41     define('FTP_ASCII', 0);
  42 }
  43 
  44 if (!defined('FTP_NATIVE'))
  45 {
  46     define('FTP_NATIVE', (function_exists('ftp_connect')) ? 1 : 0);
  47 }
  48 
  49 /**
  50  * FTP client class
  51  *
  52  * @since  12.1
  53  */
  54 class JClientFtp
  55 {
  56     /**
  57      * @var    resource  Socket resource
  58      * @since  12.1
  59      */
  60     protected $_conn = null;
  61 
  62     /**
  63      * @var    resource  Data port connection resource
  64      * @since  12.1
  65      */
  66     protected $_dataconn = null;
  67 
  68     /**
  69      * @var    array  Passive connection information
  70      * @since  12.1
  71      */
  72     protected $_pasv = null;
  73 
  74     /**
  75      * @var    string  Response Message
  76      * @since  12.1
  77      */
  78     protected $_response = null;
  79 
  80     /**
  81      * @var    integer  Timeout limit
  82      * @since  12.1
  83      */
  84     protected $_timeout = 15;
  85 
  86     /**
  87      * @var    integer  Transfer Type
  88      * @since  12.1
  89      */
  90     protected $_type = null;
  91 
  92     /**
  93      * @var    array  Array to hold ascii format file extensions
  94      * @since  12.1
  95      */
  96     protected $_autoAscii = array(
  97         'asp',
  98         'bat',
  99         'c',
 100         'cpp',
 101         'csv',
 102         'h',
 103         'htm',
 104         'html',
 105         'shtml',
 106         'ini',
 107         'inc',
 108         'log',
 109         'php',
 110         'php3',
 111         'pl',
 112         'perl',
 113         'sh',
 114         'sql',
 115         'txt',
 116         'xhtml',
 117         'xml',
 118     );
 119 
 120     /**
 121      * Array to hold native line ending characters
 122      *
 123      * @var    array
 124      * @since  12.1
 125      */
 126     protected $_lineEndings = array('UNIX' => "\n", 'WIN' => "\r\n");
 127 
 128     /**
 129      * @var    array  JClientFtp instances container.
 130      * @since  12.1
 131      */
 132     protected static $instances = array();
 133 
 134     /**
 135      * JClientFtp object constructor
 136      *
 137      * @param   array  $options  Associative array of options to set
 138      *
 139      * @since   12.1
 140      */
 141     public function __construct(array $options = array())
 142     {
 143         // If default transfer type is not set, set it to autoascii detect
 144         if (!isset($options['type']))
 145         {
 146             $options['type'] = FTP_BINARY;
 147         }
 148 
 149         $this->setOptions($options);
 150 
 151         if (FTP_NATIVE)
 152         {
 153             // Import the generic buffer stream handler
 154             jimport('joomla.utilities.buffer');
 155 
 156             // Autoloading fails for JBuffer as the class is used as a stream handler
 157             JLoader::load('JBuffer');
 158         }
 159     }
 160 
 161     /**
 162      * JClientFtp object destructor
 163      *
 164      * Closes an existing connection, if we have one
 165      *
 166      * @since   12.1
 167      */
 168     public function __destruct()
 169     {
 170         if (is_resource($this->_conn))
 171         {
 172             $this->quit();
 173         }
 174     }
 175 
 176     /**
 177      * Returns the global FTP connector object, only creating it
 178      * if it doesn't already exist.
 179      *
 180      * You may optionally specify a username and password in the parameters. If you do so,
 181      * you may not login() again with different credentials using the same object.
 182      * If you do not use this option, you must quit() the current connection when you
 183      * are done, to free it for use by others.
 184      *
 185      * @param   string  $host     Host to connect to
 186      * @param   string  $port     Port to connect to
 187      * @param   array   $options  Array with any of these options: type=>[FTP_AUTOASCII|FTP_ASCII|FTP_BINARY], timeout=>(int)
 188      * @param   string  $user     Username to use for a connection
 189      * @param   string  $pass     Password to use for a connection
 190      *
 191      * @return  JClientFtp        The FTP Client object.
 192      *
 193      * @since   12.1
 194      */
 195     public static function getInstance($host = '127.0.0.1', $port = '21', array $options = array(), $user = null, $pass = null)
 196     {
 197         $signature = $user . ':' . $pass . '@' . $host . ':' . $port;
 198 
 199         // Create a new instance, or set the options of an existing one
 200         if (!isset(static::$instances[$signature]) || !is_object(static::$instances[$signature]))
 201         {
 202             static::$instances[$signature] = new static($options);
 203         }
 204         else
 205         {
 206             static::$instances[$signature]->setOptions($options);
 207         }
 208 
 209         // Connect to the server, and login, if requested
 210         if (!static::$instances[$signature]->isConnected())
 211         {
 212             $return = static::$instances[$signature]->connect($host, $port);
 213 
 214             if ($return && $user !== null && $pass !== null)
 215             {
 216                 static::$instances[$signature]->login($user, $pass);
 217             }
 218         }
 219 
 220         return static::$instances[$signature];
 221     }
 222 
 223     /**
 224      * Set client options
 225      *
 226      * @param   array  $options  Associative array of options to set
 227      *
 228      * @return  boolean  True if successful
 229      *
 230      * @since   12.1
 231      */
 232     public function setOptions(array $options)
 233     {
 234         if (isset($options['type']))
 235         {
 236             $this->_type = $options['type'];
 237         }
 238 
 239         if (isset($options['timeout']))
 240         {
 241             $this->_timeout = $options['timeout'];
 242         }
 243 
 244         return true;
 245     }
 246 
 247     /**
 248      * Method to connect to a FTP server
 249      *
 250      * @param   string  $host  Host to connect to [Default: 127.0.0.1]
 251      * @param   string  $port  Port to connect on [Default: port 21]
 252      *
 253      * @return  boolean  True if successful
 254      *
 255      * @since   12.1
 256      */
 257     public function connect($host = '127.0.0.1', $port = 21)
 258     {
 259         $errno = null;
 260         $err = null;
 261 
 262         // If already connected, return
 263         if (is_resource($this->_conn))
 264         {
 265             return true;
 266         }
 267 
 268         // If native FTP support is enabled let's use it...
 269         if (FTP_NATIVE)
 270         {
 271             $this->_conn = @ftp_connect($host, $port, $this->_timeout);
 272 
 273             if ($this->_conn === false)
 274             {
 275                 JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_NO_CONNECT', $host, $port), JLog::WARNING, 'jerror');
 276 
 277                 return false;
 278             }
 279             // Set the timeout for this connection
 280             ftp_set_option($this->_conn, FTP_TIMEOUT_SEC, $this->_timeout);
 281 
 282             return true;
 283         }
 284 
 285         // Connect to the FTP server.
 286         $this->_conn = @ fsockopen($host, $port, $errno, $err, $this->_timeout);
 287 
 288         if (!$this->_conn)
 289         {
 290             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_NO_CONNECT_SOCKET', $host, $port, $errno, $err), JLog::WARNING, 'jerror');
 291 
 292             return false;
 293         }
 294 
 295         // Set the timeout for this connection
 296         socket_set_timeout($this->_conn, $this->_timeout, 0);
 297 
 298         // Check for welcome response code
 299         if (!$this->_verifyResponse(220))
 300         {
 301             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_BAD_RESPONSE', $this->_response), JLog::WARNING, 'jerror');
 302 
 303             return false;
 304         }
 305 
 306         return true;
 307     }
 308 
 309     /**
 310      * Method to determine if the object is connected to an FTP server
 311      *
 312      * @return  boolean  True if connected
 313      *
 314      * @since   12.1
 315      */
 316     public function isConnected()
 317     {
 318         return is_resource($this->_conn);
 319     }
 320 
 321     /**
 322      * Method to login to a server once connected
 323      *
 324      * @param   string  $user  Username to login to the server
 325      * @param   string  $pass  Password to login to the server
 326      *
 327      * @return  boolean  True if successful
 328      *
 329      * @since   12.1
 330      */
 331     public function login($user = 'anonymous', $pass = 'jftp@joomla.org')
 332     {
 333         // If native FTP support is enabled let's use it...
 334         if (FTP_NATIVE)
 335         {
 336             if (@ftp_login($this->_conn, $user, $pass) === false)
 337             {
 338                 JLog::add('JFtp::login: Unable to login', JLog::WARNING, 'jerror');
 339 
 340                 return false;
 341             }
 342 
 343             return true;
 344         }
 345 
 346         // Send the username
 347         if (!$this->_putCmd('USER ' . $user, array(331, 503)))
 348         {
 349             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_BAD_USERNAME', $this->_response, $user), JLog::WARNING, 'jerror');
 350 
 351             return false;
 352         }
 353 
 354         // If we are already logged in, continue :)
 355         if ($this->_responseCode == 503)
 356         {
 357             return true;
 358         }
 359 
 360         // Send the password
 361         if (!$this->_putCmd('PASS ' . $pass, 230))
 362         {
 363             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_BAD_PASSWORD', $this->_response, str_repeat('*', strlen($pass))), JLog::WARNING, 'jerror');
 364 
 365             return false;
 366         }
 367 
 368         return true;
 369     }
 370 
 371     /**
 372      * Method to quit and close the connection
 373      *
 374      * @return  boolean  True if successful
 375      *
 376      * @since   12.1
 377      */
 378     public function quit()
 379     {
 380         // If native FTP support is enabled lets use it...
 381         if (FTP_NATIVE)
 382         {
 383             @ftp_close($this->_conn);
 384 
 385             return true;
 386         }
 387 
 388         // Logout and close connection
 389         @fwrite($this->_conn, "QUIT\r\n");
 390         @fclose($this->_conn);
 391 
 392         return true;
 393     }
 394 
 395     /**
 396      * Method to retrieve the current working directory on the FTP server
 397      *
 398      * @return  string   Current working directory
 399      *
 400      * @since   12.1
 401      */
 402     public function pwd()
 403     {
 404         // If native FTP support is enabled let's use it...
 405         if (FTP_NATIVE)
 406         {
 407             if (($ret = @ftp_pwd($this->_conn)) === false)
 408             {
 409                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_PWD_BAD_RESPONSE_NATIVE'), JLog::WARNING, 'jerror');
 410 
 411                 return false;
 412             }
 413 
 414             return $ret;
 415         }
 416 
 417         $match = array(null);
 418 
 419         // Send print working directory command and verify success
 420         if (!$this->_putCmd('PWD', 257))
 421         {
 422             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_PWD_BAD_RESPONSE', $this->_response), JLog::WARNING, 'jerror');
 423 
 424             return false;
 425         }
 426 
 427         // Match just the path
 428         preg_match('/"[^"\r\n]*"/', $this->_response, $match);
 429 
 430         // Return the cleaned path
 431         return preg_replace("/\"/", '', $match[0]);
 432     }
 433 
 434     /**
 435      * Method to system string from the FTP server
 436      *
 437      * @return  string   System identifier string
 438      *
 439      * @since   12.1
 440      */
 441     public function syst()
 442     {
 443         // If native FTP support is enabled lets use it...
 444         if (FTP_NATIVE)
 445         {
 446             if (($ret = @ftp_systype($this->_conn)) === false)
 447             {
 448                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_SYST_BAD_RESPONSE_NATIVE'), JLog::WARNING, 'jerror');
 449 
 450                 return false;
 451             }
 452         }
 453         else
 454         {
 455             // Send print working directory command and verify success
 456             if (!$this->_putCmd('SYST', 215))
 457             {
 458                 JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_SYST_BAD_RESPONSE', $this->_response), JLog::WARNING, 'jerror');
 459 
 460                 return false;
 461             }
 462 
 463             $ret = $this->_response;
 464         }
 465 
 466         // Match the system string to an OS
 467         if (strpos(strtoupper($ret), 'MAC') !== false)
 468         {
 469             $ret = 'MAC';
 470         }
 471         elseif (strpos(strtoupper($ret), 'WIN') !== false)
 472         {
 473             $ret = 'WIN';
 474         }
 475         else
 476         {
 477             $ret = 'UNIX';
 478         }
 479 
 480         // Return the os type
 481         return $ret;
 482     }
 483 
 484     /**
 485      * Method to change the current working directory on the FTP server
 486      *
 487      * @param   string  $path  Path to change into on the server
 488      *
 489      * @return  boolean True if successful
 490      *
 491      * @since   12.1
 492      */
 493     public function chdir($path)
 494     {
 495         // If native FTP support is enabled lets use it...
 496         if (FTP_NATIVE)
 497         {
 498             if (@ftp_chdir($this->_conn, $path) === false)
 499             {
 500                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_CHDIR_BAD_RESPONSE_NATIVE'), JLog::WARNING, 'jerror');
 501 
 502                 return false;
 503             }
 504 
 505             return true;
 506         }
 507 
 508         // Send change directory command and verify success
 509         if (!$this->_putCmd('CWD ' . $path, 250))
 510         {
 511             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_CHDIR_BAD_RESPONSE', $this->_response, $path), JLog::WARNING, 'jerror');
 512 
 513             return false;
 514         }
 515 
 516         return true;
 517     }
 518 
 519     /**
 520      * Method to reinitialise the server, ie. need to login again
 521      *
 522      * NOTE: This command not available on all servers
 523      *
 524      * @return  boolean  True if successful
 525      *
 526      * @since   12.1
 527      */
 528     public function reinit()
 529     {
 530         // If native FTP support is enabled let's use it...
 531         if (FTP_NATIVE)
 532         {
 533             if (@ftp_site($this->_conn, 'REIN') === false)
 534             {
 535                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_REINIT_BAD_RESPONSE_NATIVE'), JLog::WARNING, 'jerror');
 536 
 537                 return false;
 538             }
 539 
 540             return true;
 541         }
 542 
 543         // Send reinitialise command to the server
 544         if (!$this->_putCmd('REIN', 220))
 545         {
 546             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_REINIT_BAD_RESPONSE', $this->_response), JLog::WARNING, 'jerror');
 547 
 548             return false;
 549         }
 550 
 551         return true;
 552     }
 553 
 554     /**
 555      * Method to rename a file/folder on the FTP server
 556      *
 557      * @param   string  $from  Path to change file/folder from
 558      * @param   string  $to    Path to change file/folder to
 559      *
 560      * @return  boolean  True if successful
 561      *
 562      * @since   12.1
 563      */
 564     public function rename($from, $to)
 565     {
 566         // If native FTP support is enabled let's use it...
 567         if (FTP_NATIVE)
 568         {
 569             if (@ftp_rename($this->_conn, $from, $to) === false)
 570             {
 571                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_RENAME_BAD_RESPONSE_NATIVE'), JLog::WARNING, 'jerror');
 572 
 573                 return false;
 574             }
 575 
 576             return true;
 577         }
 578 
 579         // Send rename from command to the server
 580         if (!$this->_putCmd('RNFR ' . $from, 350))
 581         {
 582             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_RENAME_BAD_RESPONSE_FROM', $this->_response, $from), JLog::WARNING, 'jerror');
 583 
 584             return false;
 585         }
 586 
 587         // Send rename to command to the server
 588         if (!$this->_putCmd('RNTO ' . $to, 250))
 589         {
 590             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_RENAME_BAD_RESPONSE_TO', $this->_response, $to), JLog::WARNING, 'jerror');
 591 
 592             return false;
 593         }
 594 
 595         return true;
 596     }
 597 
 598     /**
 599      * Method to change mode for a path on the FTP server
 600      *
 601      * @param   string  $path  Path to change mode on
 602      * @param   mixed   $mode  Octal value to change mode to, e.g. '0777', 0777 or 511 (string or integer)
 603      *
 604      * @return  boolean  True if successful
 605      *
 606      * @since   12.1
 607      */
 608     public function chmod($path, $mode)
 609     {
 610         // If no filename is given, we assume the current directory is the target
 611         if ($path == '')
 612         {
 613             $path = '.';
 614         }
 615 
 616         // Convert the mode to a string
 617         if (is_int($mode))
 618         {
 619             $mode = decoct($mode);
 620         }
 621 
 622         // If native FTP support is enabled let's use it...
 623         if (FTP_NATIVE)
 624         {
 625             if (@ftp_site($this->_conn, 'CHMOD ' . $mode . ' ' . $path) === false)
 626             {
 627                 if (!IS_WIN)
 628                 {
 629                     JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_CHMOD_BAD_RESPONSE_NATIVE'), JLog::WARNING, 'jerror');
 630                 }
 631 
 632                 return false;
 633             }
 634 
 635             return true;
 636         }
 637 
 638         // Send change mode command and verify success [must convert mode from octal]
 639         if (!$this->_putCmd('SITE CHMOD ' . $mode . ' ' . $path, array(200, 250)))
 640         {
 641             if (!IS_WIN)
 642             {
 643                 JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_CHMOD_BAD_RESPONSE', $this->_response, $path, $mode), JLog::WARNING, 'jerror');
 644             }
 645 
 646             return false;
 647         }
 648 
 649         return true;
 650     }
 651 
 652     /**
 653      * Method to delete a path [file/folder] on the FTP server
 654      *
 655      * @param   string  $path  Path to delete
 656      *
 657      * @return  boolean  True if successful
 658      *
 659      * @since   12.1
 660      */
 661     public function delete($path)
 662     {
 663         // If native FTP support is enabled let's use it...
 664         if (FTP_NATIVE)
 665         {
 666             if (@ftp_delete($this->_conn, $path) === false)
 667             {
 668                 if (@ftp_rmdir($this->_conn, $path) === false)
 669                 {
 670                     JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_DELETE_BAD_RESPONSE_NATIVE'), JLog::WARNING, 'jerror');
 671 
 672                     return false;
 673                 }
 674             }
 675 
 676             return true;
 677         }
 678 
 679         // Send delete file command and if that doesn't work, try to remove a directory
 680         if (!$this->_putCmd('DELE ' . $path, 250))
 681         {
 682             if (!$this->_putCmd('RMD ' . $path, 250))
 683             {
 684                 JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_DELETE_BAD_RESPONSE', $this->_response, $path), JLog::WARNING, 'jerror');
 685 
 686                 return false;
 687             }
 688         }
 689 
 690         return true;
 691     }
 692 
 693     /**
 694      * Method to create a directory on the FTP server
 695      *
 696      * @param   string  $path  Directory to create
 697      *
 698      * @return  boolean  True if successful
 699      *
 700      * @since   12.1
 701      */
 702     public function mkdir($path)
 703     {
 704         // If native FTP support is enabled let's use it...
 705         if (FTP_NATIVE)
 706         {
 707             if (@ftp_mkdir($this->_conn, $path) === false)
 708             {
 709                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_MKDIR_BAD_RESPONSE_NATIVE'), JLog::WARNING, 'jerror');
 710 
 711                 return false;
 712             }
 713 
 714             return true;
 715         }
 716 
 717         // Send change directory command and verify success
 718         if (!$this->_putCmd('MKD ' . $path, 257))
 719         {
 720             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_MKDIR_BAD_RESPONSE', $this->_response, $path), JLog::WARNING, 'jerror');
 721 
 722             return false;
 723         }
 724 
 725         return true;
 726     }
 727 
 728     /**
 729      * Method to restart data transfer at a given byte
 730      *
 731      * @param   integer  $point  Byte to restart transfer at
 732      *
 733      * @return  boolean  True if successful
 734      *
 735      * @since   12.1
 736      */
 737     public function restart($point)
 738     {
 739         // If native FTP support is enabled let's use it...
 740         if (FTP_NATIVE)
 741         {
 742             if (@ftp_site($this->_conn, 'REST ' . $point) === false)
 743             {
 744                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_RESTART_BAD_RESPONSE_NATIVE'), JLog::WARNING, 'jerror');
 745 
 746                 return false;
 747             }
 748 
 749             return true;
 750         }
 751 
 752         // Send restart command and verify success
 753         if (!$this->_putCmd('REST ' . $point, 350))
 754         {
 755             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_RESTART_BAD_RESPONSE', $this->_response, $point), JLog::WARNING, 'jerror');
 756 
 757             return false;
 758         }
 759 
 760         return true;
 761     }
 762 
 763     /**
 764      * Method to create an empty file on the FTP server
 765      *
 766      * @param   string  $path  Path local file to store on the FTP server
 767      *
 768      * @return  boolean  True if successful
 769      *
 770      * @since   12.1
 771      */
 772     public function create($path)
 773     {
 774         // If native FTP support is enabled let's use it...
 775         if (FTP_NATIVE)
 776         {
 777             // Turn passive mode on
 778             if (@ftp_pasv($this->_conn, true) === false)
 779             {
 780                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_CREATE_BAD_RESPONSE_PASSIVE'), JLog::WARNING, 'jerror');
 781 
 782                 return false;
 783             }
 784 
 785             $buffer = fopen('buffer://tmp', 'r');
 786 
 787             if (@ftp_fput($this->_conn, $path, $buffer, FTP_ASCII) === false)
 788             {
 789                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_CREATE_BAD_RESPONSE_BUFFER'), JLog::WARNING, 'jerror');
 790                 fclose($buffer);
 791 
 792                 return false;
 793             }
 794 
 795             fclose($buffer);
 796 
 797             return true;
 798         }
 799 
 800         // Start passive mode
 801         if (!$this->_passive())
 802         {
 803             JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_CREATE_BAD_RESPONSE_PASSIVE'), JLog::WARNING, 'jerror');
 804 
 805             return false;
 806         }
 807 
 808         if (!$this->_putCmd('STOR ' . $path, array(150, 125)))
 809         {
 810             @ fclose($this->_dataconn);
 811             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_CREATE_BAD_RESPONSE', $this->_response, $path), JLog::WARNING, 'jerror');
 812 
 813             return false;
 814         }
 815 
 816         // To create a zero byte upload close the data port connection
 817         fclose($this->_dataconn);
 818 
 819         if (!$this->_verifyResponse(226))
 820         {
 821             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_CREATE_BAD_RESPONSE_TRANSFER', $this->_response, $path), JLog::WARNING, 'jerror');
 822 
 823             return false;
 824         }
 825 
 826         return true;
 827     }
 828 
 829     /**
 830      * Method to read a file from the FTP server's contents into a buffer
 831      *
 832      * @param   string  $remote   Path to remote file to read on the FTP server
 833      * @param   string  &$buffer  Buffer variable to read file contents into
 834      *
 835      * @return  boolean  True if successful
 836      *
 837      * @since   12.1
 838      */
 839     public function read($remote, &$buffer)
 840     {
 841         // Determine file type
 842         $mode = $this->_findMode($remote);
 843 
 844         // If native FTP support is enabled let's use it...
 845         if (FTP_NATIVE)
 846         {
 847             // Turn passive mode on
 848             if (@ftp_pasv($this->_conn, true) === false)
 849             {
 850                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_READ_BAD_RESPONSE_PASSIVE'), JLog::WARNING, 'jerror');
 851 
 852                 return false;
 853             }
 854 
 855             $tmp = fopen('buffer://tmp', 'br+');
 856 
 857             if (@ftp_fget($this->_conn, $tmp, $remote, $mode) === false)
 858             {
 859                 fclose($tmp);
 860                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_READ_BAD_RESPONSE_BUFFER'), JLog::WARNING, 'jerror');
 861 
 862                 return false;
 863             }
 864             // Read tmp buffer contents
 865             rewind($tmp);
 866             $buffer = '';
 867 
 868             while (!feof($tmp))
 869             {
 870                 $buffer .= fread($tmp, 8192);
 871             }
 872 
 873             fclose($tmp);
 874 
 875             return true;
 876         }
 877 
 878         $this->_mode($mode);
 879 
 880         // Start passive mode
 881         if (!$this->_passive())
 882         {
 883             JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_READ_BAD_RESPONSE_PASSIVE'), JLog::WARNING, 'jerror');
 884 
 885             return false;
 886         }
 887 
 888         if (!$this->_putCmd('RETR ' . $remote, array(150, 125)))
 889         {
 890             @ fclose($this->_dataconn);
 891             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_READ_BAD_RESPONSE', $this->_response, $remote), JLog::WARNING, 'jerror');
 892 
 893             return false;
 894         }
 895 
 896         // Read data from data port connection and add to the buffer
 897         $buffer = '';
 898 
 899         while (!feof($this->_dataconn))
 900         {
 901             $buffer .= fread($this->_dataconn, 4096);
 902         }
 903 
 904         // Close the data port connection
 905         fclose($this->_dataconn);
 906 
 907         // Let's try to cleanup some line endings if it is ascii
 908         if ($mode == FTP_ASCII)
 909         {
 910             $os = 'UNIX';
 911 
 912             if (IS_WIN)
 913             {
 914                 $os = 'WIN';
 915             }
 916 
 917             $buffer = preg_replace('/' . CRLF . '/', $this->_lineEndings[$os], $buffer);
 918         }
 919 
 920         if (!$this->_verifyResponse(226))
 921         {
 922             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_READ_BAD_RESPONSE_TRANSFER', $this->_response, $remote), JLog::WARNING, 'jerror');
 923 
 924             return false;
 925         }
 926 
 927         return true;
 928     }
 929 
 930     /**
 931      * Method to get a file from the FTP server and save it to a local file
 932      *
 933      * @param   string  $local   Local path to save remote file to
 934      * @param   string  $remote  Path to remote file to get on the FTP server
 935      *
 936      * @return  boolean  True if successful
 937      *
 938      * @since   12.1
 939      */
 940     public function get($local, $remote)
 941     {
 942         // Determine file type
 943         $mode = $this->_findMode($remote);
 944 
 945         // If native FTP support is enabled let's use it...
 946         if (FTP_NATIVE)
 947         {
 948             // Turn passive mode on
 949             if (@ftp_pasv($this->_conn, true) === false)
 950             {
 951                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_GET_PASSIVE'), JLog::WARNING, 'jerror');
 952 
 953                 return false;
 954             }
 955 
 956             if (@ftp_get($this->_conn, $local, $remote, $mode) === false)
 957             {
 958                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_GET_BAD_RESPONSE'), JLog::WARNING, 'jerror');
 959 
 960                 return false;
 961             }
 962 
 963             return true;
 964         }
 965 
 966         $this->_mode($mode);
 967 
 968         // Check to see if the local file can be opened for writing
 969         $fp = fopen($local, 'wb');
 970 
 971         if (!$fp)
 972         {
 973             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_GET_WRITING_LOCAL', $local), JLog::WARNING, 'jerror');
 974 
 975             return false;
 976         }
 977 
 978         // Start passive mode
 979         if (!$this->_passive())
 980         {
 981             JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_GET_PASSIVE'), JLog::WARNING, 'jerror');
 982 
 983             return false;
 984         }
 985 
 986         if (!$this->_putCmd('RETR ' . $remote, array(150, 125)))
 987         {
 988             @ fclose($this->_dataconn);
 989             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_GET_BAD_RESPONSE_RETR', $this->_response, $remote), JLog::WARNING, 'jerror');
 990 
 991             return false;
 992         }
 993 
 994         // Read data from data port connection and add to the buffer
 995         while (!feof($this->_dataconn))
 996         {
 997             $buffer = fread($this->_dataconn, 4096);
 998             fwrite($fp, $buffer, 4096);
 999         }
1000 
1001         // Close the data port connection and file pointer
1002         fclose($this->_dataconn);
1003         fclose($fp);
1004 
1005         if (!$this->_verifyResponse(226))
1006         {
1007             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_GET_BAD_RESPONSE_TRANSFER', $this->_response, $remote), JLog::WARNING, 'jerror');
1008 
1009             return false;
1010         }
1011 
1012         return true;
1013     }
1014 
1015     /**
1016      * Method to store a file to the FTP server
1017      *
1018      * @param   string  $local   Path to local file to store on the FTP server
1019      * @param   string  $remote  FTP path to file to create
1020      *
1021      * @return  boolean  True if successful
1022      *
1023      * @since   12.1
1024      */
1025     public function store($local, $remote = null)
1026     {
1027         // If remote file is not given, use the filename of the local file in the current
1028         // working directory.
1029         if ($remote == null)
1030         {
1031             $remote = basename($local);
1032         }
1033 
1034         // Determine file type
1035         $mode = $this->_findMode($remote);
1036 
1037         // If native FTP support is enabled let's use it...
1038         if (FTP_NATIVE)
1039         {
1040             // Turn passive mode on
1041             if (@ftp_pasv($this->_conn, true) === false)
1042             {
1043                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_STORE_PASSIVE'), JLog::WARNING, 'jerror');
1044 
1045                 return false;
1046             }
1047 
1048             if (@ftp_put($this->_conn, $remote, $local, $mode) === false)
1049             {
1050                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_STORE_BAD_RESPONSE'), JLog::WARNING, 'jerror');
1051 
1052                 return false;
1053             }
1054 
1055             return true;
1056         }
1057 
1058         $this->_mode($mode);
1059 
1060         // Check to see if the local file exists and if so open it for reading
1061         if (@ file_exists($local))
1062         {
1063             $fp = fopen($local, 'rb');
1064 
1065             if (!$fp)
1066             {
1067                 JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_STORE_READING_LOCAL', $local), JLog::WARNING, 'jerror');
1068 
1069                 return false;
1070             }
1071         }
1072         else
1073         {
1074             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_STORE_FIND_LOCAL', $local), JLog::WARNING, 'jerror');
1075 
1076             return false;
1077         }
1078 
1079         // Start passive mode
1080         if (!$this->_passive())
1081         {
1082             @ fclose($fp);
1083             JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_STORE_PASSIVE'), JLog::WARNING, 'jerror');
1084 
1085             return false;
1086         }
1087 
1088         // Send store command to the FTP server
1089         if (!$this->_putCmd('STOR ' . $remote, array(150, 125)))
1090         {
1091             @ fclose($fp);
1092             @ fclose($this->_dataconn);
1093             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_STORE_BAD_RESPONSE_STOR', $this->_response, $remote), JLog::WARNING, 'jerror');
1094 
1095             return false;
1096         }
1097 
1098         // Do actual file transfer, read local file and write to data port connection
1099         while (!feof($fp))
1100         {
1101             $line = fread($fp, 4096);
1102 
1103             do
1104             {
1105                 if (($result = @ fwrite($this->_dataconn, $line)) === false)
1106                 {
1107                     JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_STORE_DATA_PORT'), JLog::WARNING, 'jerror');
1108 
1109                     return false;
1110                 }
1111 
1112                 $line = substr($line, $result);
1113             }
1114             while ($line != '');
1115         }
1116 
1117         fclose($fp);
1118         fclose($this->_dataconn);
1119 
1120         if (!$this->_verifyResponse(226))
1121         {
1122             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_STORE_BAD_RESPONSE_TRANSFER', $this->_response, $remote), JLog::WARNING, 'jerror');
1123 
1124             return false;
1125         }
1126 
1127         return true;
1128     }
1129 
1130     /**
1131      * Method to write a string to the FTP server
1132      *
1133      * @param   string  $remote  FTP path to file to write to
1134      * @param   string  $buffer  Contents to write to the FTP server
1135      *
1136      * @return  boolean  True if successful
1137      *
1138      * @since   12.1
1139      */
1140     public function write($remote, $buffer)
1141     {
1142         // Determine file type
1143         $mode = $this->_findMode($remote);
1144 
1145         // If native FTP support is enabled let's use it...
1146         if (FTP_NATIVE)
1147         {
1148             // Turn passive mode on
1149             if (@ftp_pasv($this->_conn, true) === false)
1150             {
1151                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_WRITE_PASSIVE'), JLog::WARNING, 'jerror');
1152 
1153                 return false;
1154             }
1155 
1156             $tmp = fopen('buffer://tmp', 'br+');
1157             fwrite($tmp, $buffer);
1158             rewind($tmp);
1159 
1160             if (@ftp_fput($this->_conn, $remote, $tmp, $mode) === false)
1161             {
1162                 fclose($tmp);
1163                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_WRITE_BAD_RESPONSE'), JLog::WARNING, 'jerror');
1164 
1165                 return false;
1166             }
1167 
1168             fclose($tmp);
1169 
1170             return true;
1171         }
1172 
1173         // First we need to set the transfer mode
1174         $this->_mode($mode);
1175 
1176         // Start passive mode
1177         if (!$this->_passive())
1178         {
1179             JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_WRITE_PASSIVE'), JLog::WARNING, 'jerror');
1180 
1181             return false;
1182         }
1183 
1184         // Send store command to the FTP server
1185         if (!$this->_putCmd('STOR ' . $remote, array(150, 125)))
1186         {
1187             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_WRITE_BAD_RESPONSE_STOR', $this->_response, $remote), JLog::WARNING, 'jerror');
1188             @ fclose($this->_dataconn);
1189 
1190             return false;
1191         }
1192 
1193         // Write buffer to the data connection port
1194         do
1195         {
1196             if (($result = @ fwrite($this->_dataconn, $buffer)) === false)
1197             {
1198                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_WRITE_DATA_PORT'), JLog::WARNING, 'jerror');
1199 
1200                 return false;
1201             }
1202 
1203             $buffer = substr($buffer, $result);
1204         }
1205         while ($buffer != '');
1206 
1207         // Close the data connection port [Data transfer complete]
1208         fclose($this->_dataconn);
1209 
1210         // Verify that the server received the transfer
1211         if (!$this->_verifyResponse(226))
1212         {
1213             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_WRITE_BAD_RESPONSE_TRANSFER', $this->_response, $remote), JLog::WARNING, 'jerror');
1214 
1215             return false;
1216         }
1217 
1218         return true;
1219     }
1220 
1221     /**
1222      * Method to append a string to the FTP server
1223      *
1224      * @param   string  $remote  FTP path to file to append to
1225      * @param   string  $buffer  Contents to append to the FTP server
1226      *
1227      * @return  boolean  True if successful
1228      *
1229      * @since   3.6.0
1230      */
1231     public function append($remote, $buffer)
1232     {
1233         // Determine file type
1234         $mode = $this->_findMode($remote);
1235 
1236         // If native FTP support is enabled let's use it...
1237         if (FTP_NATIVE)
1238         {
1239             // Turn passive mode on
1240             if (@ftp_pasv($this->_conn, true) === false)
1241             {
1242                 throw new RuntimeException(JText::_('JLIB_CLIENT_ERROR_JFTP_APPEND_PASSIVE'), 36);
1243             }
1244 
1245             $tmp = fopen('buffer://tmp', 'bw+');
1246             fwrite($tmp, $buffer);
1247             rewind($tmp);
1248 
1249             $size = $this->size($remote);
1250 
1251             if ($size === false)
1252             {
1253             }
1254 
1255             if (@ftp_fput($this->_conn, $remote, $tmp, $mode, $size) === false)
1256             {
1257                 fclose($tmp);
1258 
1259                 throw new RuntimeException(JText::_('JLIB_CLIENT_ERROR_JFTP_APPEND_BAD_RESPONSE'), 35);
1260             }
1261 
1262             fclose($tmp);
1263 
1264             return true;
1265         }
1266 
1267         // First we need to set the transfer mode
1268         $this->_mode($mode);
1269 
1270         // Start passive mode
1271         if (!$this->_passive())
1272         {
1273             throw new RuntimeException(JText::_('JLIB_CLIENT_ERROR_JFTP_APPEND_PASSIVE'), 36);
1274         }
1275 
1276         // Send store command to the FTP server
1277         if (!$this->_putCmd('APPE ' . $remote, array(150, 125)))
1278         {
1279             @fclose($this->_dataconn);
1280 
1281             throw new RuntimeException(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_APPEND_BAD_RESPONSE_APPE', $this->_response, $remote), 35);
1282         }
1283 
1284         // Write buffer to the data connection port
1285         do
1286         {
1287             if (($result = @ fwrite($this->_dataconn, $buffer)) === false)
1288             {
1289                 throw new RuntimeException(JText::_('JLIB_CLIENT_ERROR_JFTP_APPEND_DATA_PORT'), 37);
1290             }
1291 
1292             $buffer = substr($buffer, $result);
1293         }
1294         while ($buffer != '');
1295 
1296         // Close the data connection port [Data transfer complete]
1297         fclose($this->_dataconn);
1298 
1299         // Verify that the server received the transfer
1300         if (!$this->_verifyResponse(226))
1301         {
1302             throw new RuntimeException(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_APPEND_BAD_RESPONSE_TRANSFER', $this->_response, $remote), 37);
1303         }
1304 
1305         return true;
1306     }
1307 
1308     /**
1309      * Get the size of the remote file.
1310      *
1311      * @param   string  $remote  FTP path to file whose size to get
1312      *
1313      * @return  mixed  number of bytes or false on error
1314      *
1315      * @since   3.6.0
1316      */
1317     public function size($remote)
1318     {
1319         if (FTP_NATIVE)
1320         {
1321             $size = ftp_size($this->_conn, $remote);
1322 
1323             // In case ftp_size fails, try the SIZE command directly.
1324             if ($size === -1)
1325             {
1326                 $response = ftp_raw($this->_conn, 'SIZE ' . $remote);
1327                 $responseCode = substr($response[0], 0, 3);
1328                 $responseMessage = substr($response[0], 4);
1329 
1330                 if ($responseCode != '213')
1331                 {
1332                     throw new RuntimeException(JText::_('JLIB_CLIENT_ERROR_JFTP_SIZE_BAD_RESPONSE'), 35);
1333                 }
1334 
1335                 $size = (int) $responseMessage;
1336             }
1337 
1338             return $size;
1339         }
1340 
1341         // Start passive mode
1342         if (!$this->_passive())
1343         {
1344             throw new RuntimeException(JText::_('JLIB_CLIENT_ERROR_JFTP_SIZE_PASSIVE'), 36);
1345         }
1346 
1347         // Send size command to the FTP server
1348         if (!$this->_putCmd('SIZE ' . $remote, array(213)))
1349         {
1350             @fclose($this->_dataconn);
1351 
1352             throw new RuntimeException(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_SIZE_BAD_RESPONSE', $this->_response, $remote), 35);
1353         }
1354 
1355         return (int) substr($this->_responseMsg, 4);
1356     }
1357 
1358     /**
1359      * Method to list the filenames of the contents of a directory on the FTP server
1360      *
1361      * Note: Some servers also return folder names. However, to be sure to list folders on all
1362      * servers, you should use listDetails() instead if you also need to deal with folders
1363      *
1364      * @param   string  $path  Path local file to store on the FTP server
1365      *
1366      * @return  string  Directory listing
1367      *
1368      * @since   12.1
1369      */
1370     public function listNames($path = null)
1371     {
1372         $data = null;
1373 
1374         // If native FTP support is enabled let's use it...
1375         if (FTP_NATIVE)
1376         {
1377             // Turn passive mode on
1378             if (@ftp_pasv($this->_conn, true) === false)
1379             {
1380                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_LISTNAMES_PASSIVE'), JLog::WARNING, 'jerror');
1381 
1382                 return false;
1383             }
1384 
1385             if (($list = @ftp_nlist($this->_conn, $path)) === false)
1386             {
1387                 // Workaround for empty directories on some servers
1388                 if ($this->listDetails($path, 'files') === array())
1389                 {
1390                     return array();
1391                 }
1392 
1393                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_LISTNAMES_BAD_RESPONSE'), JLog::WARNING, 'jerror');
1394 
1395                 return false;
1396             }
1397 
1398             $list = preg_replace('#^' . preg_quote($path, '#') . '[/\\\\]?#', '', $list);
1399 
1400             if ($keys = array_merge(array_keys($list, '.'), array_keys($list, '..')))
1401             {
1402                 foreach ($keys as $key)
1403                 {
1404                     unset($list[$key]);
1405                 }
1406             }
1407 
1408             return $list;
1409         }
1410 
1411         // If a path exists, prepend a space
1412         if ($path != null)
1413         {
1414             $path = ' ' . $path;
1415         }
1416 
1417         // Start passive mode
1418         if (!$this->_passive())
1419         {
1420             JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_LISTNAMES_PASSIVE'), JLog::WARNING, 'jerror');
1421 
1422             return false;
1423         }
1424 
1425         if (!$this->_putCmd('NLST' . $path, array(150, 125)))
1426         {
1427             @ fclose($this->_dataconn);
1428 
1429             // Workaround for empty directories on some servers
1430             if ($this->listDetails($path, 'files') === array())
1431             {
1432                 return array();
1433             }
1434 
1435             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_LISTNAMES_BAD_RESPONSE_NLST', $this->_response, $path), JLog::WARNING, 'jerror');
1436 
1437             return false;
1438         }
1439 
1440         // Read in the file listing.
1441         while (!feof($this->_dataconn))
1442         {
1443             $data .= fread($this->_dataconn, 4096);
1444         }
1445 
1446         fclose($this->_dataconn);
1447 
1448         // Everything go okay?
1449         if (!$this->_verifyResponse(226))
1450         {
1451             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_LISTNAMES_BAD_RESPONSE_TRANSFER', $this->_response, $path), JLog::WARNING, 'jerror');
1452 
1453             return false;
1454         }
1455 
1456         $data = preg_split('/[' . CRLF . ']+/', $data, -1, PREG_SPLIT_NO_EMPTY);
1457         $data = preg_replace('#^' . preg_quote(substr($path, 1), '#') . '[/\\\\]?#', '', $data);
1458 
1459         if ($keys = array_merge(array_keys($data, '.'), array_keys($data, '..')))
1460         {
1461             foreach ($keys as $key)
1462             {
1463                 unset($data[$key]);
1464             }
1465         }
1466 
1467         return $data;
1468     }
1469 
1470     /**
1471      * Method to list the contents of a directory on the FTP server
1472      *
1473      * @param   string  $path  Path to the local file to be stored on the FTP server
1474      * @param   string  $type  Return type [raw|all|folders|files]
1475      *
1476      * @return  mixed  If $type is raw: string Directory listing, otherwise array of string with file-names
1477      *
1478      * @since   12.1
1479      */
1480     public function listDetails($path = null, $type = 'all')
1481     {
1482         $dir_list = array();
1483         $data = null;
1484         $regs = null;
1485 
1486         // TODO: Deal with recurse -- nightmare
1487         // For now we will just set it to false
1488         $recurse = false;
1489 
1490         // If native FTP support is enabled let's use it...
1491         if (FTP_NATIVE)
1492         {
1493             // Turn passive mode on
1494             if (@ftp_pasv($this->_conn, true) === false)
1495             {
1496                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_LISTDETAILS_PASSIVE'), JLog::WARNING, 'jerror');
1497 
1498                 return false;
1499             }
1500 
1501             if (($contents = @ftp_rawlist($this->_conn, $path)) === false)
1502             {
1503                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_LISTDETAILS_BAD_RESPONSE'), JLog::WARNING, 'jerror');
1504 
1505                 return false;
1506             }
1507         }
1508         else
1509         {
1510             // Non Native mode
1511 
1512             // Start passive mode
1513             if (!$this->_passive())
1514             {
1515                 JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_LISTDETAILS_PASSIVE'), JLog::WARNING, 'jerror');
1516 
1517                 return false;
1518             }
1519 
1520             // If a path exists, prepend a space
1521             if ($path != null)
1522             {
1523                 $path = ' ' . $path;
1524             }
1525 
1526             // Request the file listing
1527             if (!$this->_putCmd(($recurse == true) ? 'LIST -R' : 'LIST' . $path, array(150, 125)))
1528             {
1529                 JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_LISTDETAILS_BAD_RESPONSE_LIST', $this->_response, $path), JLog::WARNING, 'jerror');
1530                 @ fclose($this->_dataconn);
1531 
1532                 return false;
1533             }
1534 
1535             // Read in the file listing.
1536             while (!feof($this->_dataconn))
1537             {
1538                 $data .= fread($this->_dataconn, 4096);
1539             }
1540 
1541             fclose($this->_dataconn);
1542 
1543             // Everything go okay?
1544             if (!$this->_verifyResponse(226))
1545             {
1546                 JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_LISTDETAILS_BAD_RESPONSE_TRANSFER', $this->_response, $path), JLog::WARNING, 'jerror');
1547 
1548                 return false;
1549             }
1550 
1551             $contents = explode(CRLF, $data);
1552         }
1553 
1554         // If only raw output is requested we are done
1555         if ($type == 'raw')
1556         {
1557             return $data;
1558         }
1559 
1560         // If we received the listing of an empty directory, we are done as well
1561         if (empty($contents[0]))
1562         {
1563             return $dir_list;
1564         }
1565 
1566         // If the server returned the number of results in the first response, let's dump it
1567         if (strtolower(substr($contents[0], 0, 6)) == 'total ')
1568         {
1569             array_shift($contents);
1570 
1571             if (!isset($contents[0]) || empty($contents[0]))
1572             {
1573                 return $dir_list;
1574             }
1575         }
1576 
1577         // Regular expressions for the directory listing parsing.
1578         $regexps = array(
1579             'UNIX' => '#([-dl][rwxstST-]+).* ([0-9]*) ([a-zA-Z0-9]+).* ([a-zA-Z0-9]+).* ([0-9]*)'
1580                 . ' ([a-zA-Z]+[0-9: ]*[0-9])[ ]+(([0-9]{1,2}:[0-9]{2})|[0-9]{4}) (.+)#',
1581             'MAC' => '#([-dl][rwxstST-]+).* ?([0-9 ]*)?([a-zA-Z0-9]+).* ([a-zA-Z0-9]+).* ([0-9]*)'
1582                 . ' ([a-zA-Z]+[0-9: ]*[0-9])[ ]+(([0-9]{2}:[0-9]{2})|[0-9]{4}) (.+)#',
1583             'WIN' => '#([0-9]{2})-([0-9]{2})-([0-9]{2}) +([0-9]{2}):([0-9]{2})(AM|PM) +([0-9]+|<DIR>) +(.+)#',
1584         );
1585 
1586         // Find out the format of the directory listing by matching one of the regexps
1587         $osType = null;
1588 
1589         foreach ($regexps as $k => $v)
1590         {
1591             if (@preg_match($v, $contents[0]))
1592             {
1593                 $osType = $k;
1594                 $regexp = $v;
1595                 break;
1596             }
1597         }
1598 
1599         if (!$osType)
1600         {
1601             JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_LISTDETAILS_UNRECOGNISED'), JLog::WARNING, 'jerror');
1602 
1603             return false;
1604         }
1605 
1606         // Here is where it is going to get dirty....
1607         if ($osType == 'UNIX' || $osType == 'MAC')
1608         {
1609             foreach ($contents as $file)
1610             {
1611                 $tmp_array = null;
1612 
1613                 if (@preg_match($regexp, $file, $regs))
1614                 {
1615                     $fType = (int) strpos('-dl', $regs[1]{0});
1616 
1617                     // $tmp_array['line'] = $regs[0];
1618                     $tmp_array['type']   = $fType;
1619                     $tmp_array['rights'] = $regs[1];
1620 
1621                     // $tmp_array['number'] = $regs[2];
1622                     $tmp_array['user']  = $regs[3];
1623                     $tmp_array['group'] = $regs[4];
1624                     $tmp_array['size']  = $regs[5];
1625                     $tmp_array['date']  = @date('m-d', strtotime($regs[6]));
1626                     $tmp_array['time']  = $regs[7];
1627                     $tmp_array['name']  = $regs[9];
1628                 }
1629 
1630                 // If we just want files, do not add a folder
1631                 if ($type == 'files' && $tmp_array['type'] == 1)
1632                 {
1633                     continue;
1634                 }
1635 
1636                 // If we just want folders, do not add a file
1637                 if ($type == 'folders' && $tmp_array['type'] == 0)
1638                 {
1639                     continue;
1640                 }
1641 
1642                 if (is_array($tmp_array) && $tmp_array['name'] != '.' && $tmp_array['name'] != '..')
1643                 {
1644                     $dir_list[] = $tmp_array;
1645                 }
1646             }
1647         }
1648         else
1649         {
1650             foreach ($contents as $file)
1651             {
1652                 $tmp_array = null;
1653 
1654                 if (@preg_match($regexp, $file, $regs))
1655                 {
1656                     $fType = (int) ($regs[7] == '<DIR>');
1657                     $timestamp = strtotime("$regs[3]-$regs[1]-$regs[2] $regs[4]:$regs[5]$regs[6]");
1658 
1659                     // $tmp_array['line'] = $regs[0];
1660                     $tmp_array['type'] = $fType;
1661                     $tmp_array['rights'] = '';
1662 
1663                     // $tmp_array['number'] = 0;
1664                     $tmp_array['user'] = '';
1665                     $tmp_array['group'] = '';
1666                     $tmp_array['size'] = (int) $regs[7];
1667                     $tmp_array['date'] = date('m-d', $timestamp);
1668                     $tmp_array['time'] = date('H:i', $timestamp);
1669                     $tmp_array['name'] = $regs[8];
1670                 }
1671                 // If we just want files, do not add a folder
1672                 if ($type == 'files' && $tmp_array['type'] == 1)
1673                 {
1674                     continue;
1675                 }
1676                 // If we just want folders, do not add a file
1677                 if ($type == 'folders' && $tmp_array['type'] == 0)
1678                 {
1679                     continue;
1680                 }
1681 
1682                 if (is_array($tmp_array) && $tmp_array['name'] != '.' && $tmp_array['name'] != '..')
1683                 {
1684                     $dir_list[] = $tmp_array;
1685                 }
1686             }
1687         }
1688 
1689         return $dir_list;
1690     }
1691 
1692     /**
1693      * Send command to the FTP server and validate an expected response code
1694      *
1695      * @param   string  $cmd               Command to send to the FTP server
1696      * @param   mixed   $expectedResponse  Integer response code or array of integer response codes
1697      *
1698      * @return  boolean  True if command executed successfully
1699      *
1700      * @since   12.1
1701      */
1702     protected function _putCmd($cmd, $expectedResponse)
1703     {
1704         // Make sure we have a connection to the server
1705         if (!is_resource($this->_conn))
1706         {
1707             JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_PUTCMD_UNCONNECTED'), JLog::WARNING, 'jerror');
1708 
1709             return false;
1710         }
1711 
1712         // Send the command to the server
1713         if (!fwrite($this->_conn, $cmd . "\r\n"))
1714         {
1715             JLog::add(JText::sprintf('DDD', JText::sprintf('JLIB_CLIENT_ERROR_JFTP_PUTCMD_SEND', $cmd)), JLog::WARNING, 'jerror');
1716         }
1717 
1718         return $this->_verifyResponse($expectedResponse);
1719     }
1720 
1721     /**
1722      * Verify the response code from the server and log response if flag is set
1723      *
1724      * @param   mixed  $expected  Integer response code or array of integer response codes
1725      *
1726      * @return  boolean  True if response code from the server is expected
1727      *
1728      * @since   12.1
1729      */
1730     protected function _verifyResponse($expected)
1731     {
1732         $parts = null;
1733 
1734         // Wait for a response from the server, but timeout after the set time limit
1735         $endTime = time() + $this->_timeout;
1736         $this->_response = '';
1737 
1738         do
1739         {
1740             $this->_response .= fgets($this->_conn, 4096);
1741         }
1742         while (!preg_match('/^([0-9]{3})(-(.*' . CRLF . ')+\1)? [^' . CRLF . ']+' . CRLF . "$/", $this->_response, $parts) && time() < $endTime);
1743 
1744         // Catch a timeout or bad response
1745         if (!isset($parts[1]))
1746         {
1747             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_VERIFYRESPONSE', $this->_response), JLog::WARNING, 'jerror');
1748 
1749             return false;
1750         }
1751 
1752         // Separate the code from the message
1753         $this->_responseCode = $parts[1];
1754         $this->_responseMsg = $parts[0];
1755 
1756         // Did the server respond with the code we wanted?
1757         if (is_array($expected))
1758         {
1759             if (in_array($this->_responseCode, $expected))
1760             {
1761                 $retval = true;
1762             }
1763             else
1764             {
1765                 $retval = false;
1766             }
1767         }
1768         else
1769         {
1770             if ($this->_responseCode == $expected)
1771             {
1772                 $retval = true;
1773             }
1774             else
1775             {
1776                 $retval = false;
1777             }
1778         }
1779 
1780         return $retval;
1781     }
1782 
1783     /**
1784      * Set server to passive mode and open a data port connection
1785      *
1786      * @return  boolean  True if successful
1787      *
1788      * @since   12.1
1789      */
1790     protected function _passive()
1791     {
1792         $match = array();
1793         $parts = array();
1794         $errno = null;
1795         $err = null;
1796 
1797         // Make sure we have a connection to the server
1798         if (!is_resource($this->_conn))
1799         {
1800             JLog::add(JText::_('JLIB_CLIENT_ERROR_JFTP_PASSIVE_CONNECT_PORT'), JLog::WARNING, 'jerror');
1801 
1802             return false;
1803         }
1804 
1805         // Request a passive connection - this means, we'll talk to you, you don't talk to us.
1806         @ fwrite($this->_conn, "PASV\r\n");
1807 
1808         // Wait for a response from the server, but timeout after the set time limit
1809         $endTime = time() + $this->_timeout;
1810         $this->_response = '';
1811 
1812         do
1813         {
1814             $this->_response .= fgets($this->_conn, 4096);
1815         }
1816         while (!preg_match('/^([0-9]{3})(-(.*' . CRLF . ')+\1)? [^' . CRLF . ']+' . CRLF . "$/", $this->_response, $parts) && time() < $endTime);
1817 
1818         // Catch a timeout or bad response
1819         if (!isset($parts[1]))
1820         {
1821             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_PASSIVE_RESPONSE', $this->_response), JLog::WARNING, 'jerror');
1822 
1823             return false;
1824         }
1825 
1826         // Separate the code from the message
1827         $this->_responseCode = $parts[1];
1828         $this->_responseMsg = $parts[0];
1829 
1830         // If it's not 227, we weren't given an IP and port, which means it failed.
1831         if ($this->_responseCode != '227')
1832         {
1833             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_PASSIVE_IP_OBTAIN', $this->_responseMsg), JLog::WARNING, 'jerror');
1834 
1835             return false;
1836         }
1837 
1838         // Snatch the IP and port information, or die horribly trying...
1839         if (preg_match('~\((\d+),\s*(\d+),\s*(\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d+))\)~', $this->_responseMsg, $match) == 0)
1840         {
1841             JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_PASSIVE_IP_VALID', $this->_responseMsg), JLog::WARNING, 'jerror');
1842 
1843             return false;
1844         }
1845 
1846         // This is pretty simple - store it for later use ;).
1847         $this->_pasv = array('ip' => $match[1] . '.' . $match[2] . '.' . $match[3] . '.' . $match[4], 'port' => $match[5] * 256 + $match[6]);
1848 
1849         // Connect, assuming we've got a connection.
1850         $this->_dataconn = @fsockopen($this->_pasv['ip'], $this->_pasv['port'], $errno, $err, $this->_timeout);
1851 
1852         if (!$this->_dataconn)
1853         {
1854             JLog::add(
1855                 JText::sprintf('JLIB_CLIENT_ERROR_JFTP_PASSIVE_CONNECT', $this->_pasv['ip'], $this->_pasv['port'], $errno, $err),
1856                 JLog::WARNING,
1857                 'jerror'
1858             );
1859 
1860             return false;
1861         }
1862 
1863         // Set the timeout for this connection
1864         socket_set_timeout($this->_conn, $this->_timeout, 0);
1865 
1866         return true;
1867     }
1868 
1869     /**
1870      * Method to find out the correct transfer mode for a specific file
1871      *
1872      * @param   string  $fileName  Name of the file
1873      *
1874      * @return  integer Transfer-mode for this filetype [FTP_ASCII|FTP_BINARY]
1875      *
1876      * @since   12.1
1877      */
1878     protected function _findMode($fileName)
1879     {
1880         if ($this->_type == FTP_AUTOASCII)
1881         {
1882             $dot = strrpos($fileName, '.') + 1;
1883             $ext = substr($fileName, $dot);
1884 
1885             if (in_array($ext, $this->_autoAscii))
1886             {
1887                 $mode = FTP_ASCII;
1888             }
1889             else
1890             {
1891                 $mode = FTP_BINARY;
1892             }
1893         }
1894         elseif ($this->_type == FTP_ASCII)
1895         {
1896             $mode = FTP_ASCII;
1897         }
1898         else
1899         {
1900             $mode = FTP_BINARY;
1901         }
1902 
1903         return $mode;
1904     }
1905 
1906     /**
1907      * Set transfer mode
1908      *
1909      * @param   integer  $mode  Integer representation of data transfer mode [1:Binary|0:Ascii]
1910      * Defined constants can also be used [FTP_BINARY|FTP_ASCII]
1911      *
1912      * @return  boolean  True if successful
1913      *
1914      * @since   12.1
1915      */
1916     protected function _mode($mode)
1917     {
1918         if ($mode == FTP_BINARY)
1919         {
1920             if (!$this->_putCmd('TYPE I', 200))
1921             {
1922                 JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_MODE_BINARY', $this->_response), JLog::WARNING, 'jerror');
1923 
1924                 return false;
1925             }
1926         }
1927         else
1928         {
1929             if (!$this->_putCmd('TYPE A', 200))
1930             {
1931                 JLog::add(JText::sprintf('JLIB_CLIENT_ERROR_JFTP_MODE_ASCII', $this->_response), JLog::WARNING, 'jerror');
1932 
1933                 return false;
1934             }
1935         }
1936 
1937         return true;
1938     }
1939 }
1940 
1941 /**
1942  * Deprecated class placeholder. You should use JClientFtp instead.
1943  *
1944  * @since       11.1
1945  * @deprecated  12.3 (Platform) & 4.0 (CMS)
1946  */
1947 class JFTP extends JClientFtp
1948 {
1949     /**
1950      * JFTP object constructor
1951      *
1952      * @param   array  $options  Associative array of options to set
1953      *
1954      * @since   11.1
1955      */
1956     public function __construct(array $options = array())
1957     {
1958         JLog::add('JFTP is deprecated. Use JClientFtp instead.', JLog::WARNING, 'deprecated');
1959         parent::__construct($options);
1960     }
1961 }
1962 
Joomla! Framework TM API documentation generated by ApiGen 2.8.0
Joomla!® and Joomla! Framework™ are trademarks of Open Source Matters, Inc. in the United States and other countries.