芝麻web文件管理V1.00
编辑当前文件:/home/asmplong/www/ancien-site-2019/site/administrator/components/com_content/helpers/content.php
set($action, $user->authorise($action, $assetName)); } return $result; } /** * Applies the content tag filters to arbitrary text as per settings for current user group * @param text The string to filter * @return string The filtered string */ public static function filterText($text) { // Filter settings jimport('joomla.application.component.helper'); $config = JComponentHelper::getParams('com_content'); $user = JFactory::getUser(); $userGroups = JAccess::getGroupsByUser($user->get('id')); $filters = $config->get('filters'); $blackListTags = array(); $blackListAttributes = array(); $whiteListTags = array(); $whiteListAttributes = array(); $noHtml = false; $whiteList = false; $blackList = false; $unfiltered = false; // Cycle through each of the user groups the user is in. // Remember they are include in the Public group as well. foreach ($userGroups AS $groupId) { // May have added a group by not saved the filters. if (!isset($filters->$groupId)) { continue; } // Each group the user is in could have different filtering properties. $filterData = $filters->$groupId; $filterType = strtoupper($filterData->filter_type); if ($filterType == 'NH') { // Maximum HTML filtering. $noHtml = true; } else if ($filterType == 'NONE') { // No HTML filtering. $unfiltered = true; } else { // Black or white list. // Preprocess the tags and attributes. $tags = explode(',', $filterData->filter_tags); $attributes = explode(',', $filterData->filter_attributes); $tempTags = array(); $tempAttributes = array(); foreach ($tags AS $tag) { $tag = trim($tag); if ($tag) { $tempTags[] = $tag; } } foreach ($attributes AS $attribute) { $attribute = trim($attribute); if ($attribute) { $tempAttributes[] = $attribute; } } // Collect the black or white list tags and attributes. // Each list is cummulative. if ($filterType == 'BL') { $blackList = true; $blackListTags = array_merge($blackListTags, $tempTags); $blackListAttributes = array_merge($blackListAttributes, $tempAttributes); } else if ($filterType == 'WL') { $whiteList = true; $whiteListTags = array_merge($whiteListTags, $tempTags); $whiteListAttributes = array_merge($whiteListAttributes, $tempAttributes); } } } // Remove duplicates before processing (because the black list uses both sets of arrays). $blackListTags = array_unique($blackListTags); $blackListAttributes = array_unique($blackListAttributes); $whiteListTags = array_unique($whiteListTags); $whiteListAttributes = array_unique($whiteListAttributes); // Unfiltered assumes first priority. if ($unfiltered) { // Dont apply filtering. } else { // Black lists take second precedence. if ($blackList) { // Remove the white-listed attributes from the black-list. $filter = JFilterInput::getInstance( array_diff($blackListTags, $whiteListTags), // blacklisted tags array_diff($blackListAttributes, $whiteListAttributes), // blacklisted attributes 1, // blacklist tags 1 // blacklist attributes ); } // White lists take third precedence. else if ($whiteList) { $filter = JFilterInput::getInstance($whiteListTags, $whiteListAttributes, 0, 0, 0); // turn off xss auto clean } // No HTML takes last place. else { $filter = JFilterInput::getInstance(); } $text = $filter->clean($text, 'html'); } return $text; } }