Overview

Namespaces

  • MatthiasMullie
    • Minify
      • Exceptions
    • PathConverter
  • None
  • ReCaptcha
    • RequestMethod
  • TOTP

Classes

  • apc_cache
  • apcu_cache
  • ApprovePost_Notify_Background
  • ApproveReply_Notify_Background
  • Attachments
  • Birthday_Notify_Background
  • browser_detector
  • Buddy_Notify_Background
  • cache_api
  • CreateAttachment_Notify_Background
  • CreatePost_Notify_Background
  • curl_fetch_web_data
  • custom_search
  • EventNew_Notify_Background
  • ftp_connection
  • fulltext_search
  • gif_color_table
  • gif_file
  • gif_file_header
  • gif_image
  • gif_image_header
  • gif_lzw_compression
  • GroupAct_Notify_Background
  • GroupReq_Notify_Background
  • Likes
  • Likes_Notify_Background
  • MatthiasMullie\Minify\CSS
  • MatthiasMullie\Minify\JS
  • MatthiasMullie\Minify\Minify
  • MatthiasMullie\PathConverter\Converter
  • MemberReport_Notify_Background
  • MemberReportReply_Notify_Background
  • memcache_cache
  • memcached_cache
  • Mentions
  • MsgReport_Notify_Background
  • MsgReportReply_Notify_Background
  • paypal_display
  • paypal_payment
  • postgres_cache
  • ProxyServer
  • Punycode
  • ReCaptcha\ReCaptcha
  • ReCaptcha\RequestMethod\Curl
  • ReCaptcha\RequestMethod\CurlPost
  • ReCaptcha\RequestMethod\Post
  • ReCaptcha\RequestMethod\Socket
  • ReCaptcha\RequestMethod\SocketPost
  • ReCaptcha\RequestParameters
  • ReCaptcha\Response
  • Register_Notify_Background
  • search_api
  • SMF_BackgroundTask
  • smf_cache
  • sqlite_cache
  • standard_search
  • TOTP\Auth
  • TypeError
  • Update_TLD_Regex
  • xcache_cache
  • xmlArray
  • zend_cache

Interfaces

  • cache_api_interface
  • ReCaptcha\RequestMethod
  • search_api_interface

Exceptions

  • Error
  • MatthiasMullie\Minify\Exception
  • MatthiasMullie\Minify\Exceptions\BasicException
  • MatthiasMullie\Minify\Exceptions\FileImportException
  • MatthiasMullie\Minify\Exceptions\IOException

