' . $bridgeClass::NAME . ''; $description = $bridgeClass::DESCRIPTION; $card = <<

{$name}

{$description}

CARD; // If we don't have any parameter for the bridge, we print a generic form to load it. if(count($bridgeClass::PARAMETERS) == 0){ $card .= HTMLUtils::getFormHeader($bridgeName); if($isActive){ if(defined('PROXY_URL') && PROXY_BYBRIDGE){ $idArg = 'arg-' . urlencode($bridgeName) . '-' . urlencode('proxyoff') . '-' . urlencode('_noproxy'); $card .= '' . PHP_EOL; $card .= '
' . PHP_EOL; } $card .= HTMLUtils::getHelperButtonsFormat($formats); } else { $card .= 'Inactive'; } $card .= '' . PHP_EOL; } $hasGlobalParameter = array_key_exists('global', $bridgeClass::PARAMETERS); if($hasGlobalParameter){ $globalParameters = $bridgeClass::PARAMETERS['global']; } foreach($bridgeClass::PARAMETERS as $parameterName => $parameter){ if(!is_numeric($parameterName) && $parameterName == 'global') continue; if($hasGlobalParameter) $parameter = array_merge($parameter, $globalParameters); if(!is_numeric($parameterName)) $card .= '
' . $parameterName . '
' . PHP_EOL; $card .= HTMLUtils::getFormHeader($bridgeName); foreach($parameter as $id=>$inputEntry){ $additionalInfoString = ''; if(isset($inputEntry['required']) && $inputEntry['required'] === true) $additionalInfoString .= ' required'; if(isset($inputEntry['pattern'])) $additionalInfoString .= ' pattern="' . $inputEntry['pattern'] . '"'; if(isset($inputEntry['title'])) $additionalInfoString .= ' title="' . $inputEntry['title'] . '"'; if(!isset($inputEntry['exampleValue'])) $inputEntry['exampleValue'] = ''; if(!isset($inputEntry['defaultValue'])) $inputEntry['defaultValue'] = ''; $idArg = 'arg-' . urlencode($bridgeName) . '-' . urlencode($parameterName) . '-' . urlencode($id); $card .= '' . PHP_EOL; if(!isset($inputEntry['type']) || $inputEntry['type'] == 'text'){ $card .= '
' . PHP_EOL; } elseif($inputEntry['type'] == 'number'){ $card .= '
' . PHP_EOL; } else if($inputEntry['type'] == 'list'){ $card .= '
'; } elseif($inputEntry['type'] == 'checkbox'){ if($inputEntry['defaultValue'] === 'checked') $card .= '
' . PHP_EOL; else $card .= '
' . PHP_EOL; } } if($isActive){ if(defined('PROXY_URL') && PROXY_BYBRIDGE){ $idArg = 'arg-' . urlencode($bridgeName) . '-' . urlencode('proxyoff') . '-' . urlencode('_noproxy'); $card .= '' . PHP_EOL; $card .= '
' . PHP_EOL; } $card .= HTMLUtils::getHelperButtonsFormat($formats); } else { $card .= 'Inactive'; } $card .= '' . PHP_EOL; } $card .= ''; $card .= '

' . $bridgeClass::MAINTAINER . '

'; $card .= ''; return $card; } private static function getHelperButtonsFormat($formats){ $buttons = ''; foreach($formats as $name){ $buttons .= '' . PHP_EOL; } return $buttons; } private static function getFormHeader($bridge){ return << EOD; } } class HTMLSanitizer { var $tagsToRemove; var $keptAttributes; var $onlyKeepText; public static $DEFAULT_CLEAR_TAGS = ["script", "iframe", "input", "form"]; public static $KEPT_ATTRIBUTES = ["title", "href", "src"]; public static $ONLY_TEXT = []; public function __construct($tags_to_remove = null , $kept_attributes = null , $only_keep_text = null){ $this->tagsToRemove = is_null($tags_to_remove) ? HTMLSanitizer::$DEFAULT_CLEAR_TAGS : $tags_to_remove; $this->keptAttributes = is_null($kept_attributes) ? HTMLSanitizer::$KEPT_ATTRIBUTES : $kept_attributes; $this->onlyKeepText = is_null($only_keep_text) ? HTMLSanitizer::$ONLY_TEXT : $only_keep_text; } public function sanitize($textToSanitize){ $htmlContent = str_get_html($textToSanitize); foreach($htmlContent->find('*[!b38fd2b1fe7f4747d6b1c1254ccd055e]') as $element){ if(in_array($element->tag, $this->onlyKeepText)){ $element->outertext = $element->plaintext; } elseif(in_array($element->tag, $this->tagsToRemove)){ $element->outertext = ''; } else { foreach($element->getAllAttributes() as $attributeName => $attribute){ if(!in_array($attributeName, $this->keptAttributes)) $element->removeAttribute($attributeName); } } } return $htmlContent; } public static function defaultImageSrcTo($content, $server){ foreach($content->find('img') as $image){ if(is_null(strpos($image->src, "http")) && is_null(strpos($image->src, "//")) && is_null(strpos($image->src, "data:"))) $image->src = $server . $image->src; } return $content; } }