1
As you have possibly have seen, we are including HTML-files directly into WF-Sections. However, the code is not stripping the header and html-tags. I found that in the freecontent-module some simple, but effective functions are used to reduce the HTML-content to only the body part. This is what I included: in article.php at line
========= Start of the code ===============
# this is the original line:
#
# $articletag['maintext'] = fread($fp, filesize($maintextfile));
// NEW!
$htmlData = fread($fp, filesize($maintextfile));
$htmlData = str_replace("\r\n", " ", $htmlData);
$htmlData = str_replace("\n", " ", $htmlData);
$htmlData = preg_replace("/\s+/", " ", $htmlData);
if (preg_match('|<\s*head\s*>(.*)<\s*/\s*head\s*>.*?<\s*body\s?.*?>(.*)<\s*/\s*body\s*>|i',$htmlData, $match) !==0) {
$headPart = $match[1];
$bodyPart = $match[2];
preg_match_all('|<\s*link\s+.*?>|i', $headPart, $match);
$headPart_tmp = implode($match[0],' ');
preg_match_all('|<\s*script\s+.*?>\s*<\s*/\s*script\s*>|i', $headPart, $match);
$headPart = $headPart_tmp.implode($match[0],' ');
} else {
$headPart = '';
$bodyPart = '';
}
$articletag['maintext'] = $bodyPart;
// END OF NEW
========= End of the code ===============
Perhaps this can end up in the mainstream, but otherwise other people can include this themselves.
Have fun!