Functions

  • _safe_serialize
  • _safe_unserialize
  • account
  • Activate
  • activateAccount
  • add_integration_function
  • addData
  • addInlineCss
  • addInlineJavaScript
  • addJavaScriptVar
  • AddLanguage
  • AddMailQueue
  • AddMembergroup
  • addMembersToGroup
  • addSeparator
  • AddSmiley
  • addSubscription
  • addTriggers
  • AdminAccount
  • AdminApprove
  • AdminBoardRecount
  • AdminEndSession
  • AdminHome
  • adminLogin
  • adminLogin_outputPostVars
  • AdminLogs
  • AdminMain
  • adminNotify
  • AdminRegister
  • AdminSearch
  • AdminSearchInternal
  • AdminSearchMember
  • AdminSearchOM
  • alert_configuration
  • alert_count
  • alert_delete
  • alert_mark
  • alert_markread
  • alert_notifications_boards
  • alert_notifications_topics
  • alert_purge
  • alerts_popup
  • AlignURLsWithSSLSetting
  • allowedTo
  • AnnouncementSelectMembergroup
  • AnnouncementSend
  • AnnounceTopic
  • ApplyRules
  • approveAllData
  • ApproveAttach
  • ApproveAttachments
  • ApproveMessage
  • approveMessages
  • approvePosts
  • approveTopics
  • array_column
  • array_length
  • assignAttachments
  • attachDirStatus
  • attachmentChecks
  • attachments_init_dir
  • automanage_attachments_by_space
  • automanage_attachments_check_directory
  • automanage_attachments_create_directory
  • AutoSuggest_Search_Member
  • AutoSuggest_Search_MemberGroups
  • AutoSuggest_Search_SMFVersions
  • AutoSuggestHandler
  • AutoTask
  • BackupDatabase
  • backupTable
  • Ban
  • BanBrowseTriggers
  • BanEdit
  • banEdit2
  • BanEditTrigger
  • BanList
  • banLoadAdditionalIPs
  • banLoadAdditionalIPsError
  • banLoadAdditionalIPsMember
  • BanLog
  • banPermissions
  • bbc_to_html
  • BoardIndex
  • BoardNotify
  • BoardPermissionsReport
  • BoardReport
  • boardsAllowedTo
  • BoardurlMatch
  • BookOfUnknown
  • BrowseFiles
  • BrowseMailQueue
  • BuddyListToggle
  • build_query_board
  • build_regex
  • buildEventDatetimes
  • cache_get_data
  • cache_getLastPosts
  • cache_getMembergroupList
  • cache_getOffsetIndependentEvents
  • cache_getRecentEvents
  • cache_put_data
  • cache_quick_get
  • CalculateNextTrigger
  • CalendarMain
  • CalendarPost
  • call_helper
  • call_integration_hook
  • canLinkEvent
  • canPickTheme
  • cdata_parse
  • censorText
  • check_cron
  • checkActivation
  • checkChange
  • checkConfirm
  • checkExistingTriggerIP
  • CheckFilesWritable
  • checkGD
  • checkImageContents
  • checkImagick
  • checkLogin
  • checkMagickWand
  • checkSession
  • checkSubmitOnce
  • clean_cache
  • cleanLangString
  • cleanRequest
  • cleanRequest_cron
  • cleanTokens
  • cleanXml
  • ClearMailQueue
  • cli_scheduled_fetchSMfiles
  • clock
  • cmdStep0
  • comma_format
  • compareVersions
  • ComposeMailing
  • consolidateSpiderStats
  • construct_query_string
  • constructPageIndex
  • ConvertEntities
  • ConvertMsgBody
  • convertSettingstoOptions
  • convertSettingsToTheme
  • ConvertUtf8
  • CoppaForm
  • CopyTemplate
  • copytree
  • countReports
  • create_button
  • create_chmod_control
  • create_control_richedit
  • create_control_verification
  • createAttachment
  • createBoard
  • createCategory
  • createList
  • createMenu
  • CreateMessageIndex
  • createPost
  • createSalvageArea
  • createThumbnail
  • createToken
  • createWaveFile
  • Credits
  • custFieldsMaxOrder
  • custMinify
  • DatabaseChanges
  • DatabasePopulation
  • DatabaseSettings
  • db_extend
  • db_extra_init
  • db_fix_prefix
  • db_packages_init
  • db_search_init
  • db_version_check
  • debugPrint
  • deleteAccount
  • deleteAccount2
  • deleteAllMinified
  • deleteBoards
  • deleteCategories
  • DeleteDraft
  • deleteErrors
  • DeleteInstall
  • DeleteMembergroup
  • deleteMembergroups
  • deleteMembers
  • DeleteMessage
  • deleteMessages
  • deleteModComment
  • deleteNotifyPrefs
  • DeleteUpgrade
  • deltree
  • Destroy
  • destroyMenu
  • detectBrowser
  • detectFulltextIndex
  • determineActions
  • Display
  • display_db_error
  • display_loadavg_error
  • display_maintenance_message
  • DisplayAdminFile
  • displayDebug
  • DisplayStats
  • DoLogin
  • Download
  • downloadAvatar
  • DownloadLanguage
  • dumpTags
  • EditAgreement
  • EditBoard
  • EditBoard2
  • EditBoardSettings
  • editBuddies
  • editBuddyIgnoreLists
  • EditCategory
  • EditCategory2
  • EditComment
  • EditCustomProfiles
  • EditHoliday
  • editIgnoreList
  • EditMembergroup
  • EditMessageIcons
  • editModComment
  • EditNews
  • EditPermissionProfiles
  • EditPoll
  • EditPoll2
  • EditSearchMethod
  • EditSearchSettings
  • EditSmileyOrder
  • EditSmileys
  • EditSmileySets
  • EditSmileySettings
  • EditSpider
  • EditTask
  • EditTheme
  • EditWeights
  • emailAdmins
  • EnableTheme
  • entity_fix__callback
  • escapestring__recursive
  • ExamineFile
  • expandIPv6
  • fatal_error
  • fatal_lang_error
  • fetch_alerts
  • fetch_task
  • fetch_web_data
  • fetchPerms__recursive
  • fetchTagAttributes
  • find_gpg
  • find_signed_off
  • find_signed_off_parents
  • findForumErrors
  • findMembers
  • findSearchAPI
  • finishTables
  • fix_possible_url
  • fix_serialized_data
  • fixchar__callback
  • fixchardb__callback
  • fixChildren
  • fixModSecurity
  • fixRelativePath
  • fixTag
  • fixTags
  • forum_time
  • forumProfile
  • ForumSettings
  • frameOptionsHeader
  • GeneralPermissionSettings
  • generateSubscriptionError
  • generateValidationCode
  • get_all_themes
  • get_current_settings
  • get_date_or_time_format
  • get_directory_tree_elements
  • get_file_listing
  • get_files_recursive
  • get_gravatar_url
  • get_hook_info_from_raw
  • get_installed_themes
  • get_integration_hooks
  • get_integration_hooks_count
  • get_integration_hooks_data
  • get_proxied_url
  • get_single_theme
  • get_theme_info
  • getAttachmentFilename
  • getAttachMsgInfo
  • getAvatars
  • getBirthdayRange
  • getBoardIndex
  • getBoardList
  • getBoardModeratorGroups
  • getBoardModerators
  • getBoardParents
  • getBoardTree
  • getCalendarGrid
  • getCalendarList
  • getCalendarWeek
  • getCommentModDetails
  • getCustFieldsMList
  • getDailyStats
  • getEventPoster
  • getEventProperties
  • getEventRange
  • getFileVersions
  • getHolidayRange
  • GetJumpTo
  • getLanguages
  • getLastPost
  • getLastPosts
  • GetMemberActivationCounts
  • getMemberData
  • getMemberGroups
  • getMembersOnlineStats
  • getMessageIcons
  • getMsgMemberID
  • getNewEventDatetimes
  • getNotifyPrefs
  • getPackageInfo
  • getRawAttachInfo
  • getReportComments
  • getReportDetails
  • getReports
  • getServerVersions
  • getTodayInfo
  • getTopic
  • getTreeOrder
  • getUserTimezone
  • getXmlMembers
  • getXmlNews
  • getXmlProfile
  • getXmlRecent
  • gif_outputAsPng
  • GroupList
  • groupMembership
  • groupMembership2
  • GroupPermissionsReport
  • GroupRequests
  • Groups
  • groupsAllowedTo
  • HandleComment
  • HandleReport
  • hash_benchmark
  • hash_length
  • hash_password
  • hash_salt
  • hash_verify_password
  • HelpIndex
  • HelpRules
  • highlight
  • highlight_php_code
  • host_from_ip
  • html_to_bbc
  • htmlspecialchars__recursive
  • htmltrim__recursive
  • https_redirect_active
  • httpsOn
  • iCalDownload
  • ignoreboards
  • imagecopyresamplebicubic
  • imagecreatefrombmp
  • imageMemoryCheck
  • ImportSmileys
  • inet_dtop
  • inet_ptod
  • initialize_inputs
  • InMaintenance
  • insertBanGroup
  • insertEvent
  • InstallCopy
  • InstallDir
  • installer_updateSettingsFile
  • installExit
  • InstallFile
  • InstallSmileySet
  • ip2range
  • iri_to_url
  • is_not_banned
  • is_not_guest
  • isAccessiblePM
  • isAllowedTo
  • isBannedEmail
  • isBrowser
  • isChildOf
  • isReservedName
  • issueWarning
  • isValidIP
  • isValidIPv6
  • JavaScriptEscape
  • JavaScriptModify
  • jeffsdatediff
  • JSMembers
  • KickGuest
  • legalise_bbc
  • list_getAttachDirs
  • list_getAttachments
  • list_getBanItems
  • list_getBanLogEntries
  • list_getBans
  • list_getBanTriggers
  • list_getBaseDirs
  • list_getBoardNotifications
  • list_getFiles
  • list_getGroupRequestCount
  • list_getGroupRequests
  • list_getGroupRequestsCount
  • list_getHolidays
  • list_getIPMessageCount
  • list_getIPMessages
  • list_getLanguages
  • list_getLanguagesList
  • list_getLoginCount
  • list_getLogins
  • list_getMailQueue
  • list_getMailQueueSize
  • list_getMembergroups
  • list_getMembers
  • list_getMessageIcons
  • list_getModLogEntries
  • list_getModLogEntryCount
  • list_getNews
  • list_getNumAttachments
  • list_getNumBanItems
  • list_getNumBanLogEntries
  • list_getNumBans
  • list_getNumBanTriggers
  • list_getNumFiles
  • list_getNumHolidays
  • list_getNumLanguages
  • list_getNumMembers
  • list_getNumSmileys
  • list_getNumSmileySets
  • list_getNumSpiderLogs
  • list_getNumSpiders
  • list_getNumSpiderStats
  • list_getNumTaskLogEntries
  • list_getNumUnapprovedAttachments
  • list_getNumUnwatched
  • list_getPackages
  • list_getProfileEditCount
  • list_getProfileEdits
  • list_getProfileFields
  • list_getProfileFieldSize
  • list_getScheduledTasks
  • list_getSmileys
  • list_getSmileySets
  • list_getSpiderLogs
  • list_getSpiders
  • list_getSpiderStats
  • list_getSubscribedUserCount
  • list_getSubscribedUsers
  • list_getTaskLogEntries
  • list_getTopicNotificationCount
  • list_getTopicNotifications
  • list_getUnapprovedAttachments
  • list_getUnwatched
  • list_getUserErrorCount
  • list_getUserErrors
  • list_getUserWarningCount
  • list_getUserWarnings
  • list_getWarningCount
  • list_getWarnings
  • list_getWarningTemplateCount
  • list_getWarningTemplates
  • list_getWatchedUserCount
  • list_getWatchedUserPosts
  • list_getWatchedUserPostsCount
  • list_getWatchedUsers
  • list_integration_hooks
  • listMembergroupMembers_Href
  • ListMessageIcons
  • listtree
  • load_database
  • load_file
  • load_lang_file
  • loadAttachmentContext
  • loadBoard
  • loadCacheAccelerator
  • loadCacheAPIs
  • loadCSSFile
  • loadCustomFields
  • loadDatabase
  • loadDatePair
  • loadDatePicker
  • loadEmailTemplate
  • loadEssentialData
  • loadEssentialThemeData
  • loadForumTests
  • loadGeneralSettingParameters
  • loadIllegalBBCHtmlGroups
  • loadIllegalGuestPermissions
  • loadIllegalPermissions
  • loadInstalledPackages
  • loadJavaScriptFile
  • loadLanguage
  • loadLocale
  • loadMemberContext
  • loadMemberCustomFields
  • loadMemberData
  • loadPaymentGateways
  • loadPermissionProfiles
  • loadPermissions
  • loadProfileFields
  • LoadRules
  • loadSearchAPIs
  • loadSession
  • loadSubscriptions
  • loadSubTemplate
  • loadTemplate
  • loadTheme
  • loadThemeOptions
  • loadTimePicker
  • loadUserSettings
  • LockTopic
  • LockVoting
  • log_ban
  • log_error
  • log_error_online
  • logAction
  • logActions
  • Login
  • Login2
  • LoginTFA
  • logLastDatabaseError
  • Logout
  • logSpider
  • logTriggersUpdates
  • MaintainCleanCache
  • MaintainDatabase
  • MaintainEmptyUnimportantLogs
  • MaintainFiles
  • MaintainFindFixErrors
  • MaintainMassMoveTopics
  • MaintainMembers
  • MaintainPurgeInactiveMembers
  • MaintainReattributePosts
  • MaintainRecountPosts
  • MaintainRemoveOldDrafts
  • MaintainRemoveOldPosts
  • MaintainRoutine
  • MaintainTopics
  • makeCustomFieldChanges
  • makeFilesWritable
  • makeNotificationChanges
  • makeThemeChanges
  • ManageAttachmentPaths
  • ManageAttachments
  • ManageAttachmentSettings
  • ManageAvatarSettings
  • ManageBoards
  • ManageBoardsMain
  • ManageCalendar
  • ManageLabels
  • ManageLanguages
  • ManageMail
  • ManageMaintenance
  • ManageNews
  • ManagePaidSubscriptions
  • ManagePostSettings
  • ManageRules
  • ManageScheduledTasks
  • ManageSearch
  • ManageSearchEngineSettings
  • ManageSmileys
  • markBoardsRead
  • markMessages
  • MarkRead
  • matchHighestPackageVersion
  • matchIPtoCIDR
  • matchPackageVersion
  • md5_hmac
  • MembergroupIndex
  • MembergroupMembers
  • MemberGroupsReport
  • Memberlist
  • membersAllowedTo
  • MembersAwaitingActivation
  • memoryReturnBytes
  • MergeDone
  • MergeExecute
  • MergeIndex
  • mergePosts
  • MergeTopics
  • MessageActionsApply
  • MessageDrafts
  • MessageFolder
  • MessageIndex
  • messageIndexBar
  • MessageKillAll
  • MessageMain
  • MessagePopup
  • MessagePost
  • MessagePost2
  • messagePostError
  • MessagePrune
  • MessageSearch
  • MessageSearch2
  • MessageSettings
  • mimespecialchars
  • mktree
  • MLAll
  • MLSearch
  • ModBlockGroupRequests
  • ModBlockNotes
  • ModBlockReportedMembers
  • ModBlockReportedPosts
  • ModBlockWatchedUsers
  • ModEndSession
  • ModerateGroups
  • ModerationHome
  • ModerationMain
  • ModerationSettings
  • ModifyAlertsSettings
  • ModifyAntispamSettings
  • ModifyBasicSettings
  • ModifyBBCSettings
  • modifyBoard
  • ModifyCacheSettings
  • ModifyCalendarSettings
  • ModifyCat
  • modifyCategory
  • ModifyCookieSettings
  • ModifyDatabaseSettings
  • ModifyDraftSettings
  • modifyEvent
  • ModifyFeatureSettings
  • ModifyGeneralModSettings
  • ModifyGeneralSecuritySettings
  • ModifyGeneralSettings
  • ModifyHolidays
  • ModifyLanguage
  • ModifyLanguages
  • ModifyLanguageSettings
  • ModifyLayoutSettings
  • ModifyLikesSettings
  • ModifyLoadBalancingSettings
  • ModifyLogSettings
  • ModifyMailSettings
  • ModifyMembergroup
  • ModifyMembergroup2
  • ModifyMembergroups
  • ModifyMembergroupsettings
  • ModifyMentionsSettings
  • ModifyModSettings
  • ModifyNewsSettings
  • ModifyPermissions
  • modifyPost
  • ModifyPostModeration
  • ModifyPostSettings
  • ModifyProfile
  • ModifyRegistrationSettings
  • ModifySettings
  • ModifySignatureSettings
  • ModifySubscription
  • ModifySubscriptionSettings
  • ModifyTopicSettings
  • ModifyUserSubscription
  • ModifyWarningSettings
  • ModifyWarningTemplate
  • MoveTopic
  • MoveTopic2
  • moveTopicConcurrence
  • moveTopics
  • MySQLConvertOldIp
  • newsletterpreview
  • newspreview
  • newTable
  • next_time
  • nextSubstep
  • notification
  • ob_sessrewrite
  • obExit
  • obExit_cron
  • OptimizeTables
  • package_chmod
  • package_create_backup
  • package_crypt
  • package_flush_cache
  • package_get_contents
  • package_put_contents
  • PackageBrowse
  • PackageDownload
  • PackageFTPTest
  • PackageGBrowse
  • PackageGet
  • PackageInstall
  • PackageInstallTest
  • PackageList
  • PackageOptions
  • PackagePermissions
  • PackagePermissionsAction
  • PackageRemove
  • packageRequireFTP
  • Packages
  • PackageServerAdd
  • PackageServerRemove
  • PackageServers
  • PackageUpload
  • parse_bbc
  • parse_path
  • parse_sql
  • parseAttachBBC
  • parseBoardMod
  • parseModification
  • parsePackageInfo
  • parsesmileys
  • password_get_info
  • password_hash
  • password_needs_rehash
  • password_verify
  • pauseAttachmentMaintenance
  • pauseMailQueueClear
  • pauseRepairProcess
  • pauseSignatureApplySettings
  • perform_task
  • PermissionByBoard
  • PermissionIndex
  • permute
  • php_version_check
  • phpBB3_password_check
  • PickTheme
  • PlushSearch1
  • PlushSearch2
  • populateDuplicateMembers
  • Post
  • Post2
  • PostModerationMain
  • prepareAttachsByMsg
  • prepareCLIhandler
  • prepareDBSettingContext
  • prepareDisplayContext
  • prepareLikesContext
  • prepareMailingForPreview
  • prepareMessageContext
  • prepareSearchContext
  • prepareServerSettingsContext
  • preparsecode
  • print_error
  • printMemberListRows
  • PrintTopic
  • processAttachments
  • profile_popup
  • profileLoadAvatarData
  • profileLoadGroups
  • profileLoadLanguages
  • profileLoadSignatureData
  • profileReloadUser
  • profileSaveAvatarData
  • profileSaveGroups
  • profileSendActivation
  • profileValidateEmail
  • profileValidateSignature
  • protected_alter
  • quickFileWritable
  • QuickInTopicModeration
  • QuickModeration
  • QuoteFast
  • random_bytes
  • random_int
  • RandomCompat_intval
  • RandomCompat_strlen
  • RandomCompat_substr
  • range2ip
  • read_tgz_data
  • read_tgz_file
  • read_zip_data
  • read_zip_file
  • ReadDraft
  • reapplySubscriptions
  • reattributePosts
  • rebuildModCache
  • recacheSpiderNames
  • RecentPosts
  • recountOpenReports
  • recursiveBoards
  • redirectexit
  • redirectLocation
  • ReduceMailQueue
  • reencodeImage
  • RegCenter
  • Register
  • Register2
  • RegisterCheckUsername
  • registerMember
  • registerSMStats
  • reloadSettings
  • RemindMe
  • RemindPick
  • remove_dir
  • remove_integration_function
  • remove_theme
  • RemoveAllAttachments
  • RemoveAttachment
  • RemoveAttachmentByAge
  • RemoveAttachmentBySize
  • removeBanGroups
  • removeBanLogs
  • removeBanTriggers
  • removeDeleteConcurrence
  • removeEvent
  • removeHolidays
  • removeIllegalBBCHtmlPermission
  • removeMembersFromGroups
  • removeMessage
  • removeMessages
  • RemoveOldTopics2
  • RemovePoll
  • removeSubscription
  • RemoveTheme
  • RemoveTopic2
  • removeTopics
  • reorderBoards
  • RepairAttachments
  • RepairBoards
  • replaceEntities__callback
  • ReportDetails
  • ReportedContent
  • ReportedMembers
  • ReportMessage
  • reportPost
  • ReportsMain
  • ReportToModerator
  • ReportToModerator2
  • reportUser
  • RequestMembers
  • resetPassword
  • resizeImage
  • resizeImageFile
  • RestoreTopic
  • RetrievePreview
  • safe_file_write
  • safe_serialize
  • safe_unserialize
  • sanitize_iri
  • sanitizeMSCutPaste
  • saveDBSettings
  • SaveDraft
  • saveModComment
  • SavePMDraft
  • saveProfileChanges
  • saveProfileFields
  • saveSettings
  • saveTriggers
  • scheduled_birthdayemails
  • scheduled_daily_digest
  • scheduled_daily_maintenance
  • scheduled_fetchSMfiles
  • scheduled_paid_subscriptions
  • scheduled_remove_old_drafts
  • scheduled_remove_temp_attachments
  • scheduled_remove_topic_redirect
  • scheduled_weekly_digest
  • scheduled_weekly_maintenance
  • ScheduledTasks
  • SearchEngines
  • SearchMembers
  • searchSort
  • SecretAnswer2
  • SecretAnswerInput
  • secureDirectory
  • SelectMailingMembers
  • send_http_status
  • SendActivation
  • sendmail
  • SendMailing
  • sendNotifications
  • sendpm
  • sentence_list
  • serialize_to_json
  • sessionClose
  • sessionDestroy
  • sessionGC
  • sessionOpen
  • sessionRead
  • sessionWrite
  • set_alert_icon
  • set_avatar_data
  • set_fatal_error_headers
  • set_tld_regex
  • SetCensor
  • setEventStartEnd
  • SetJavaScript
  • setKeys
  • setLoginCookie
  • setMemoryLimit
  • setNotifyPrefs
  • setPassword
  • setPassword2
  • SetQuickGroups
  • SetReserved
  • setSqlMode
  • setTFACookie
  • SetThemeOptions
  • SetThemeSettings
  • setup_fatal_error_context
  • setupMenuContext
  • setupProfileContext
  • setupThemeContext
  • sha1_core
  • sha1_ft
  • sha1_kt
  • sha1_raw
  • sha1_rol
  • sha1_smf
  • shorten_subject
  • ShowAdminHelp
  • showAlerts
  • showAttachment
  • showAttachments
  • ShowClosedReports
  • showCodeImage
  • ShowCustomProfiles
  • ShowDrafts
  • ShowHelp
  • showLetterImage
  • ShowNotice
  • showPermissions
  • ShowPHPinfoSettings
  • showPMDrafts
  • showPosts
  • showProfileDrafts
  • ShowReports
  • showUnwatched
  • ShowXmlFeed
  • sig_preview
  • smf_chmod
  • smf_crc32
  • smf_db_add_column
  • smf_db_add_index
  • smf_db_affected_rows
  • smf_db_allow_persistent
  • smf_db_backup_table
  • smf_db_calculate_type
  • smf_db_change_column
  • smf_db_create_query_column
  • smf_db_create_table
  • smf_db_create_word_search
  • smf_db_cte_support
  • smf_db_custom_order
  • smf_db_drop_table
  • smf_db_error
  • smf_db_error_backtrace
  • smf_db_error_insert
  • smf_db_escape_string
  • smf_db_escape_wildcard_string
  • smf_db_fetch_all
  • smf_db_get_server_info
  • smf_db_get_vendor
  • smf_db_get_version
  • smf_db_initiate
  • smf_db_insert
  • smf_db_insert_id
  • smf_db_list_columns
  • smf_db_list_indexes
  • smf_db_list_tables
  • smf_db_native_replace
  • smf_db_optimize_table
  • smf_db_query
  • smf_db_quote
  • smf_db_remove_column
  • smf_db_remove_index
  • smf_db_replacement__callback
  • smf_db_search_language
  • smf_db_search_query
  • smf_db_search_support
  • smf_db_select
  • smf_db_select_db
  • smf_db_table_sql
  • smf_db_table_structure
  • smf_db_transaction
  • smf_db_version
  • smf_error_handler
  • smf_error_handler_cron
  • smf_is_resource
  • smf_json_decode
  • smf_list_timezones
  • smf_main
  • smf_mysql_fetch_assoc
  • smf_mysql_fetch_row
  • smf_mysql_free_result
  • smf_mysql_insert_id
  • smf_mysql_num_rows
  • smf_mysql_real_escape_string
  • smf_seed_generator
  • smf_serverResponse
  • smf_setcookie
  • smf_strtolower
  • smf_var_export
  • SMStats
  • sortBoards
  • sortCategories
  • spamProtection
  • spell_check
  • spell_init
  • spell_suggest
  • SpellCheck
  • SpiderCheck
  • SpiderLogs
  • SpiderStats
  • SplitExecute
  • SplitIndex
  • SplitSelectionExecute
  • SplitSelectTopics
  • splitTopic
  • SplitTopics
  • ssi_boardNews
  • ssi_boardStats
  • ssi_checkPassword
  • ssi_copyright
  • ssi_fetchGroupMembers
  • ssi_fetchMember
  • ssi_fetchPosts
  • ssi_full_version
  • ssi_latestMember
  • ssi_login
  • ssi_logOnline
  • ssi_logout
  • ssi_menubar
  • ssi_news
  • ssi_pollVote
  • ssi_queryMembers
  • ssi_queryPosts
  • ssi_quickSearch
  • ssi_randomMember
  • ssi_recentAttachments
  • ssi_recentEvents
  • ssi_recentPoll
  • ssi_recentPosts
  • ssi_recentTopics
  • ssi_showPoll
  • ssi_shutdown
  • ssi_software_year
  • ssi_todaysBirthdays
  • ssi_todaysCalendar
  • ssi_todaysEvents
  • ssi_todaysHolidays
  • ssi_topBoards
  • ssi_topPoll
  • ssi_topPoster
  • ssi_topTopics
  • ssi_topTopicsReplies
  • ssi_topTopicsViews
  • ssi_version
  • ssi_welcome
  • ssi_whosOnline
  • ssl_cert_found
  • StaffReport
  • statPanel
  • Sticky
  • strip_php_comments
  • stripslashes__recursive
  • subscriptions
  • summary
  • TaskLog
  • TaskSettings
  • template_action_permissions
  • template_add_edit_group_boards_list
  • template_add_language
  • template_add_rule
  • template_additional_rows
  • template_addsmiley
  • template_admin
  • template_admin_account
  • template_admin_browse
  • template_admin_login
  • template_admin_quick_search
  • template_admin_register
  • template_admin_search_results
  • template_after
  • template_alert_configuration
  • template_alert_notifications_boards
  • template_alert_notifications_topics
  • template_alerts_all_read
  • template_alerts_popup
  • template_announce
  • template_announcement_send
  • template_ask
  • template_ask_delete
  • template_attachment_errors
  • template_attachment_paths
  • template_attachment_repair
  • template_avatar_settings_above
  • template_avatar_settings_below
  • template_backup_database
  • template_backup_xml
  • template_ban_edit
  • template_ban_edit_trigger
  • template_bcd
  • template_bi_board_children
  • template_bi_board_icon
  • template_bi_board_info
  • template_bi_board_lastpost
  • template_bi_board_stats
  • template_bi_redirect_icon
  • template_bi_redirect_stats
  • template_boardindex_outer_above
  • template_boardindex_outer_below
  • template_body_above
  • template_body_below
  • template_browse
  • template_button_strip
  • template_by_board
  • template_calendar_top
  • template_callback_question_answer_list
  • template_check_username
  • template_chmod
  • template_chmod_files
  • template_choose_payment
  • template_clean_cache_button_above
  • template_clean_cache_button_below
  • template_confirm_board_delete
  • template_confirm_category_delete
  • template_control_chmod
  • template_control_richedit
  • template_control_richedit_buttons
  • template_control_verification
  • template_convert_entities
  • template_convert_msgbody
  • template_convert_utf8
  • template_convert_xml
  • template_coppa
  • template_coppa_form
  • template_copy_template
  • template_create_index
  • template_create_index_done
  • template_create_index_progress
  • template_create_list_menu
  • template_credits
  • template_css
  • template_database_changes
  • template_database_settings
  • template_database_xml
  • template_delete_install
  • template_delete_subscription
  • template_deleteAccount
  • template_download_language
  • template_downloaded
  • template_edit_agreement
  • template_edit_browse
  • template_edit_censored
  • template_edit_comment
  • template_edit_file
  • template_edit_group
  • template_edit_holiday
  • template_edit_list
  • template_edit_options
  • template_edit_profile_field
  • template_edit_profiles
  • template_edit_reserved_words
  • template_edit_scheduled_tasks
  • template_edit_style
  • template_edit_template
  • template_editBuddies
  • template_editicon
  • template_editicons
  • template_editIgnoreList
  • template_editsets
  • template_email_members
  • template_email_members_compose
  • template_email_members_send
  • template_error_log
  • template_error_message
  • template_event_post
  • template_examine
  • template_extract_package
  • template_fatal_error
  • template_file_permissions
  • template_find_members
  • template_folder
  • template_footer
  • template_forum_settings
  • template_ftp_required
  • template_generic
  • template_generic_menu
  • template_generic_menu_dropdown_above
  • template_generic_menu_dropdown_below
  • template_generic_menu_tabs
  • template_generic_xml
  • template_generic_xml_recursive
  • template_group_members
  • template_group_request_reason
  • template_group_requests_block
  • template_groupMembership
  • template_header
  • template_hms
  • template_homepage_sample1
  • template_homepage_sample1_html
  • template_homepage_sample1_php
  • template_html_above
  • template_html_below
  • template_ic_block_calendar
  • template_ic_block_online
  • template_ic_block_recent
  • template_ic_block_stats
  • template_ignoreboards
  • template_include
  • template_info_center
  • template_init
  • template_inline_permissions
  • template_install_above
  • template_install_below
  • template_install_options
  • template_installed
  • template_issueWarning
  • template_javascript
  • template_jump_to
  • template_kick_guest
  • template_labels
  • template_like
  • template_list
  • template_list_themes
  • template_load_warning_variables
  • template_login
  • template_login_tfa
  • template_mailtest
  • template_main
  • template_maint_warning_above
  • template_maint_warning_below
  • template_maintain_database
  • template_maintain_members
  • template_maintain_routine
  • template_maintain_topics
  • template_maintenance
  • template_manual
  • template_max_size
  • template_menu
  • template_merge
  • template_merge_done
  • template_merge_extra_options
  • template_message_icons
  • template_moderation_center
  • template_moderation_settings
  • template_modify_board
  • template_modify_category
  • template_modify_group
  • template_modify_group_display
  • template_modify_language_entries
  • template_modify_subscription
  • template_modify_user_subscription
  • template_modify_weights
  • template_modifydone
  • template_modifyfast
  • template_modifyset
  • template_modifysmiley
  • template_modifytopicdone
  • template_move
  • template_new_group
  • template_news_lists
  • template_newsfader
  • template_not_done
  • template_notes
  • template_notify_board
  • template_omfg
  • template_optimize
  • template_options
  • template_package_confirm
  • template_package_list
  • template_paid_done
  • template_permission_index
  • template_permission_show_contents
  • template_php_info
  • template_pick
  • template_pm
  • template_pm_above
  • template_pm_below
  • template_pm_popup
  • template_populate_database
  • template_popup
  • template_post
  • template_post_header
  • template_postmod_permissions
  • template_print
  • template_print_above
  • template_print_below
  • template_print_options
  • template_profile_above
  • template_profile_avatar_select
  • template_profile_below
  • template_profile_birthdate
  • template_profile_group_manage
  • template_profile_pm_settings
  • template_profile_popup
  • template_profile_save
  • template_profile_signature_modify
  • template_profile_smiley_pick
  • template_profile_tfa
  • template_profile_theme_pick
  • template_profile_theme_settings
  • template_profile_timeformat_modify
  • template_prune
  • template_quickbuttons
  • template_quickreply
  • template_quotefast
  • template_recent
  • template_redirect_options
  • template_registration_agreement
  • template_registration_form
  • template_reminder_pick
  • template_repair_boards
  • template_replies
  • template_report_message
  • template_report_message_complete
  • template_report_type
  • template_reported_members
  • template_reported_members_block
  • template_reported_posts
  • template_reported_posts_block
  • template_reported_users_block
  • template_resend
  • template_reset_list
  • template_results
  • template_retry_activate
  • template_rules
  • template_search
  • template_search_members
  • template_search_results
  • template_select
  • template_select_search_method
  • template_send
  • template_sendbody
  • template_sent
  • template_serialize_json
  • template_serialize_json_xml
  • template_servers
  • template_set_options
  • template_set_password
  • template_set_settings
  • template_setorder
  • template_settings
  • template_show_backtrace
  • template_show_custom_profile
  • template_show_file
  • template_show_list
  • template_show_month_grid
  • template_show_notice
  • template_show_settings
  • template_show_spider_logs
  • template_show_spider_stats
  • template_show_upcoming_list
  • template_show_week_grid
  • template_showAlerts
  • template_showDrafts
  • template_showPermissions
  • template_showPMDrafts
  • template_showPosts
  • template_single_pm
  • template_single_post
  • template_spellcheck
  • template_spider_edit
  • template_split
  • template_ssi_above
  • template_ssi_below
  • template_statPanel
  • template_stats
  • template_subject_list
  • template_summary
  • template_terms
  • template_tfadisable
  • template_tfasetup
  • template_tfasetup_backup
  • template_thetime
  • template_topic_legend
  • template_trackActivity
  • template_trackIP
  • template_unapproved_posts
  • template_unread
  • template_upgrade_above
  • template_upgrade_below
  • template_upgrade_complete
  • template_upgrade_options
  • template_user_subscription
  • template_user_watch_post_callback
  • template_verification_sound
  • template_view_operations
  • template_view_package
  • template_view_scheduled_tasks
  • template_view_versions
  • template_viewmemberreport
  • template_viewmodreport
  • template_viewWarning
  • template_warn_template
  • template_warning
  • template_warning_divs
  • template_watched_users
  • template_welcome_message
  • template_xml_above
  • template_xml_below
  • TestMailSend
  • text2words
  • textfield_alter
  • tfadisable
  • tfasetup
  • theme
  • theme_copyright
  • theme_inline_permissions
  • theme_install
  • theme_linktree
  • ThemeAdmin
  • ThemeInstall
  • ThemeList
  • ThemesMain
  • throw_error
  • time_since
  • timeformat
  • TopicNotify
  • trackActivity
  • trackEdits
  • trackGroupReq
  • tracking
  • TrackIP
  • TrackLogins
  • trackStats
  • trackStatsUsersOnline
  • TransferAttachments
  • truncate_array
  • un_htmlspecialchars
  • un_preparsecode
  • UnapprovedAttachments
  • UnapprovedPosts
  • unescapestring__recursive
  • UnreadTopics
  • updateAdminPreferences
  • updateBanGroup
  • updateBanMembers
  • updateBoardManagers
  • updateChildPermissions
  • updateDbLastError
  • updateLastMessages
  • updateMemberData
  • updateReport
  • updateSettings
  • updateSettingsFile
  • updateStats
  • updateTriggers
  • upgrade_clean_cache
  • upgrade_query
  • upgradeExit
  • upgradeGetColumnInfo
  • UpgradeOptions
  • url_exists
  • url_image_size
  • url_parts
  • url_to_iri
  • urldecode__recursive
  • user_info_callback
  • utf8_strtolower
  • utf8_strtoupper
  • validate_iri
  • validateEventPost
  • validatePassword
  • validatePasswordFlood
  • validateSession
  • validateToken
  • validateTriggers
  • validateUsername
  • VerificationCode
  • VersionDetail
  • ViewBacktrace
  • ViewErrorLog
  • ViewFile
  • ViewMemberlist
  • ViewMembers
  • ViewModlog
  • ViewOperations
  • ViewQuery
  • ViewSpiders
  • ViewSubscribedUsers
  • ViewSubscriptions
  • viewWarning
  • ViewWarningLog
  • ViewWarnings
  • ViewWarningTemplates
  • ViewWatchedUsers
  • Vote
  • warning_preview
  • Welcome
  • WelcomeLogin
  • Who
  • WrapAction
  • writeLog
  • XmlDraft
  • XMLhttpMain
  • Overview
  • Namespace
  • Class
   1:    2:    3:    4:    5:    6:    7:    8:    9:   10:   11:   12:   13:   14:   15:   16:   17:   18:   19:   20:   21:   22:   23:   24:   25:   26:   27:   28:   29:   30:   31:   32:   33:   34:   35:   36:   37:   38:   39:   40:   41:   42:   43:   44:   45:   46:   47:   48:   49:   50:   51:   52:   53:   54:   55:   56:   57:   58:   59:   60:   61:   62:   63:   64:   65:   66:   67:   68:   69:   70:   71:   72:   73:   74:   75:   76:   77:   78:   79:   80:   81:   82:   83:   84:   85:   86:   87:   88:   89:   90:   91:   92:   93:   94:   95:   96:   97:   98:   99:  100:  101:  102:  103:  104:  105:  106:  107:  108:  109:  110:  111:  112:  113:  114:  115:  116:  117:  118:  119:  120:  121:  122:  123:  124:  125:  126:  127:  128:  129:  130:  131:  132:  133:  134:  135:  136:  137:  138:  139:  140:  141:  142:  143:  144:  145:  146:  147:  148:  149:  150:  151:  152:  153:  154:  155:  156:  157:  158:  159:  160:  161:  162:  163:  164:  165:  166:  167:  168:  169:  170:  171:  172:  173:  174:  175:  176:  177:  178:  179:  180:  181:  182:  183:  184:  185:  186:  187:  188:  189:  190:  191:  192:  193:  194:  195:  196:  197:  198:  199:  200:  201:  202:  203:  204:  205:  206:  207:  208:  209:  210:  211:  212:  213:  214:  215:  216:  217:  218:  219:  220:  221:  222:  223:  224:  225:  226:  227:  228:  229:  230:  231:  232:  233:  234:  235:  236:  237:  238:  239:  240:  241:  242:  243:  244:  245:  246:  247:  248:  249:  250:  251:  252:  253:  254:  255:  256:  257:  258:  259:  260:  261:  262:  263:  264:  265:  266:  267:  268:  269:  270:  271:  272:  273:  274:  275:  276:  277:  278:  279:  280:  281:  282:  283:  284:  285:  286:  287:  288:  289:  290:  291:  292:  293:  294:  295:  296:  297:  298:  299:  300:  301:  302:  303:  304:  305:  306:  307:  308:  309:  310:  311:  312:  313:  314:  315:  316:  317:  318:  319:  320:  321:  322:  323:  324:  325:  326:  327:  328:  329:  330:  331:  332:  333:  334:  335:  336:  337:  338:  339:  340:  341:  342:  343:  344:  345:  346:  347:  348:  349:  350:  351:  352:  353:  354:  355:  356:  357:  358:  359:  360:  361:  362:  363:  364:  365:  366:  367:  368:  369:  370:  371:  372:  373:  374:  375:  376:  377:  378:  379:  380:  381:  382:  383:  384:  385:  386:  387:  388:  389:  390:  391:  392:  393:  394:  395:  396:  397:  398:  399:  400:  401:  402:  403:  404:  405:  406:  407:  408:  409:  410:  411:  412:  413:  414:  415:  416:  417:  418:  419:  420:  421:  422:  423:  424:  425:  426:  427:  428:  429:  430:  431:  432:  433:  434:  435:  436:  437:  438:  439:  440:  441:  442:  443:  444:  445:  446:  447:  448:  449:  450:  451:  452:  453:  454:  455:  456:  457:  458:  459:  460:  461:  462:  463:  464:  465:  466:  467:  468:  469:  470:  471:  472:  473:  474:  475:  476:  477:  478:  479:  480:  481:  482:  483:  484:  485:  486:  487:  488:  489:  490:  491:  492:  493:  494:  495:  496:  497:  498:  499:  500:  501:  502:  503:  504:  505:  506:  507:  508:  509:  510:  511:  512:  513:  514:  515:  516:  517:  518:  519:  520:  521:  522:  523:  524:  525:  526:  527:  528:  529:  530:  531:  532:  533:  534:  535:  536:  537:  538:  539:  540:  541:  542:  543:  544:  545:  546:  547:  548:  549:  550:  551:  552:  553:  554:  555:  556:  557:  558:  559:  560:  561:  562:  563:  564:  565:  566:  567:  568:  569:  570:  571:  572:  573:  574:  575:  576:  577:  578:  579:  580:  581:  582:  583:  584:  585:  586:  587:  588:  589:  590:  591:  592:  593:  594:  595:  596:  597:  598:  599:  600:  601:  602:  603:  604:  605:  606:  607:  608:  609:  610:  611:  612:  613:  614:  615:  616:  617:  618:  619:  620:  621:  622:  623:  624:  625:  626:  627:  628:  629:  630:  631:  632:  633:  634:  635:  636:  637:  638:  639:  640:  641:  642:  643:  644:  645:  646:  647:  648:  649:  650:  651:  652:  653:  654:  655:  656:  657:  658:  659:  660:  661:  662:  663:  664:  665:  666:  667:  668:  669:  670:  671:  672:  673:  674:  675:  676:  677:  678:  679:  680:  681:  682:  683:  684:  685:  686:  687:  688:  689:  690:  691:  692:  693:  694:  695:  696:  697:  698:  699:  700:  701:  702:  703:  704:  705:  706:  707:  708:  709:  710:  711:  712:  713:  714:  715:  716:  717:  718:  719:  720:  721:  722:  723:  724:  725:  726:  727:  728:  729:  730:  731:  732:  733:  734:  735:  736:  737:  738:  739:  740:  741:  742:  743:  744:  745:  746:  747:  748:  749:  750:  751:  752:  753:  754:  755:  756:  757:  758:  759:  760:  761:  762:  763:  764:  765:  766:  767:  768:  769:  770:  771:  772:  773:  774:  775:  776:  777:  778:  779:  780:  781:  782:  783:  784:  785:  786:  787:  788:  789:  790:  791:  792:  793:  794:  795:  796:  797:  798:  799:  800:  801:  802:  803:  804:  805:  806:  807:  808:  809:  810:  811:  812:  813:  814:  815:  816:  817:  818:  819:  820:  821:  822:  823:  824:  825:  826:  827:  828:  829:  830:  831:  832:  833:  834:  835:  836:  837:  838:  839:  840:  841:  842:  843:  844:  845:  846:  847:  848:  849:  850:  851:  852:  853:  854:  855:  856:  857:  858:  859:  860:  861:  862:  863:  864:  865:  866:  867:  868:  869:  870:  871:  872:  873:  874:  875:  876:  877:  878:  879:  880:  881:  882:  883:  884:  885:  886:  887:  888:  889:  890:  891:  892:  893:  894:  895:  896:  897:  898:  899:  900:  901:  902:  903:  904:  905:  906:  907:  908:  909:  910:  911:  912:  913:  914:  915:  916:  917:  918:  919:  920:  921:  922:  923:  924:  925:  926:  927:  928:  929:  930:  931:  932:  933:  934:  935:  936:  937:  938:  939:  940:  941:  942:  943:  944:  945:  946:  947:  948:  949:  950:  951:  952:  953:  954:  955:  956:  957:  958:  959:  960:  961:  962:  963:  964:  965:  966:  967:  968:  969:  970:  971:  972:  973:  974:  975:  976:  977:  978:  979:  980:  981:  982:  983:  984:  985:  986:  987:  988:  989:  990:  991:  992:  993:  994:  995:  996:  997:  998:  999: 1000: 1001: 1002: 1003: 1004: 1005: 1006: 1007: 1008: 1009: 1010: 1011: 1012: 1013: 1014: 1015: 1016: 1017: 1018: 1019: 1020: 1021: 1022: 1023: 1024: 1025: 1026: 1027: 1028: 1029: 1030: 1031: 1032: 1033: 1034: 1035: 1036: 1037: 1038: 1039: 1040: 1041: 1042: 1043: 1044: 1045: 1046: 1047: 1048: 1049: 1050: 1051: 1052: 1053: 1054: 1055: 1056: 1057: 1058: 1059: 1060: 1061: 1062: 1063: 1064: 1065: 1066: 1067: 1068: 1069: 1070: 1071: 1072: 1073: 1074: 1075: 1076: 1077: 1078: 1079: 1080: 1081: 1082: 1083: 1084: 1085: 1086: 1087: 1088: 1089: 1090: 1091: 1092: 1093: 1094: 1095: 1096: 1097: 1098: 1099: 1100: 1101: 1102: 1103: 1104: 1105: 1106: 1107: 1108: 1109: 1110: 1111: 1112: 1113: 1114: 1115: 1116: 1117: 1118: 1119: 1120: 1121: 1122: 1123: 1124: 1125: 1126: 1127: 1128: 1129: 1130: 1131: 1132: 1133: 1134: 1135: 1136: 1137: 1138: 1139: 1140: 1141: 1142: 1143: 1144: 1145: 1146: 1147: 1148: 1149: 1150: 1151: 1152: 1153: 1154: 1155: 1156: 1157: 1158: 1159: 1160: 1161: 1162: 1163: 1164: 1165: 1166: 1167: 1168: 1169: 1170: 1171: 1172: 1173: 1174: 1175: 1176: 1177: 1178: 1179: 1180: 1181: 1182: 1183: 1184: 1185: 1186: 1187: 1188: 1189: 1190: 1191: 1192: 1193: 1194: 1195: 1196: 1197: 1198: 1199: 1200: 1201: 1202: 1203: 1204: 1205: 1206: 1207: 1208: 1209: 1210: 1211: 1212: 1213: 1214: 1215: 1216: 1217: 1218: 1219: 1220: 1221: 1222: 1223: 1224: 1225: 1226: 1227: 1228: 1229: 1230: 1231: 1232: 1233: 1234: 1235: 1236: 1237: 1238: 1239: 1240: 1241: 1242: 1243: 1244: 1245: 1246: 1247: 1248: 1249: 1250: 1251: 1252: 1253: 1254: 1255: 1256: 1257: 1258: 1259: 1260: 1261: 1262: 1263: 1264: 1265: 1266: 1267: 1268: 1269: 1270: 1271: 1272: 1273: 1274: 1275: 1276: 1277: 1278: 1279: 1280: 1281: 1282: 1283: 1284: 1285: 1286: 1287: 1288: 1289: 1290: 1291: 1292: 1293: 1294: 1295: 1296: 1297: 1298: 1299: 1300: 1301: 1302: 1303: 1304: 1305: 1306: 1307: 1308: 1309: 1310: 1311: 1312: 1313: 1314: 1315: 1316: 1317: 1318: 1319: 1320: 1321: 1322: 1323: 1324: 1325: 1326: 1327: 1328: 1329: 1330: 1331: 1332: 1333: 1334: 1335: 1336: 1337: 1338: 1339: 1340: 1341: 1342: 1343: 1344: 1345: 1346: 1347: 1348: 1349: 1350: 1351: 1352: 1353: 1354: 1355: 1356: 1357: 1358: 1359: 1360: 1361: 1362: 1363: 1364: 1365: 1366: 1367: 1368: 1369: 1370: 1371: 1372: 1373: 1374: 1375: 1376: 1377: 1378: 1379: 1380: 1381: 1382: 1383: 1384: 1385: 1386: 1387: 1388: 1389: 1390: 1391: 1392: 1393: 1394: 1395: 1396: 1397: 1398: 1399: 1400: 1401: 1402: 1403: 1404: 1405: 1406: 1407: 1408: 1409: 1410: 1411: 1412: 1413: 1414: 1415: 1416: 1417: 1418: 1419: 1420: 1421: 1422: 1423: 1424: 1425: 1426: 1427: 1428: 1429: 1430: 1431: 1432: 1433: 1434: 1435: 1436: 1437: 1438: 1439: 1440: 1441: 1442: 1443: 1444: 1445: 1446: 1447: 1448: 1449: 1450: 1451: 1452: 1453: 1454: 1455: 1456: 1457: 1458: 1459: 1460: 1461: 1462: 1463: 1464: 1465: 1466: 1467: 1468: 1469: 1470: 1471: 1472: 1473: 1474: 1475: 1476: 1477: 1478: 1479: 1480: 1481: 1482: 1483: 1484: 1485: 1486: 1487: 1488: 1489: 1490: 1491: 1492: 1493: 1494: 1495: 1496: 1497: 1498: 1499: 1500: 1501: 1502: 1503: 1504: 1505: 1506: 1507: 1508: 1509: 1510: 1511: 1512: 1513: 1514: 1515: 1516: 1517: 1518: 1519: 1520: 1521: 1522: 1523: 1524: 1525: 1526: 1527: 1528: 1529: 1530: 1531: 1532: 1533: 1534: 1535: 1536: 1537: 1538: 1539: 1540: 1541: 1542: 1543: 1544: 1545: 1546: 1547: 1548: 1549: 1550: 1551: 1552: 1553: 1554: 1555: 1556: 1557: 1558: 1559: 1560: 1561: 1562: 1563: 1564: 1565: 1566: 1567: 1568: 1569: 1570: 1571: 1572: 1573: 1574: 1575: 1576: 1577: 1578: 1579: 1580: 1581: 1582: 1583: 1584: 1585: 1586: 1587: 1588: 1589: 1590: 1591: 1592: 1593: 1594: 1595: 1596: 1597: 1598: 1599: 1600: 1601: 1602: 1603: 1604: 1605: 1606: 1607: 1608: 1609: 1610: 1611: 1612: 1613: 1614: 1615: 1616: 1617: 1618: 1619: 1620: 1621: 1622: 1623: 1624: 1625: 1626: 1627: 1628: 1629: 1630: 1631: 1632: 1633: 1634: 1635: 1636: 1637: 1638: 1639: 1640: 1641: 1642: 1643: 1644: 1645: 1646: 1647: 1648: 1649: 1650: 1651: 1652: 1653: 1654: 1655: 1656: 1657: 1658: 1659: 1660: 1661: 1662: 1663: 1664: 1665: 1666: 1667: 1668: 1669: 1670: 1671: 1672: 1673: 1674: 1675: 1676: 1677: 1678: 1679: 1680: 1681: 1682: 1683: 1684: 1685: 1686: 1687: 1688: 1689: 1690: 1691: 1692: 1693: 1694: 1695: 1696: 1697: 1698: 1699: 1700: 1701: 1702: 1703: 1704: 1705: 1706: 1707: 1708: 1709: 1710: 1711: 1712: 1713: 1714: 1715: 1716: 1717: 1718: 1719: 1720: 1721: 1722: 1723: 1724: 1725: 1726: 1727: 1728: 1729: 1730: 1731: 1732: 1733: 1734: 1735: 1736: 1737: 1738: 1739: 1740: 1741: 1742: 1743: 1744: 1745: 1746: 1747: 1748: 1749: 1750: 1751: 1752: 1753: 1754: 
