Overview

Packages

  • Core
    • Authentication
    • Backend
    • Cache
    • CEC
    • Chain
    • ContentType
    • Database
    • Datatype
    • Debug
    • Exception
    • Frontend
      • Search
      • URI
      • Util
    • GenericDB
      • Model
    • GUI
      • HTML
    • I18N
    • LayoutHandler
    • Log
    • Security
    • Session
    • Util
    • Validation
    • Versioning
    • XML
  • Module
    • ContentSitemapHtml
    • ContentSitemapXml
    • ContentUserForum
    • NavigationTop
  • mpAutoloaderClassMap
  • None
  • Plugin
    • ContentAllocation
    • CronjobOverview
    • FormAssistant
    • FrontendLogic
    • FrontendUsers
    • Linkchecker
    • ModRewrite
    • Newsletter
    • Repository
      • FrontendNavigation
      • KeywordDensity
    • SearchSolr
    • SmartyWrapper
    • UrlShortener
    • UserForum
    • Workflow
  • PluginManager
  • Setup
    • Form
    • GUI
    • Helper
      • Environment
      • Filesystem
      • MySQL
      • PHP
    • UpgradeJob

Classes

  • cAjaxRequest
  • cAutoload
  • cBackend
  • cEffectiveSetting
  • cGuiScrollListAlltranslations
  • cHTMLValidator
  • cMailer
  • cModuleFileTranslation
  • cModuleHandler
  • cModuleSearch
  • cModuleSynchronizer
  • cModuleTemplateHandler
  • CodeMirror
  • cPasswordRequest
  • cPermission
  • cRegistry
  • cSystemPurge
  • cSystemtest
  • cTinyMCEEditor
  • cWYSIWYGEditor
  • FrontendList
  • HtmlParser
  • SimpleXMLExtended
  • TreeItem
  • UploadList
  • UploadSearchResultList

