feat: remove HTML blocks

This commit is contained in:
Hugo Poissonnet 2022-10-19 21:50:10 +02:00
parent 2a154a6eea
commit dd7f80ee5a
1 changed files with 12 additions and 1 deletions

View File

@ -30,7 +30,7 @@
* @link https://archivarix.com
*/
@ini_set( 'display_errors', 0 );
@ini_set( 'display_errors', 1 );
/**
* Switch mode to integrate with 3rd party CMS.
@ -393,6 +393,17 @@ function prepareContent( $file, $sourcePath )
$content = preg_replace( '~' . $includeCustom['KEYPHRASE'] . '~is', $includedContent, $content, $includeCustom['LIMIT'] );
}
}
$doc = new DOMDocument();
$doc->loadHTML($content);
$xpath = new DOMXpath($doc);
$hostedByElements = $xpath->query("//*[@id='text-6']");
$hostedByElements->item(0)?->remove();
$twitterWidgetElements = $xpath->query("//*[@id='twitter-2']");
$twitterWidgetElements->item(0)?->remove();
//$content = '';
$content = $doc->saveHTML();
if ( function_exists( 'mb_strlen' ) ) {
header( 'Content-Length: ' . mb_strlen( $content, '8bit' ), true );
}