<?php

/**
 * This file handles the administration of languages tasks.
 *
 * Simple Machines Forum (SMF)
 *
 * @package SMF
 * @author Simple Machines https://www.simplemachines.org
 * @copyright 2020 Simple Machines and individual contributors
 * @license https://www.simplemachines.org/about/smf/license.php BSD
 *
 * @version 2.1 RC2
 */

if (!defined('SMF'))
    die('No direct access...');

/**
 * This is the main function for the languages area.
 * It dispatches the requests.
 * Loads the ManageLanguages template. (sub-actions will use it)
 *
 * @todo lazy loading.
 *
 * @uses ManageSettings language file
 */
function ManageLanguages()
{
    global $context, $txt;

    loadTemplate('ManageLanguages');
    loadLanguage('ManageSettings');

    $context['page_title'] = $txt['edit_languages'];
    $context['sub_template'] = 'show_settings';

    $subActions = array(
        'edit' => 'ModifyLanguages',
        'add' => 'AddLanguage',
        'settings' => 'ModifyLanguageSettings',
        'downloadlang' => 'DownloadLanguage',
        'editlang' => 'ModifyLanguage',
    );

    // By default we're managing languages.
    $_REQUEST['sa'] = isset($_REQUEST['sa']) && isset($subActions[$_REQUEST['sa']]) ? $_REQUEST['sa'] : 'edit';
    $context['sub_action'] = $_REQUEST['sa'];

    // Load up all the tabs...
    $context[$context['admin_menu_name']]['tab_data'] = array(
        'title' => $txt['language_configuration'],
        'description' => $txt['language_description'],
    );

    call_integration_hook('integrate_manage_languages', array(&$subActions));

    // Call the right function for this sub-action.
    call_helper($subActions[$_REQUEST['sa']]);
}