Functions

  • _getCurrentTypes
  • _processCmsTags
  • addArtspec
  • addslashes_deep
  • addSortImages
  • backToMainArea
  • buildArticleSelect
  • buildCategorySelect
  • buildCategorySelectRights
  • buildHeapTable
  • buildStackString
  • buildTree
  • buildUserOrGroupPermsFromRequest
  • callPluginStore
  • cApiCatGetLevelNode
  • cApiImageCheckCachedImageValidity
  • cApiImageCheckImageEditingPosibility
  • cApiImageGetCacheFileName
  • cApiImageGetTargetDimensions
  • cApiImageIsAnimGif
  • cApiImgScale
  • cApiImgScaleGetMD5CacheFile
  • cApiImgScaleHQ
  • cApiImgScaleImageMagick
  • cApiImgScaleLQ
  • cApiIsImageMagickAvailable
  • cApiStrCleanURLCharacters
  • cApiStrNormalizeLineEndings
  • cApiStrRecodeString
  • cApiStrReplaceDiacritics
  • cApiStrTrimAfterWord
  • cApiStrTrimHard
  • cApiStrTrimSentence
  • cDeprecated
  • cDie
  • cError
  • checkLangInClients
  • checkPathInformation
  • cInclude
  • compareUrlStrings
  • conChangeTemplateForCat
  • conCopyArticle
  • conCopyArtLang
  • conCopyContainerConf
  • conCopyContent
  • conCopyMetaTags
  • conCopyTemplateConfiguration
  • conCreateLocationString
  • conDeeperCategoriesArray
  • conDeleteart
  • conEditArt
  • conEditFirstTime
  • conFetchCategoryTree
  • conFlagOnOffline
  • conGenerateCode
  • conGenerateCodeForAllArts
  • conGenerateCodeForAllArtsInCategory
  • conGenerateCodeForAllartsUsingLayout
  • conGenerateCodeForAllartsUsingMod
  • conGenerateCodeForAllArtsUsingTemplate
  • conGenerateCodeForArtInAllCategories
  • conGenerateCodeForClient
  • conGenerateKeywords
  • conGetAvailableMetaTagTypes
  • conGetCategoryArticleId
  • conGetCategoryAssignments
  • conGetContainerConfiguration
  • conGetContentFromArticle
  • conGetHtmlTranslationTable
  • conGetMetaValue
  • conGetTemplateConfigurationIdForArticle
  • conGetTemplateConfigurationIdForCategory
  • conGetTopmostCat
  • conGetUsedModules
  • conHtmlentities
  • conHtmlEntityDecode
  • conHtmlSpecialChars
  • conIsLocked
  • conLock
  • conLockBulkEditing
  • conMakeArticleIndex
  • conMakeCatOnline
  • conMakeInlineScript
  • conMakeOnline
  • conMakeOnlineBulkEditing
  • conMakePublic
  • conMakeStart
  • conMoveArticles
  • conPhp54Check
  • conRemoveOldCategoryArticle
  • conSaveContentEntry
  • conSetCodeFlag
  • conSetCodeFlagBulkEditing
  • conSetMetaValue
  • conSyncArticle
  • copyRightsForElement
  • createBulkEditingFunction
  • createRandomName
  • createRightsForElement
  • cWarning
  • dbGetColumns
  • dbGetIndexes
  • dbGetPrimaryKeyName
  • dbTableExists
  • dbUpgradeTable
  • defineIfNotDefined
  • deleteArtspec
  • deleteRightsForElement
  • deleteSystemProperty
  • displayDatetime
  • emptyLogFile
  • endAndLogTiming
  • endsWith
  • extractNumber
  • generateDisplayFilePath
  • generateJs
  • getAllClientsAndLanguages
  • getArtLang
  • getArtspec
  • getAvailableContentTypes
  • getCanonicalDay
  • getCanonicalMonth
  • getDirectorySize
  • getEffectiveSetting
  • getEffectiveSettingsByType
  • getEncodingByLanguage
  • getFileContents
  • getFileInformation
  • getFileType
  • getGroupOrUserName
  • getIDForArea
  • getJsHelpContext
  • getLanguageNamesByClient
  • getLanguagesByClient
  • getmicrotime
  • getNamedFrame
  • getParam
  • getParentAreaId
  • getSearchResults
  • getStrExpandCollapseButton
  • getSystemProperties
  • getSystemPropertiesByType
  • getSystemProperty
  • getTemplateSelect
  • getUplExpandCollapseButton
  • htmldecode
  • htmlentities_iso88592
  • humanReadableSize
  • includePlugins
  • insertEmptyStrRow
  • ipMatch
  • isAlphanumeric
  • isArchive
  • isArtInMultipleUse
  • isFunctionDisabled
  • isGroup
  • isIPv4
  • isRunningFromWeb
  • isStartArticle
  • isUtf8
  • isValidMail
  • langActivateDeactivateLanguage
  • langDeleteLanguage
  • langEditLanguage
  • langGetTextDirection
  • langNewLanguage
  • langRenameLanguage
  • layDeleteLayout
  • layEditLayout
  • machineReadableSize
  • mailLogBulkEditingFunctions
  • mailLogDecodeAddresses
  • markSubMenuItem
  • mask
  • modDeleteModule
  • modEditModule
  • modTestModule
  • phpInfoToHtml
  • plugin_include
  • prCreateURLNameLocationString
  • prDeleteCacheFileContent
  • prGetCacheFileContent
  • prResolvePathViaCategoryNames
  • prResolvePathViaURLNames
  • prWriteCacheFileContent
  • putFileContents
  • recursiveCopy
  • removeFileInformation
  • renderBackendBreadcrumb
  • renderLabel
  • renderSelectProperty
  • renderTextProperty
  • saveGroupRights
  • saveRights
  • scanDirectory
  • scanPlugins
  • sendEncodingHeader
  • set_magic_quotes_gpc
  • setArtspecDefault
  • setArtspecOnline
  • setHelpContext
  • setSystemProperty
  • showTree
  • startTiming
  • statCreateLocationString
  • statDisplayTopChooser
  • statDisplayYearlyTopChooser
  • statGetAvailableMonths
  • statGetAvailableYears
  • statResetStatistic
  • statsArchive
  • statsDisplayInfo
  • statsOverviewAll
  • statsOverviewTop
  • statsOverviewTopYear
  • statsOverviewYear
  • strAssignTemplate
  • strBuildSqlValues
  • strCheckTreeForErrors
  • strCopyCategory
  • strCopyTree
  • strDeeperCategoriesArray
  • strDeleteCategory
  • strHasArticles
  • strHasStartArticle
  • stripslashes_deep
  • strMakePublic
  • strMakeVisible
  • strMoveCatTargetallowed
  • strMoveDownCategory
  • strMoveSubtree
  • strMoveUpCategory
  • strNewCategory
  • strNewTree
  • strNextBackwards
  • strNextDeeper
  • strNextDeeperAll
  • strNextPost
  • strOrderedPostTreeList
  • strRemakeTreeTable
  • strRenameCategory
  • strRenameCategoryAlias
  • strSortPrePost
  • strSyncCategory
  • systemHavePerm
  • tplAutoFillModules
  • tplBrowseLayoutForContainers
  • tplcfgDuplicate
  • tplDeleteTemplate
  • tplDuplicateTemplate
  • tplEditTemplate
  • tplGetContainerDefault
  • tplGetContainerMode
  • tplGetContainerName
  • tplGetContainerNumbersInLayout
  • tplGetContainerTypes
  • tplGetInUsedData
  • tplIsTemplateInUse
  • tplPreparseLayout
  • tplProcessSendContainerConfiguration
  • updateClientCache
  • updateFileInformation
  • uplCreateFriendlyName
  • uplDirectoryListRecursive
  • uplGetDirectoriesToExclude
  • uplGetFileExtension
  • uplGetFileIcon
  • uplGetFileTypeDescription
  • uplGetThumbnail
  • uplHasFiles
  • uplHasSubdirs
  • uplmkdir
  • uplRecursiveDBDirectoryList
  • uplRecursiveDirectoryList
  • uplRenameDirectory
  • uplSearch
  • uplSyncDirectory
  • uplSyncDirectoryDBFS
  • Overview
  • Package
  • Class
  • Tree
  • Deprecated
  • Todo
  1: <?php
  2: /**
  3:  * This file contains the html validator class.
  4:  *
  5:  * @package Core
  6:  * @subpackage Backend
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author timo.hummel
 10:  * @copyright four for business AG <www.4fb.de>
 11:  * @license http://www.contenido.org/license/LIZENZ.txt
 12:  * @link http://www.4fb.de
 13:  * @link http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * This class validates HTML.
 20:  *
 21:  * @package Core
 22:  * @subpackage Backend
 23:  */
 24: class cHTMLValidator {
 25: 
 26:     /**
 27:      *
 28:      * @var array
 29:      */
 30:     protected $_doubleTags = array(
 31:         "form",
 32:         "head",
 33:         "body",
 34:         "html",
 35:         "td",
 36:         "tr",
 37:         "table",
 38:         "a",
 39:         "tbody",
 40:         "title",
 41:         "container",
 42:         "span",
 43:         "div"
 44:     );
 45: 
 46:     /**
 47:      *
 48:      * @var array
 49:      */
 50:     public $missingNodes = array();
 51: 
 52:     /**
 53:      *
 54:      * @var string
 55:      * @deprecated not used anymore
 56:      */
 57:     public $iNodeName;
 58: 
 59:     /**
 60:      *
 61:      * @var string
 62:      */
 63:     protected $_html;
 64: 
 65:     /**
 66:      *
 67:      * @var array
 68:      */
 69:     protected $_nestingLevel = array();
 70: 
 71:     /**
 72:      *
 73:      * @var array
 74:      */
 75:     protected $_nestingNodes = array();
 76: 
 77:     /**
 78:      *
 79:      * @var array
 80:      */
 81:     protected $_existingTags = array();
 82: 
 83:     /**
 84:      *
 85:      * @param string $html
 86:      */
 87:     public function validate($html) {
 88:         $nestingLevel = 0;
 89: 
 90:         // Clean up HTML first from any PHP scripts, and clean up line breaks
 91:         $this->_html = $this->_cleanHTML($html);
 92: 
 93:         $htmlParser = new HtmlParser($this->_html);
 94: 
 95:         while ($htmlParser->parse()) {
 96:             $this->_existingTags[] = $htmlParser->iNodeName;
 97:             // Check if we found a double tag
 98:             if (in_array($htmlParser->iNodeName, $this->_doubleTags)) {
 99:                 if (!array_key_exists($htmlParser->iNodeName, $this->_nestingLevel)) {
100:                     $this->_nestingLevel[$htmlParser->iNodeName] = 0;
101:                 }
102: 
103:                 if (!array_key_exists($htmlParser->iNodeName, $this->_nestingNodes)) {
104:                     $this->_nestingNodes[$htmlParser->iNodeName][intval($this->_nestingLevel[$htmlParser->iNodeName])] = array();
105:                 }
106: 
107:                 // Check if it's a start tag
108:                 if ($htmlParser->iNodeType == HtmlParser::NODE_TYPE_ELEMENT) {
109:                     // Push the current element to the stack, remember ID and
110:                     // Name, if possible
111:                     $nestingLevel++;
112: 
113:                     $this->_nestingNodes[$htmlParser->iNodeName][intval($this->_nestingLevel[$htmlParser->iNodeName])]["name"] = $htmlParser->iNodeAttributes["name"];
114:                     $this->_nestingNodes[$htmlParser->iNodeName][intval($this->_nestingLevel[$htmlParser->iNodeName])]["id"] = $htmlParser->iNodeAttributes["id"];
115:                     $this->_nestingNodes[$htmlParser->iNodeName][intval($this->_nestingLevel[$htmlParser->iNodeName])]["level"] = $nestingLevel;
116:                     $this->_nestingNodes[$htmlParser->iNodeName][intval($this->_nestingLevel[$htmlParser->iNodeName])]["char"] = $htmlParser->iHtmlTextIndex;
117:                     $this->_nestingLevel[$htmlParser->iNodeName]++;
118:                 }
119: 
120:                 if ($htmlParser->iNodeType == HtmlParser::NODE_TYPE_ENDELEMENT) {
121:                     // Check if we've an element of this type on the stack
122:                     if ($this->_nestingLevel[$htmlParser->iNodeName] > 0) {
123:                         unset($this->_nestingNodes[$htmlParser->iNodeName][$this->_nestingLevel[$htmlParser->iNodeName]]);
124:                         $this->_nestingLevel[$htmlParser->iNodeName]--;
125: 
126:                         if ($this->_nestingNodes[$htmlParser->iNodeName][intval($this->_nestingLevel[$htmlParser->iNodeName])]["level"] != $nestingLevel) {
127:                             // Todo: Check for the wrong nesting level
128:                         }
129: 
130:                         $nestingLevel--;
131:                     }
132:                 }
133:             }
134:         }
135: 
136:         // missingNodes should be an empty array by default
137:         $this->missingNodes = array();
138: 
139:         // Collect all missing nodes
140:         foreach ($this->_nestingLevel as $key => $value) {
141:             // One or more missing tags found
142:             if ($value > 0) {
143:                 // Step trough all missing tags
144:                 for ($i = 0; $i < $value; $i++) {
145:                     $node = $this->_nestingNodes[$key][$i];
146: 
147:                     list($line, $char) = $this->_getLineAndCharPos($node["char"]);
148:                     $this->missingNodes[] = array(
149:                         "tag" => $key,
150:                         "id" => $node["id"],
151:                         "name" => $node["name"],
152:                         "line" => $line,
153:                         "char" => $char
154:                     );
155: 
156:                     $this->missingTags[$line][$char] = true;
157:                 }
158:             }
159:         }
160:     }
161: 
162:     /**
163:      *
164:      * @param string $tag
165:      * @return boolean
166:      */
167:     public function tagExists($tag) {
168:         if (in_array($tag, $this->_existingTags)) {
169:             return true;
170:         } else {
171:             return false;
172:         }
173:     }
174: 
175:     /**
176:      *
177:      * @param string $html
178:      * @return mixed
179:      */
180:     protected function _cleanHTML($html) {
181:         // remove all php code from layout
182:         $resultingHTML = preg_replace('/<\?(php)?((.)|(\s))*?\?>/i', '', $html);
183: 
184:         // We respect only \n, but we need to take care of windows (\n\r) and
185:         // other systems (\r)
186:         $resultingHTML = str_replace("\r\n", "\n", $resultingHTML);
187:         $resultingHTML = str_replace("\r", "\n", $resultingHTML);
188: 
189:         return $resultingHTML;
190:     }
191: 
192:     /**
193:      *
194:      * @return string
195:      * @deprecated not used anymore
196:      */
197:     protected function _returnErrorMap() {
198:         $html = "<pre>";
199: 
200:         $chunks = explode("\n", $this->_html);
201: 
202:         foreach ($chunks as $key => $value) {
203:             $html .= ($key + 1) . " ";
204: 
205:             for ($i = 0; $i < strlen($value); $i++) {
206:                 $char = substr($value, $i, 1);
207: 
208:                 if (is_array($this->missingTags[$key + 1])) {
209:                     // echo ($key+1) . " ". $i."<br>";
210:                     if (array_key_exists($i + 2, $this->missingTags[$key + 1])) {
211:                         $html .= "<u><b>" . conHtmlSpecialChars($char) . "</b></u>";
212:                     } else {
213:                         $html .= conHtmlSpecialChars($char);
214:                     }
215:                 } else {
216:                     $html .= conHtmlSpecialChars($char);
217:                 }
218:             }
219: 
220:             $html .= "<br>";
221:         }
222: 
223:         return $html;
224:     }
225: 
226:     /**
227:      *
228:      * @param int $charpos
229:      * @return array
230:      */
231:     protected function _getLineAndCharPos($charpos) {
232:         $mangled = substr($this->_html, 0, $charpos);
233: 
234:         $line = substr_count($mangled, "\n") + 1;
235:         $char = $charpos - strrpos($mangled, "\n");
236: 
237:         return array(
238:             $line,
239:             $char
240:         );
241:     }
242: }
243: 
CMS CONTENIDO 4.9.5 API documentation generated by ApiGen 2.8.0