/**
 * Interface for adding a new language
 *
 * @uses ManageLanguages template, add_language sub-template.
 */
function AddLanguage()
{
    global $context, $sourcedir, $txt, $smcFunc;

    // Are we searching for new languages courtesy of Simple Machines?
    if (!empty($_POST['smf_add_sub']))
    {
        $context['smf_search_term'] = $smcFunc['htmlspecialchars'](trim($_POST['smf_add']));

        $listOptions = array(
            'id' => 'smf_languages',
            'get_items' => array(
                'function' => 'list_getLanguagesList',
            ),
            'columns' => array(
                'name' => array(
                    'header' => array(
                        'value' => $txt['name'],
                    ),
                    'data' => array(
                        'db' => 'name',
                    ),
                ),
                'description' => array(
                    'header' => array(
                        'value' => $txt['add_language_smf_desc'],
                    ),
                    'data' => array(
                        'db' => 'description',
                    ),
                ),
                'version' => array(
                    'header' => array(
                        'value' => $txt['add_language_smf_version'],
                    ),
                    'data' => array(
                        'db' => 'version',
                    ),
                ),
                'utf8' => array(
                    'header' => array(
                        'value' => $txt['add_language_smf_utf8'],
                    ),
                    'data' => array(
                        'db' => 'utf8',
                    ),
                ),
                'install_link' => array(
                    'header' => array(
                        'value' => $txt['add_language_smf_install'],
                        'class' => 'centercol',
                    ),
                    'data' => array(
                        'db' => 'install_link',
                        'class' => 'centercol',
                    ),
                ),
            ),
        );

        require_once($sourcedir . '/Subs-List.php');
        createList($listOptions);

        $context['default_list'] = 'smf_languages';
    }

    $context['sub_template'] = 'add_language';
}

/**
 * Gets a list of available languages from the mother ship
 * Will return a subset if searching, otherwise all avaialble
 *
 * @return array An array containing information about each available language
 */
function list_getLanguagesList()
{
    global $context, $sourcedir, $smcFunc, $txt, $scripturl;

    // We're going to use this URL.
    $url = 'https://download.simplemachines.org/fetch_language.php?version=' . urlencode(SMF_VERSION);

    // Load the class file and stick it into an array.
    require_once($sourcedir . '/Class-Package.php');
    $language_list = new xmlArray(fetch_web_data($url), true);

    // Check that the site responded and that the language exists.
    if (!$language_list->exists('languages'))
        $context['smf_error'] = 'no_response';
    elseif (!$language_list->exists('languages/language'))
        $context['smf_error'] = 'no_files';
    else
    {
        $language_list = $language_list->path('languages[0]');
        $lang_files = $language_list->set('language');
        $smf_languages = array();
        foreach ($lang_files as $file)
        {
            // Were we searching?
            if (!empty($context['smf_search_term']) && strpos($file->fetch('name'), $smcFunc['strtolower']($context['smf_search_term'])) === false)
                continue;

            $smf_languages[] = array(
                'id' => $file->fetch('id'),
                'name' => $smcFunc['ucwords']($file->fetch('name')),
                'version' => $file->fetch('version'),
                'utf8' => $txt['yes'],
                'description' => $file->fetch('description'),
                'install_link' => '<a href="' . $scripturl . '?action=admin;area=languages;sa=downloadlang;did=' . $file->fetch('id') . ';' . $context['session_var'] . '=' . $context['session_id'] . '">' . $txt['add_language_smf_install'] . '</a>',
            );
        }
        if (empty($smf_languages))
            $context['smf_error'] = 'no_files';
        else
            return $smf_languages;
    }
}

/**
 * Download a language file from the Simple Machines website.
 * Requires a valid download ID ("did") in the URL.
 * Also handles installing language files.
 * Attempts to chmod things as needed.
 * Uses a standard list to display information about all the files and where they'll be put.
 *
 * @uses ManageLanguages template, download_language sub-template.
 * @uses Admin template, show_list sub-template.
 */
function DownloadLanguage()
{
    global $context, $sourcedir, $boarddir, $txt, $scripturl, $modSettings, $cache_enable;

    loadLanguage('ManageSettings');
    require_once($sourcedir . '/Subs-Package.php');

    // Clearly we need to know what to request.
    if (!isset($_GET['did']))
        fatal_lang_error('no_access', false);

    // Some lovely context.
    $context['download_id'] = $_GET['did'];
    $context['sub_template'] = 'download_language';
    $context['menu_data_' . $context['admin_menu_id']]['current_subsection'] = 'add';

    // Can we actually do the installation - and do they want to?
    if (!empty($_POST['do_install']) && !empty($_POST['copy_file']))
    {
        checkSession('get');
        validateToken('admin-dlang');

        $chmod_files = array();
        $install_files = array();

        // Check writable status.
        foreach ($_POST['copy_file'] as $file)
        {
            // Check it's not very bad.
            if (strpos($file, '..') !== false || (strpos($file, 'Themes') !== 0 && !preg_match('~agreement\.[A-Za-z-_0-9]+\.txt$~', $file)))
                fatal_error($txt['languages_download_illegal_paths']);

            $chmod_files[] = $boarddir . '/' . $file;
            $install_files[] = $file;
        }

        // Call this in case we have work to do.
        $file_status = create_chmod_control($chmod_files);
        $files_left = $file_status['files']['notwritable'];

        // Something not writable?
        if (!empty($files_left))
            $context['error_message'] = $txt['languages_download_not_chmod'];
        // Otherwise, go go go!
        elseif (!empty($install_files))
        {
            read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(SMF_VERSION) . ';fetch=' . urlencode($_GET['did']), $boarddir, false, true, $install_files);

            // Make sure the files aren't stuck in the cache.
            package_flush_cache();
            $context['install_complete'] = sprintf($txt['languages_download_complete_desc'], $scripturl . '?action=admin;area=languages');

            return;
        }
    }

    // Open up the old china.
    if (!isset($archive_content))
        $archive_content = read_tgz_file('https://download.simplemachines.org/fetch_language.php?version=' . urlencode(SMF_VERSION) . ';fetch=' . urlencode($_GET['did']), null);

    if (empty($archive_content))
        fatal_error($txt['add_language_error_no_response']);

    // Now for each of the files, let's do some *stuff*
    $context['files'] = array(
        'lang' => array(),
        'other' => array(),
    );
    $context['make_writable'] = array();
    foreach ($archive_content as $file)
    {
        $pathinfo = pathinfo($file['filename']);
        $dirname = $pathinfo['dirname'];
        $basename = $pathinfo['basename'];
        $extension = $pathinfo['extension'];

        // Don't do anything with files we don't understand.
        if (!in_array($extension, array('php', 'jpg', 'gif', 'jpeg', 'png', 'txt')))
            continue;

        // Basic data.
        $context_data = array(
            'name' => $basename,
            'destination' => $boarddir . '/' . $file['filename'],
            'generaldest' => $file['filename'],
            'size' => $file['size'],
            // Does chmod status allow the copy?
            'writable' => false,
            // Should we suggest they copy this file?
            'default_copy' => true,
            // Does the file already exist, if so is it same or different?
            'exists' => false,
        );

        // Does the file exist, is it different and can we overwrite?
        if (file_exists($boarddir . '/' . $file['filename']))
        {
            if (is_writable($boarddir . '/' . $file['filename']))
                $context_data['writable'] = true;

            // Finally, do we actually think the content has changed?
            if ($file['size'] == filesize($boarddir . '/' . $file['filename']) && $file['md5'] == md5_file($boarddir . '/' . $file['filename']))
            {
                $context_data['exists'] = 'same';
                $context_data['default_copy'] = false;
            }
            // Attempt to discover newline character differences.
            elseif ($file['md5'] == md5(preg_replace("~[\r]?\n~", "\r\n", file_get_contents($boarddir . '/' . $file['filename']))))
            {
                $context_data['exists'] = 'same';
                $context_data['default_copy'] = false;
            }
            else
                $context_data['exists'] = 'different';
        }
        // No overwrite?
        else
        {
            // Can we at least stick it in the directory...
            if (is_writable($boarddir . '/' . $dirname))
                $context_data['writable'] = true;
        }

        // I love PHP files, that's why I'm a developer and not an artistic type spending my time drinking absinth and living a life of sin...
        if ($extension == 'php' && preg_match('~\w+\.\w+(?:-utf8)?\.php~', $basename))
        {
            $context_data += array(
                'version' => '??',
                'cur_version' => false,
                'version_compare' => 'newer',
            );

            list ($name, $language) = explode('.', $basename);

            // Let's get the new version, I like versions, they tell me that I'm up to date.
            if (preg_match('~\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '~i', $file['preview'], $match) == 1)
                $context_data['version'] = $match[1];

            // Now does the old file exist - if so what is it's version?
            if (file_exists($boarddir . '/' . $file['filename']))
            {
                // OK - what is the current version?
                $fp = fopen($boarddir . '/' . $file['filename'], 'rb');
                $header = fread($fp, 768);
                fclose($fp);

                // Find the version.
                if (preg_match('~(?://|/\*)\s*Version:\s+(.+?);\s*' . preg_quote($name, '~') . '(?:[\s]{2}|\*/)~i', $header, $match) == 1)
                {
                    $context_data['cur_version'] = $match[1];

                    // How does this compare?
                    if ($context_data['cur_version'] == $context_data['version'])
                        $context_data['version_compare'] = 'same';
                    elseif ($context_data['cur_version'] > $context_data['version'])
                        $context_data['version_compare'] = 'older';

                    // Don't recommend copying if the version is the same.
                    if ($context_data['version_compare'] != 'newer')
                        $context_data['default_copy'] = false;
                }
            }

            // Add the context data to the main set.
            $context['files']['lang'][] = $context_data;
        }
        elseif ($extension == 'txt' && stripos($basename, 'agreement') !== false)
        {
            $context_data += array(
                'version' => '??',
                'cur_version' => false,
                'version_compare' => 'newer',
            );

            // Registration agreement is a primary file
            $context['files']['lang'][] = $context_data;
        }
        else
        {
            // There shouldn't be anything else, but load this into "other" in case we decide to handle it in the future
            $context['files']['other'][] = $context_data;
        }

        // Collect together all non-writable areas.
        if (!$context_data['writable'])
            $context['make_writable'][] = $context_data['destination'];
    }

    // Before we go to far can we make anything writable, eh, eh?
    if (!empty($context['make_writable']))
    {
        // What is left to be made writable?
        $file_status = create_chmod_control($context['make_writable']);
        $context['still_not_writable'] = $file_status['files']['notwritable'];

        // Mark those which are now writable as such.
        foreach ($context['files'] as $type => $data)
        {
            foreach ($data as $k => $file)
            {
                if (!$file['writable'] && !in_array($file['destination'], $context['still_not_writable']))
                    $context['files'][$type][$k]['writable'] = true;
            }
        }

        // Are we going to need more language stuff?
        if (!empty($context['still_not_writable']))
            loadLanguage('Packages');
    }

    // This is the list for the main files.
    $listOptions = array(
        'id' => 'lang_main_files_list',
        'title' => $txt['languages_download_main_files'],
        'get_items' => array(
            'function' => function() use ($context)
            {
                return $context['files']['lang'];
            },
        ),
        'columns' => array(
            'name' => array(
                'header' => array(
                    'value' => $txt['languages_download_filename'],
                ),
                'data' => array(
                    'function' => function($rowData) use ($txt)
                    {
                        return '<strong>' . $rowData['name'] . '</strong><br><span class="smalltext">' . $txt['languages_download_dest'] . ': ' . $rowData['destination'] . '</span>' . ($rowData['version_compare'] == 'older' ? '<br>' . $txt['languages_download_older'] : '');
                    },
                ),
            ),
            'writable' => array(
                'header' => array(
                    'value' => $txt['languages_download_writable'],
                ),
                'data' => array(
                    'function' => function($rowData) use ($txt)
                    {
                        return '<span style="color: ' . ($rowData['writable'] ? 'green' : 'red') . ';">' . ($rowData['writable'] ? $txt['yes'] : $txt['no']) . '</span>';
                    },
                ),
            ),
            'version' => array(
                'header' => array(
                    'value' => $txt['languages_download_version'],
                ),
                'data' => array(
                    'function' => function($rowData) use ($txt)
                    {
                        return '<span style="color: ' . ($rowData['version_compare'] == 'older' ? 'red' : ($rowData['version_compare'] == 'same' ? 'orange' : 'green')) . ';">' . $rowData['version'] . '</span>';
                    },
                ),
            ),
            'exists' => array(
                'header' => array(
                    'value' => $txt['languages_download_exists'],
                ),
                'data' => array(
                    'function' => function($rowData) use ($txt)
                    {
                        return $rowData['exists'] ? ($rowData['exists'] == 'same' ? $txt['languages_download_exists_same'] : $txt['languages_download_exists_different']) : $txt['no'];
                    },
                ),
            ),
            'copy' => array(
                'header' => array(
                    'value' => $txt['languages_download_overwrite'],
                    'class' => 'centercol',
                ),
                'data' => array(
                    'function' => function($rowData)
                    {
                        return '<input type="checkbox" name="copy_file[]" value="' . $rowData['generaldest'] . '"' . ($rowData['default_copy'] ? ' checked' : '') . '>';
                    },
                    'style' => 'width: 4%;',
                    'class' => 'centercol',
                ),
            ),
        ),
    );

    // Kill the cache, as it is now invalid..
    if (!empty($cache_enable))
    {
        cache_put_data('known_languages', null, !empty($cache_enable) && $cache_enable < 1 ? 86400 : 3600);
        cache_put_data('known_languages_all', null, !empty($cache_enable) && $cache_enable < 1 ? 86400 : 3600);
    }

    require_once($sourcedir . '/Subs-List.php');
    createList($listOptions);

    $context['default_list'] = 'lang_main_files_list';
    createToken('admin-dlang');
}

/**
 * This lists all the current languages and allows editing of them.
 */
function ModifyLanguages()
{
    global $txt, $context, $scripturl, $modSettings;
    global $sourcedir, $language, $boarddir;

    // Setting a new default?
    if (!empty($_POST['set_default']) && !empty($_POST['def_language']))
    {
        checkSession();
        validateToken('admin-lang');

        getLanguages();
        $lang_exists = false;
        foreach ($context['languages'] as $lang)
        {
            if ($_POST['def_language'] == $lang['filename'])
            {
                $lang_exists = true;
                break;
            }
        }

        if ($_POST['def_language'] != $language && $lang_exists)
        {
            require_once($sourcedir . '/Subs-Admin.php');
            updateSettingsFile(array('language' => $_POST['def_language']));
            $language = $_POST['def_language'];
        }
    }

    // Create another one time token here.
    createToken('admin-lang');

    $listOptions = array(
        'id' => 'language_list',
        'items_per_page' => $modSettings['defaultMaxListItems'],
        'base_href' => $scripturl . '?action=admin;area=languages',
        'title' => $txt['edit_languages'],
        'get_items' => array(
            'function' => 'list_getLanguages',
        ),
        'get_count' => array(
            'function' => 'list_getNumLanguages',
        ),
        'columns' => array(
            'default' => array(
                'header' => array(
                    'value' => $txt['languages_default'],
                    'class' => 'centercol',
                ),
                'data' => array(
                    'function' => function($rowData)
                    {
                        return '<input type="radio" name="def_language" value="' . $rowData['id'] . '"' . ($rowData['default'] ? ' checked' : '') . ' onclick="highlightSelected(\'list_language_list_' . $rowData['id'] . '\');">';
                    },
                    'style' => 'width: 8%;',
                    'class' => 'centercol',
                ),
            ),
            'name' => array(
                'header' => array(
                    'value' => $txt['languages_lang_name'],
                ),
                'data' => array(
                    'function' => function($rowData) use ($scripturl)
                    {
                        return sprintf('<a href="%1$s?action=admin;area=languages;sa=editlang;lid=%2$s">%3$s</a>', $scripturl, $rowData['id'], $rowData['name']);
                    },
                    'class' => 'centercol',
                ),
            ),
            'character_set' => array(
                'header' => array(
                    'value' => $txt['languages_character_set'],
                ),
                'data' => array(
                    'db_htmlsafe' => 'char_set',
                    'class' => 'centercol',
                ),
            ),
            'count' => array(
                'header' => array(
                    'value' => $txt['languages_users'],
                ),
                'data' => array(
                    'db_htmlsafe' => 'count',
                    'class' => 'centercol',
                ),
            ),
            'locale' => array(
                'header' => array(
                    'value' => $txt['languages_locale'],
                ),
                'data' => array(
                    'db_htmlsafe' => 'locale',
                    'class' => 'centercol',
                ),
            ),
            'editlang' => array(
                'header' => array(
                    'value' => '',
                ),
                'data' => array(
                    'function' => function($rowData) use ($scripturl, $txt)
                    {
                        return sprintf('<a href="%1$s?action=admin;area=languages;sa=editlang;lid=%2$s" class="button">%3$s</a>', $scripturl, $rowData['id'], $txt['edit']);
                    },
                    'style' => 'width: 8%;',
                    'class' => 'centercol',
                ),
            ),
        ),
        'form' => array(
            'href' => $scripturl . '?action=admin;area=languages',
            'token' => 'admin-lang',
        ),
        'additional_rows' => array(
            array(
                'position' => 'bottom_of_list',
                'value' => '<input type="hidden" name="' . $context['session_var'] . '" value="' . $context['session_id'] . '"><input type="submit" name="set_default" value="' . $txt['save'] . '"' . (is_writable($boarddir . '/Settings.php') ? '' : ' disabled') . ' class="button">',
            ),
        ),
    );

    // We want to highlight the selected language. Need some Javascript for this.
    addInlineJavaScript('
    function highlightSelected(box)
    {
        $("tr.highlight2").removeClass("highlight2");
        $("#" + box).addClass("highlight2");
    }
    highlightSelected("list_language_list_' . ($language == '' ? 'english' : $language) . '");', true);

    // Display a warning if we cannot edit the default setting.
    if (!is_writable($boarddir . '/Settings.php'))
        $listOptions['additional_rows'][] = array(
            'position' => 'after_title',
            'value' => $txt['language_settings_writable'],
            'class' => 'smalltext alert',
        );

    require_once($sourcedir . '/Subs-List.php');
    createList($listOptions);

    $context['sub_template'] = 'show_list';
    $context['default_list'] = 'language_list';
}

/**
 * How many languages?
 * Callback for the list in ManageLanguageSettings().
 *
 * @return int The number of available languages
 */
function list_getNumLanguages()
{
    return count(getLanguages());
}

/**
 * Fetch the actual language information.
 * Callback for $listOptions['get_items']['function'] in ManageLanguageSettings.
 * Determines which languages are available by looking for the "index.{language}.php" file.
 * Also figures out how many users are using a particular language.
 *
 * @return array An array of information about currenty installed languages
 */
function list_getLanguages()
{
    global $settings, $smcFunc, $language, $context, $txt;

    $languages = array();
    // Keep our old entries.
    $old_txt = $txt;
    $backup_actual_theme_dir = $settings['actual_theme_dir'];
    $backup_base_theme_dir = !empty($settings['base_theme_dir']) ? $settings['base_theme_dir'] : '';

    // Override these for now.
    $settings['actual_theme_dir'] = $settings['base_theme_dir'] = $settings['default_theme_dir'];
    getLanguages();

    // Put them back.
    $settings['actual_theme_dir'] = $backup_actual_theme_dir;
    if (!empty($backup_base_theme_dir))
        $settings['base_theme_dir'] = $backup_base_theme_dir;
    else
        unset($settings['base_theme_dir']);

    // Get the language files and data...
    foreach ($context['languages'] as $lang)
    {
        // Load the file to get the character set.
        require($settings['default_theme_dir'] . '/languages/index.' . $lang['filename'] . '.php');

        $languages[$lang['filename']] = array(
            'id' => $lang['filename'],
            'count' => 0,
            'char_set' => $txt['lang_character_set'],
            'default' => $language == $lang['filename'] || ($language == '' && $lang['filename'] == 'english'),
            'locale' => $txt['lang_locale'],
            'name' => $smcFunc['ucwords'](strtr($lang['filename'], array('_' => ' ', '-utf8' => ''))),
        );
    }

    // Work out how many people are using each language.
    $request = $smcFunc['db_query']('', '
        SELECT lngfile, COUNT(*) AS num_users
        FROM {db_prefix}members
        GROUP BY lngfile',
        array(
        )
    );
    while ($row = $smcFunc['db_fetch_assoc']($request))
    {
        // Default?
        if (empty($row['lngfile']) || !isset($languages[$row['lngfile']]))
            $row['lngfile'] = $language;

        if (!isset($languages[$row['lngfile']]) && isset($languages['english']))
            $languages['english']['count'] += $row['num_users'];
        elseif (isset($languages[$row['lngfile']]))
            $languages[$row['lngfile']]['count'] += $row['num_users'];
    }
    $smcFunc['db_free_result']($request);

    // Restore the current users language.
    $txt = $old_txt;

    // Return how many we have.
    return $languages;
}

/**
 * Edit language related settings.
 *
 * @param bool $return_config Whether to return the $config_vars array (used in admin search)
 * @return void|array Returns nothing or the $config_vars array if $return_config is true
 */
function ModifyLanguageSettings($return_config = false)
{
    global $scripturl, $context, $txt, $boarddir, $sourcedir;

    // We'll want to save them someday.
    require_once $sourcedir . '/ManageServer.php';

    // Warn the user if the backup of Settings.php failed.
    $settings_not_writable = !is_writable($boarddir . '/Settings.php');
    $settings_backup_fail = !@is_writable($boarddir . '/Settings_bak.php') || !@copy($boarddir . '/Settings.php', $boarddir . '/Settings_bak.php');

    /* If you're writing a mod, it's a bad idea to add things here....
    For each option:
        variable name, description, type (constant), size/possible values, helptext.
    OR  an empty string for a horizontal rule.
    OR  a string for a titled section. */
    $config_vars = array(
        'language' => array('language', $txt['default_language'], 'file', 'select', array(), null, 'disabled' => $settings_not_writable),
        array('userLanguage', $txt['userLanguage'], 'db', 'check', null, 'userLanguage'),
    );

    call_integration_hook('integrate_language_settings', array(&$config_vars));

    if ($return_config)
        return $config_vars;

    // Get our languages. No cache
    getLanguages(false);
    foreach ($context['languages'] as $lang)
        $config_vars['language'][4][$lang['filename']] = array($lang['filename'], $lang['name']);

    // Saving settings?
    if (isset($_REQUEST['save']))
    {
        checkSession();

        call_integration_hook('integrate_save_language_settings', array(&$config_vars));

        saveSettings($config_vars);
        if (!$settings_not_writable && !$settings_backup_fail)
            $_SESSION['adm-save'] = true;
        redirectexit('action=admin;area=languages;sa=settings');
    }

    // Setup the template stuff.
    $context['post_url'] = $scripturl . '?action=admin;area=languages;sa=settings;save';
    $context['settings_title'] = $txt['language_settings'];
    $context['save_disabled'] = $settings_not_writable;

    if ($settings_not_writable)
        $context['settings_message'] = array(
            'label' => $txt['settings_not_writable'],
            'tag' => 'div',
            'class' => 'centertext strong'
        );
    elseif ($settings_backup_fail)
        $context['settings_message'] = array(
            'label' => $txt['admin_backup_fail'],
            'tag' => 'div',
            'class' => 'centertext strong'
        );

    // Fill the config array.
    prepareServerSettingsContext($config_vars);
}

/**
 * Edit a particular set of language entries.
 */
function ModifyLanguage()
{
    global $settings, $context, $smcFunc, $txt, $modSettings, $boarddir, $sourcedir, $language, $cache_enable;

    loadLanguage('ManageSettings');

    // Select the languages tab.
    $context['menu_data_' . $context['admin_menu_id']]['current_subsection'] = 'edit';
    $context['page_title'] = $txt['edit_languages'];
    $context['sub_template'] = 'modify_language_entries';

    $context['lang_id'] = $_GET['lid'];
    list($theme_id, $file_id) = empty($_REQUEST['tfid']) || strpos($_REQUEST['tfid'], '+') === false ? array(1, '') : explode('+', $_REQUEST['tfid']);

    // Clean the ID - just in case.
    preg_match('~([A-Za-z0-9_-]+)~', $context['lang_id'], $matches);
    $context['lang_id'] = $matches[1];

    // Get all the theme data.
    $request = $smcFunc['db_query']('', '
        SELECT id_theme, variable, value
        FROM {db_prefix}themes
        WHERE id_theme != {int:default_theme}
            AND id_member = {int:no_member}
            AND variable IN ({string:name}, {string:theme_dir})',
        array(
            'default_theme' => 1,
            'no_member' => 0,
            'name' => 'name',
            'theme_dir' => 'theme_dir',
        )
    );
    $themes = array(
        1 => array(
            'name' => $txt['dvc_default'],
            'theme_dir' => $settings['default_theme_dir'],
        ),
    );
    while ($row = $smcFunc['db_fetch_assoc']($request))
        $themes[$row['id_theme']][$row['variable']] = $row['value'];
    $smcFunc['db_free_result']($request);

    // This will be where we look
    $lang_dirs = array();

    // There are different kinds of strings
    $string_types = array('txt', 'helptxt', 'editortxt', 'tztxt', 'txtBirthdayEmails');
    $additional_string_types = array();

    // Some files allow the admin to add and/or remove certain types of strings
    $allows_add_remove = array(
        'Timezones' => array(
            'add' => array('tztxt', 'txt'),
            'remove' => array('tztxt', 'txt'),
        ),
        'Modifications' => array(
            'add' => array('txt'),
            'remove' => array('txt'),
        ),
        'ThemeStrings' => array(
            'add' => array('txt'),
        ),
    );

    // Does a hook need to add in some additional places to look for languages or info about how to handle them?
    call_integration_hook('integrate_modifylanguages', array(&$themes, &$lang_dirs, &$allows_add_remove, &$additional_string_types));

    $string_types = array_unique(array_merge($string_types, $additional_string_types));

    // Check we have themes with a path and a name - just in case - and add the path.
    foreach ($themes as $id => $data)
    {
        if (count($data) != 2)
            unset($themes[$id]);
        elseif (is_dir($data['theme_dir'] . '/languages'))
            $lang_dirs[$id] = $data['theme_dir'] . '/languages';

        // How about image directories?
        if (is_dir($data['theme_dir'] . '/images/' . $context['lang_id']))
            $images_dirs[$id] = $data['theme_dir'] . '/images/' . $context['lang_id'];
    }

    $current_file = $file_id ? $lang_dirs[$theme_id] . '/' . $file_id . '.' . $context['lang_id'] . '.php' : '';

    // Now for every theme get all the files and stick them in context!
    $context['possible_files'] = array();
    foreach ($lang_dirs as $theme => $theme_dir)
    {
        // Open it up.
        $dir = dir($theme_dir);
        while ($entry = $dir->read())
        {
            // We're only after the files for this language.
            if (preg_match('~^([A-Za-z]+)\.' . $context['lang_id'] . '\.php$~', $entry, $matches) == 0)
                continue;

            if (!isset($context['possible_files'][$theme]))
                $context['possible_files'][$theme] = array(
                    'id' => $theme,
                    'name' => $themes[$theme]['name'],
                    'files' => array(),
                );

            $context['possible_files'][$theme]['files'][] = array(
                'id' => $matches[1],
                'name' => isset($txt['lang_file_desc_' . $matches[1]]) ? $txt['lang_file_desc_' . $matches[1]] : $matches[1],
                'selected' => $theme_id == $theme && $file_id == $matches[1],
            );
        }
        $dir->close();
        usort($context['possible_files'][$theme]['files'], function($val1, $val2)
        {
            return strcmp($val1['name'], $val2['name']);
        });
    }

    // We no longer wish to speak this language.
    if (!empty($_POST['delete_main']) && $context['lang_id'] != 'english')
    {
        checkSession();
        validateToken('admin-mlang');

        // @todo Todo: FTP Controls?
        require_once($sourcedir . '/Subs-Package.php');

        // First, Make a backup?
        if (!empty($modSettings['package_make_backups']) && (!isset($_SESSION['last_backup_for']) || $_SESSION['last_backup_for'] != $context['lang_id'] . '$$$'))
        {
            $_SESSION['last_backup_for'] = $context['lang_id'] . '$$$';
            $result = package_create_backup('backup_lang_' . $context['lang_id']);
            if (!$result)
                fatal_lang_error('could_not_language_backup', false);
        }

        // Second, loop through the array to remove the files.
        foreach ($lang_dirs as $curPath)
        {
            foreach ($context['possible_files'][1]['files'] as $lang)
                if (file_exists($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php'))
                    unlink($curPath . '/' . $lang['id'] . '.' . $context['lang_id'] . '.php');

            // Check for the email template.
            if (file_exists($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php'))
                unlink($curPath . '/EmailTemplates.' . $context['lang_id'] . '.php');
        }

        // Third, the agreement file.
        if (file_exists($boarddir . '/agreement.' . $context['lang_id'] . '.txt'))
            unlink($boarddir . '/agreement.' . $context['lang_id'] . '.txt');

        // Fourth, a related images folder, if it exists...
        if (!empty($images_dirs))
            foreach ($images_dirs as $curPath)
                if (is_dir($curPath))
                    deltree($curPath);

        // Members can no longer use this language.
        $smcFunc['db_query']('', '
            UPDATE {db_prefix}members
            SET lngfile = {empty}
            WHERE lngfile = {string:current_language}',
            array(
                'empty_string' => '',
                'current_language' => $context['lang_id'],
            )
        );

        // Fifth, update getLanguages() cache.
        if (!empty($cache_enable))
        {
            cache_put_data('known_languages', null, !empty($cache_enable) && $cache_enable < 1 ? 86400 : 3600);
        }

        // Sixth, if we deleted the default language, set us back to english?
        if ($context['lang_id'] == $language)
        {
            require_once($sourcedir . '/Subs-Admin.php');
            $language = 'english';
            updateSettingsFile(array('language' => $language));
        }

        // Seventh, get out of here.
        redirectexit('action=admin;area=languages;sa=edit;' . $context['session_var'] . '=' . $context['session_id']);
    }

    // Saving primary settings?
    $primary_settings = array('native_name' => 'string', 'lang_character_set' => 'string', 'lang_locale' => 'string', 'lang_rtl' => 'bool', 'lang_dictionary' => 'string', 'lang_spelling' => 'string', 'lang_recaptcha' => 'string');
    $madeSave = false;
    if (!empty($_POST['save_main']) && !$current_file)
    {
        checkSession();
        validateToken('admin-mlang');

        // Read in the current file.
        $current_data = implode('', file($settings['default_theme_dir'] . '/languages/index.' . $context['lang_id'] . '.php'));

        // Build the replacements. old => new
        $replace_array = array();
        foreach ($primary_settings as $setting => $type)
            $replace_array['~\$txt\[\'' . $setting . '\'\]\s*=\s*[^\r\n]+~'] = '$txt[\'' . $setting . '\'] = ' . ($type === 'bool' ? (!empty($_POST[$setting]) ? 'true' : 'false') : '\'' . ($setting = 'native_name' ? htmlentities(un_htmlspecialchars($_POST[$setting]), ENT_QUOTES, $context['character_set']) : preg_replace('~[^\w-]~i', '', $_POST[$setting])) . '\'') . ';';

        $current_data = preg_replace(array_keys($replace_array), array_values($replace_array), $current_data);
        $fp = fopen($settings['default_theme_dir'] . '/languages/index.' . $context['lang_id'] . '.php', 'w+');
        fwrite($fp, $current_data);
        fclose($fp);

        $madeSave = true;
    }

    // Quickly load index language entries.
    $old_txt = $txt;
    require($settings['default_theme_dir'] . '/languages/index.' . $context['lang_id'] . '.php');
    $context['lang_file_not_writable_message'] = is_writable($settings['default_theme_dir'] . '/languages/index.' . $context['lang_id'] . '.php') ? '' : sprintf($txt['lang_file_not_writable'], $settings['default_theme_dir'] . '/languages/index.' . $context['lang_id'] . '.php');
    // Setup the primary settings context.
    $context['primary_settings']['name'] = $smcFunc['ucwords'](strtr($context['lang_id'], array('_' => ' ', '-utf8' => '')));
    foreach ($primary_settings as $setting => $type)
    {
        $context['primary_settings'][$setting] = array(
            'label' => str_replace('lang_', '', $setting),
            'value' => $txt[$setting],
        );
    }

    // Restore normal service.
    $txt = $old_txt;

    // Are we saving?
    $save_strings = array();
    $remove_strings = array();
    $add_strings = array();
    if (isset($_POST['save_entries']))
    {
        checkSession();
        validateToken('admin-mlang');

        if (!empty($_POST['edit']))
        {
            foreach ($_POST['edit'] as $k => $v)
            {
                if (is_string($v))
                {
                    // Only try to save if 'edit' was specified and if the string has changed
                    if ($v == 'edit' && isset($_POST['entry'][$k]) && isset($_POST['comp'][$k]) && $_POST['entry'][$k] != $_POST['comp'][$k])
                        $save_strings[$k] = cleanLangString($_POST['entry'][$k], false);

                    // Record any add or remove requests. We'll decide on them later.
                    elseif ($v == 'remove')
                        $remove_strings[] = $k;
                    elseif ($v == 'add' && isset($_POST['entry'][$k]))
                    {
                        $add_strings[$k] = array(
                            'group' => isset($_POST['grp'][$k]) ? $_POST['grp'][$k] : 'txt',
                            'string' => cleanLangString($_POST['entry'][$k], false),
                        );
                    }
                }
                elseif (is_array($v))
                {
                    foreach ($v as $subk => $subv)
                    {
                        if ($subv == 'edit' && isset($_POST['entry'][$k][$subk]) && isset($_POST['comp'][$k][$subk]) && $_POST['entry'][$k][$subk] != $_POST['comp'][$k][$subk])
                            $save_strings[$k][$subk] = cleanLangString($_POST['entry'][$k][$subk], false);

                        elseif ($subv == 'remove')
                            $remove_strings[$k][] = $subk;
                        elseif ($subv == 'add' && isset($_POST['entry'][$k][$subk]))
                        {
                            $add_strings[$k][$subk] = array(
                                'group' => isset($_POST['grp'][$k]) ? $_POST['grp'][$k] : 'txt',
                                'string' => cleanLangString($_POST['entry'][$k][$subk], false),
                            );
                        }

                    }
                }
            }
        }
    }

    // If we are editing a file work away at that.
    $context['can_add_lang_entry'] = array();
    if ($current_file)
    {
        $context['entries_not_writable_message'] = is_writable($current_file) ? '' : sprintf($txt['lang_entries_not_writable'], $current_file);

        // How many strings will PHP let us edit at once?
        // Each string needs 3 inputs, and there are 5 others in the form.
        $context['max_inputs'] = floor(ini_get('max_input_vars') / 3) - 5;

        // Do we want to override the helptxt for certain types of text variables?
        $special_groups = array(
            'Timezones' => array('txt' => 'txt_for_timezones'),
            'EmailTemplates' => array('txt' => 'txt_for_email_templates', 'txtBirthdayEmails' => 'txt_for_email_templates'),
        );
        call_integration_hook('integrate_language_edit_helptext', array(&$special_groups));

        // Determine which groups of strings (if any) allow adding new entries
        if (isset($allows_add_remove[$file_id]['add']))
        {
            foreach ($allows_add_remove[$file_id]['add'] as $var_group)
            {
                $group = !empty($special_groups[$file_id][$var_group]) ? $special_groups[$file_id][$var_group] : $var_group;
                if (in_array($var_group, $allows_add_remove[$file_id]['add']))
                    $context['can_add_lang_entry'][$group] = true;
            }
        }

        // Read in the file's contents and process it into entries.
        // Also, remove any lines for uneditable variables like $forum_copyright from the working data.
        $entries = array();
        foreach (preg_split('~^(?=\$(?:' . implode('|', $string_types) . ')\[\'([^\n]+?)\'\])~m' . ($context['utf8'] ? 'u' : ''), preg_replace('~\s*\n(\$(?!(?:' . implode('|', $string_types) . '))[^\n]*)~', '', file_get_contents($current_file))) as $blob)
        {
            // Comment lines at the end of the blob can make terrible messes
            $blob = preg_replace('~(\n[ \t]*//[^\n]*)*$~' . ($context['utf8'] ? 'u' : ''), '', $blob);

            // Extract the variable
            if (preg_match('~^\$(' . implode('|', $string_types) . ')\[\'([^\n]+?)\'\](?:\[\'?([^\n]+?)\'?\])?\s?=\s?(.+);([ \t]*(?://[^\n]*)?)$~ms' . ($context['utf8'] ? 'u' : ''), strtr($blob, array("\r" => '')), $matches))
            {
                // If no valid subkey was found, we need it to be explicitly null
                $matches[3] = isset($matches[3]) && $matches[3] !== '' ? $matches[3] : null;

                // The point of this exercise
                $entries[$matches[2] . (isset($matches[3]) ? '[' . $matches[3] . ']' : '')] = array(
                    'type' => $matches[1],
                    'group' => !empty($special_groups[$file_id][$matches[1]]) ? $special_groups[$file_id][$matches[1]] : $matches[1],
                    'can_remove' => isset($allows_add_remove[$file_id]['remove']) && in_array($matches[1], $allows_add_remove[$file_id]['remove']),
                    'key' => $matches[2],
                    'subkey' => $matches[3],
                    'full' => $matches[0],
                    'entry' => $matches[4],
                    'cruft' => $matches[5],
                );
            }
        }

        // These will be the entries we can definitely save.
        $final_saves = array();

        $context['file_entries'] = array();
        foreach ($entries as $entryKey => $entryValue)
        {
            // Ignore some things we set separately.
            if (in_array($entryKey, array_keys($primary_settings)))
                continue;

            // These are arrays that need breaking out.
            if (strpos($entryValue['entry'], 'array(') === 0 && strpos($entryValue['entry'], ')', -1) === strlen($entryValue['entry']) - 1)
            {
                // No, you may not use multidimensional arrays of $txt strings. Madness stalks that path.
                if (isset($entryValue['subkey']))
                    continue;

                // Trim off the array construct bits.
                $entryValue['entry'] = substr($entryValue['entry'], strpos($entryValue['entry'], 'array(') + 6, -1);

                // This crazy regex extracts each array element, even if the value contains commas or escaped quotes
                // The keys can be either integers or strings
                // The values must be strings, or the regex will fail
                $m = preg_match_all('/
                    # Optional explicit key assignment
                    (?:
                        (?:
                            \d+
                            |
                            (?:
                                (?:
                                    \'(?:[^\']|(?<=\\\)\')*\'
                                )
                                |
                                (?:
                                    "(?:[^"]|(?<=\\\)")*"
                                )
                            )
                        )
                        \s*=>\s*
                    )?

                    # String value in single or double quotes
                    (?:
                        (?:
                            \'(?:[^\']|(?<=\\\)\')*\'
                        )
                        |
                        (?:
                            "(?:[^"]|(?<=\\\)")*"
                        )
                    )

                    # Followed by a comma or the end of the string
                    (?=,|$)

                    /x' . ($context['utf8'] ? 'u' : ''), $entryValue['entry'], $matches);

                if (empty($m))
                    continue;

                $entryValue['entry'] = $matches[0];

                // Now create an entry for each item.
                $cur_index = -1;
                $save_cache = array(
                    'enabled' => false,
                    'entries' => array(),
                );
                foreach ($entryValue['entry'] as $id => $subValue)
                {
                    // Is this a new index?
                    if (preg_match('~^(\d+|(?:(?:\'(?:[^\']|(?<=\\\)\')*\')|(?:"(?:[^"]|(?<=\\\)")*")))\s*=>~', $subValue, $matches))
                    {
                        $subKey = trim($matches[1], '\'"');

                        if (ctype_digit($subKey))
                            $cur_index = $subKey;

                        $subValue = trim(substr($subValue, strpos($subValue, '=>') + 2));
                    }
                    else
                        $subKey = ++$cur_index;

                    // Clean up some bits.
                    if (strpos($subValue, '\'') === 0)
                        $subValue = trim($subValue, '\'');
                    elseif (strpos($subValue, '"') === 0)
                        $subValue = trim($subValue, '"');

                    // Can we save?
                    if (isset($save_strings[$entryKey][$subKey]))
                    {
                        $save_cache['entries'][$subKey] = strtr($save_strings[$entryKey][$subKey], array('\'' => ''));
                        $save_cache['enabled'] = true;
                    }
                    // Should we remove this one?
                    elseif (isset($remove_strings[$entryKey]) && in_array($subKey, $remove_strings[$entryKey]) && $entryValue['can_remove'])
                        $save_cache['enabled'] = true;
                    // Just keep this one as it is
                    else
                        $save_cache['entries'][$subKey] = $subValue;

                    $context['file_entries'][$entryValue['group']][] = array(
                        'key' => $entryKey,
                        'subkey' => $subKey,
                        'value' => $subValue,
                        'rows' => 1,
                        'can_remove' => $entryValue['can_remove'],
                    );
                }

                // Should we add a new string to this array?
                if (!empty($context['can_add_lang_entry'][$entryValue['type']]) && isset($add_strings[$entryKey]))
                {
                    foreach ($add_strings[$entryKey] as $string_key => $string_val)
                        $save_cache['entries'][$string_key] = strtr($string_val['string'], array('\'' => ''));

                    $save_cache['enabled'] = true;

                    // Make sure we don't add this again as an independent line
                    unset($add_strings[$entryKey][$string_key]);
                    if (empty($add_strings[$entryKey]))
                        unset($add_strings[$entryKey]);
                }

                // Do we need to save?
                if ($save_cache['enabled'])
                {
                    // Format the string, checking the indexes first.
                    $items = array();
                    $cur_index = 0;
                    foreach ($save_cache['entries'] as $k2 => $v2)
                    {
                        // Manually show the custom index.
                        if ($k2 != $cur_index)
                        {
                            $items[] = $k2 . ' => \'' . $v2 . '\'';
                            $cur_index = $k2;
                        }
                        else
                            $items[] = '\'' . $v2 . '\'';

                        $cur_index++;
                    }
                    // Now create the string!
                    $final_saves[$entryKey] = array(
                        'find' => $entryValue['full'],
                        'replace' => '// ' . implode("\n// ", explode("\n", rtrim($entryValue['full'], "\n"))) . "\n" . '$' . $entryValue['type'] . '[\'' . $entryKey . '\'] = array(' . implode(', ', $items) . ');' . $entryValue['cruft'],
                    );
                }
            }
            // A single array element, like: $txt['foo']['bar'] = 'baz';
            elseif (isset($entryValue['subkey']))
            {
                // Saving?
                if (isset($save_strings[$entryValue['key']][$entryValue['subkey']]) && $save_strings[$entryValue['key']][$entryValue['subkey']] != $entryValue['entry'])
                {
                    if ($save_strings[$entryValue['key']][$entryValue['subkey']] == '')
                        $save_strings[$entryValue['key']][$entryValue['subkey']] = '\'\'';

                    // Preserve subkey as either digit or string
                    $subKey = ctype_digit($entryValue['subkey']) ? $entryValue['subkey'] : '\'' . $entryValue['subkey'] . '\'';

                    // We have a new value, so we should use it
                    $entryValue['entry'] = $save_strings[$entryValue['key']][$entryValue['subkey']];

                    // And save it
                    $final_saves[$entryKey] = array(
                        'find' => $entryValue['full'],
                        'replace' => '// ' . implode("\n// ", explode("\n", rtrim($entryValue['full'], "\n"))) . "\n" . '$' . $entryValue['type'] . '[\'' . $entryValue['key'] . '\'][' . $subKey . '] = ' . $save_strings[$entryValue['key']][$entryValue['subkey']] . ';' . $entryValue['cruft'],
                    );
                }

                // Remove this entry only if it is allowed
                if (isset($remove_strings[$entryValue['key']]) && in_array($entryValue['subkey'], $remove_strings[$entryValue['key']]) && $entryValue['can_remove'])
                {
                    $entryValue['entry'] = '\'\'';
                    $final_saves[$entryKey] = array(
                        'find' => $entryValue['full'],
                        'replace' => '// ' . implode("\n// ", explode("\n", rtrim($entryValue['full'], "\n"))) . "\n",
                    );
                }

                $editing_string = cleanLangString($entryValue['entry'], true);
                $context['file_entries'][$entryValue['group']][] = array(
                    'key' => $entryValue['key'],
                    'subkey' => $entryValue['subkey'],
                    'value' => $editing_string,
                    'rows' => (int) (strlen($editing_string) / 38) + substr_count($editing_string, "\n") + 1,
                    'can_remove' => $entryValue['can_remove'],
                );
            }
            // A simple string entry
            else
            {
                // Saving?
                if (isset($save_strings[$entryValue['key']]) && $save_strings[$entryValue['key']] != $entryValue['entry'])
                {
                    // @todo Fix this properly.
                    if ($save_strings[$entryValue['key']] == '')
                        $save_strings[$entryValue['key']] = '\'\'';

                    // Set the new value.
                    $entryValue['entry'] = $save_strings[$entryValue['key']];
                    // And we know what to save now!
                    $final_saves[$entryKey] = array(
                        'find' => $entryValue['full'],
                        'replace' => '// ' . implode("\n// ", explode("\n", rtrim($entryValue['full'], "\n"))) . "\n" . '$' . $entryValue['type'] . '[\'' . $entryValue['key'] . '\'] = ' . $save_strings[$entryValue['key']] . ';' . $entryValue['cruft'],
                    );
                }
                // Remove this entry only if it is allowed
                if (in_array($entryValue['key'], $remove_strings) && $entryValue['can_remove'])
                {
                    $entryValue['entry'] = '\'\'';
                    $final_saves[$entryKey] = array(
                        'find' => $entryValue['full'],
                        'replace' => '// ' . implode("\n// ", explode("\n", rtrim($entryValue['full'], "\n"))) . "\n",
                    );
                }

                $editing_string = cleanLangString($entryValue['entry'], true);
                $context['file_entries'][$entryValue['group']][] = array(
                    'key' => $entryValue['key'],
                    'subkey' => null,
                    'value' => $editing_string,
                    'rows' => (int) (strlen($editing_string) / 38) + substr_count($editing_string, "\n") + 1,
                    'can_remove' => $entryValue['can_remove'],
                );
            }
        }

        // Do they want to add some brand new strings? Does this file allow that?
        if (!empty($add_strings) && !empty($allows_add_remove[$file_id]['add']))
        {
            $special_types = isset($special_groups[$file_id]) ? array_flip($special_groups[$file_id]) : array();

            foreach ($add_strings as $string_key => $string_val)
            {
                // Adding a normal string
                if (isset($string_val['string']) && is_string($string_val['string']))
                {
                    $type = isset($special_types[$string_val['group']]) ? $special_types[$string_val['group']] : $string_val['group'];

                    if (empty($context['can_add_lang_entry'][$type]))
                        continue;

                    $final_saves[$string_key] = array(
                        'find' => "\s*\?" . '>$',
                        'replace' => "\n\$" . $type . '[\'' . $string_key . '\'] = ' . $string_val['string'] . ';' . "\n\n?" . '>',
                        'is_regex' => true,
                    );
                }
                // Adding an array element
                else
                {
                    foreach ($string_val as $substring_key => $substring_val)
                    {
                        $type = isset($special_types[$substring_val['group']]) ? $special_types[$substring_val['group']] : $substring_val['group'];

                        if (empty($context['can_add_lang_entry'][$type]))
                            continue;

                        $subKey = ctype_digit(trim($substring_key, '\'')) ? trim($substring_key, '\'') : '\'' . $substring_key . '\'';

                        $final_saves[$string_key . '[' . $substring_key . ']'] = array(
                            'find' => "\s*\?" . '>$',
                            'replace' => "\n\$" . $type . '[\'' . $string_key . '\'][' . $subKey . '] = ' . $substring_val['string'] . ';' . "\n\n?" . '>',
                            'is_regex' => true,
                        );
                    }
                }
            }
        }

        // Any saves to make?
        if (!empty($final_saves))
        {
            checkSession();

            // Get a fresh copy of the file's current content.
            $file_contents = file_get_contents($current_file);

            // Apply our changes.
            foreach ($final_saves as $save)
            {
                if (!empty($save['is_regex']))
                    $file_contents = preg_replace('~' . $save['find'] . '~' . ($context['utf8'] ? 'u' : ''), $save['replace'], $file_contents);
                else
                    $file_contents = str_replace($save['find'], $save['replace'], $file_contents);
            }

            // Save the result back to the file.
            file_put_contents($current_file, $file_contents);

            $madeSave = true;
        }

        // Another restore.
        $txt = $old_txt;

        // If they can add new language entries, make sure the UI is set up for that.
        if (!empty($context['can_add_lang_entry']))
        {
            // Make sure the Add button has a place to show up.
            foreach ($context['can_add_lang_entry'] as $group => $value)
            {
                if (!isset($context['file_entries'][$group]))
                    $context['file_entries'][$group] = array();
            }

            addInlineJavaScript('
                function add_lang_entry(group) {
                    var key = prompt("' . $txt['languages_enter_key'] . '");

                    if (key !== null) {
                        ++entry_num;

                        var array_regex = /^(.*)(\[[^\[\]]*\])$/
                        var result = array_regex.exec(key);
                        if (result != null) {
                            key = result[1];
                            var subkey = result[2];
                        } else {
                            var subkey = "";
                        }

                        var bracket_regex = /[\[\]]/
                        if (bracket_regex.test(key)) {
                            alert("' . $txt['languages_invalid_key'] . '" + key + subkey);
                            return;
                        }

                        $("#language_" + group).append("<dt><span>" + key + subkey + "</span></dt> <dd id=\"entry_" + entry_num + "\"><input id=\"entry_" + entry_num + "_edit\" class=\"entry_toggle\" type=\"checkbox\" name=\"edit[" + key + "]" + subkey + "\" value=\"add\" data-target=\"#entry_" + entry_num + "\" checked> <label for=\"entry_" + entry_num + "_edit\">' . $txt['edit'] . '</label> <input type=\"hidden\" class=\"entry_oldvalue\" name=\"grp[" + key + "]\" value=\"" + group + "\"> <textarea name=\"entry[" + key + "]" + subkey + "\" class=\"entry_textfield\" cols=\"40\" rows=\"1\" style=\"width: 96%; margin-bottom: 2em;\"></textarea></dd>");
                    }
                };');

            addInlineJavaScript('
                $(".add_lang_entry_button").show();', true);
        }

        // Warn them if they try to submit more changes than the server can accept in a single request.
        // Also make it obvious that they cannot submit changes to both the primary settings and the entries at the same time.
        if (!empty($context['file_entries']))
        {
            addInlineJavaScript('
                max_inputs = ' . $context['max_inputs'] . ';
                num_inputs = 0;

                $(".entry_textfield").prop("disabled", true);
                $(".entry_oldvalue").prop("disabled", true);

                $(".entry_toggle").click(function() {
                    var target_dd = $( $(this).data("target") );

                    if ($(this).prop("checked") === true && $(this).val() === "edit") {
                        if (++num_inputs <= max_inputs) {
                            target_dd.find(".entry_oldvalue, .entry_textfield").prop("disabled", false);
                        } else {
                            alert("' . sprintf($txt['languages_max_inputs_warning'], $context['max_inputs']) . '");
                            $(this).prop("checked", false);
                        }
                    } else {
                        --num_inputs;
                        target_dd.find(".entry_oldvalue, .entry_textfield").prop("disabled", true);
                    }

                    if (num_inputs > 0) {
                        $("#primary_settings").trigger("reset");
                        $("#primary_settings input").prop("disabled", true);
                    } else {
                        $("#primary_settings input").prop("disabled", false);
                    }
                });

                $("#primary_settings input").change(function() {
                    num_changed = 0;
                    $("#primary_settings input:text").each(function(i, e) {
                        if ($(e).data("orig") != $(e).val())
                            num_changed++;
                    });
                    $("#primary_settings input:checkbox").each(function(i, e) {
                        cur_val = $(e).is(":checked");
                        orig_val = $(e).val == "true";
                        if (cur_val != orig_val)
                            num_changed++;
                    });

                    if (num_changed > 0) {
                        $("#entry_fields").fadeOut();
                    } else {
                        $("#entry_fields").fadeIn();
                    }
                });
                $("#reset_main").click(function() {
                    $("#entry_fields").fadeIn();
                });', true);
        }
    }

    // If we saved, redirect.
    if ($madeSave)
        redirectexit('action=admin;area=languages;sa=editlang;lid=' . $context['lang_id'] . (!empty($file_id) ? ';entries;tfid=' . $theme_id . rawurlencode('+') . $file_id : ''));

    createToken('admin-mlang');
}

/**
 * This function cleans language entries to/from display.
 *
 * @todo This function could be two functions?
 *
 * @param string $string The language string
 * @param bool $to_display Whether or not this is going to be displayed
 * @return string The cleaned string
 */
function cleanLangString($string, $to_display = true)
{
    global $smcFunc;

    // If going to display we make sure it doesn't have any HTML in it - etc.
    $new_string = '';
    if ($to_display)
    {
        // Are we in a string (0 = no, 1 = single quote, 2 = parsed)
        $in_string = 0;
        $is_escape = false;
        for ($i = 0; $i < strlen($string); $i++)
        {
            // Handle escapes first.
            if ($string[$i] == '\\')
            {
                // Toggle the escape.
                $is_escape = !$is_escape;
                // If we're now escaped don't add this string.
                if ($is_escape)
                    continue;
            }
            // Special case - parsed string with line break etc?
            elseif (($string[$i] == 'n' || $string[$i] == 't') && $in_string == 2 && $is_escape)
            {
                // Put the escape back...
                $new_string .= $string[$i] == 'n' ? "\n" : "\t";
                $is_escape = false;
                continue;
            }
            // Have we got a single quote?
            elseif ($string[$i] == '\'')
            {
                // Already in a parsed string, or escaped in a linear string, means we print it - otherwise something special.
                if ($in_string != 2 && ($in_string != 1 || !$is_escape))
                {
                    // Is it the end of a single quote string?
                    if ($in_string == 1)
                        $in_string = 0;
                    // Otherwise it's the start!
                    else
                        $in_string = 1;

                    // Don't actually include this character!
                    continue;
                }
            }
            // Otherwise a double quote?
            elseif ($string[$i] == '"')
            {
                // Already in a single quote string, or escaped in a parsed string, means we print it - otherwise something special.
                if ($in_string != 1 && ($in_string != 2 || !$is_escape))
                {
                    // Is it the end of a double quote string?
                    if ($in_string == 2)
                        $in_string = 0;
                    // Otherwise it's the start!
                    else
                        $in_string = 2;

                    // Don't actually include this character!
                    continue;
                }
            }
            // A join/space outside of a string is simply removed.
            elseif ($in_string == 0 && (empty($string[$i]) || $string[$i] == '.'))
                continue;
            // Start of a variable?
            elseif ($in_string == 0 && $string[$i] == '$')
            {
                // Find the whole of it!
                preg_match('~([\$A-Za-z0-9\'\[\]_-]+)~', substr($string, $i), $matches);
                if (!empty($matches[1]))
                {
                    // Come up with some pseudo thing to indicate this is a var.
                    /**
                     * @todo Do better than this, please!
                     */
                    $new_string .= '{%' . $matches[1] . '%}';

                    // We're not going to reparse this.
                    $i += strlen($matches[1]) - 1;
                }

                continue;
            }
            // Right, if we're outside of a string we have DANGER, DANGER!
            elseif ($in_string == 0)
            {
                continue;
            }

            // Actually add the character to the string!
            $new_string .= $string[$i];
            // If anything was escaped it ain't any longer!
            $is_escape = false;
        }

        // Unhtml then rehtml the whole thing!
        $new_string = $smcFunc['htmlspecialchars'](un_htmlspecialchars($new_string));
    }
    else
    {
        // Keep track of what we're doing...
        $in_string = 0;
        // This is for deciding whether to HTML a quote.
        $in_html = false;
        for ($i = 0; $i < strlen($string); $i++)
        {
            // We don't do parsed strings apart from for breaks.
            if ($in_string == 2)
            {
                $in_string = 0;
                $new_string .= '"';
            }

            // Not in a string yet?
            if ($in_string != 1)
            {
                $in_string = 1;
                $new_string .= ($new_string ? ' . ' : '') . '\'';
            }

            // Is this a variable?
            if ($string[$i] == '{' && $string[$i + 1] == '%' && $string[$i + 2] == '$')
            {
                // Grab the variable.
                preg_match('~\{%([\$A-Za-z0-9\'\[\]_-]+)%\}~', substr($string, $i), $matches);
                if (!empty($matches[1]))
                {
                    if ($in_string == 1)
                        $new_string .= '\' . ';
                    elseif ($new_string)
                        $new_string .= ' . ';

                    $new_string .= $matches[1];
                    $i += strlen($matches[1]) + 3;
                    $in_string = 0;
                }

                continue;
            }
            // Is this a lt sign?
            elseif ($string[$i] == '<')
            {
                // Probably HTML?
                if ($string[$i + 1] != ' ')
                    $in_html = true;
                // Assume we need an entity...
                else
                {
                    $new_string .= '&lt;';
                    continue;
                }
            }
            // What about gt?
            elseif ($string[$i] == '>')
            {
                // Will it be HTML?
                if ($in_html)
                    $in_html = false;
                // Otherwise we need an entity...
                else
                {
                    $new_string .= '&gt;';
                    continue;
                }
            }
            // Is it a slash? If so escape it...
            if ($string[$i] == '\\')
                $new_string .= '\\';
            // The infamous double quote?
            elseif ($string[$i] == '"')
            {
                // If we're in HTML we leave it as a quote - otherwise we entity it.
                if (!$in_html)
                {
                    $new_string .= '&quot;';
                    continue;
                }
            }
            // A single quote?
            elseif ($string[$i] == '\'')
            {
                // Must be in a string so escape it.
                $new_string .= '\\';
            }

            // Finally add the character to the string!
            $new_string .= $string[$i];
        }

        // If we ended as a string then close it off.
        if ($in_string == 1)
            $new_string .= '\'';
        elseif ($in_string == 2)
            $new_string .= '"';
    }

    return $new_string;
}

?>
API documentation generated by ApiGen