$htmlshift+=$replacelength-$replacepart;// HTML might have moved around if we replaced multi-byte characters
if($replacepart>=$textlength)
break;// we have replaced everything expected, otherwise more left (due to hitting an HTML tag)
if($replacepart>=$textlength)
break;// we have replaced everything expected, otherwise more left (due to hitting an HTML tag)
$textlength-=$replacepart;
$textoffset+=$replacepart;
$texttohtml+=strlen($nexttagmatch[0]);
$nexttagmatch=array_shift($tagmatches);
}
$textlength-=$replacepart;
$textoffset+=$replacepart;
$texttohtml+=strlen($nexttagmatch[0]);
$nexttagmatch=array_shift($tagmatches);
}
}
}
if(@$options['showurllinks']){// we need to ensure here that we don't put new links inside existing ones
require_onceQA_INCLUDE_DIR.'qa-util-string.php';
if(@$options['showurllinks']){// we need to ensure here that we don't put new links inside existing ones
require_onceQA_INCLUDE_DIR.'qa-util-string.php';
$htmlunlinkeds=array_reverse(preg_split('|<[Aa]\s+[^>]+>.*</[Aa]\s*>|',$html,-1,PREG_SPLIT_OFFSET_CAPTURE));// start from end so we substitute correctly
$htmlunlinkeds=array_reverse(preg_split('|<[Aa]\s+[^>]+>.*</[Aa]\s*>|',$html,-1,PREG_SPLIT_OFFSET_CAPTURE));// start from end so we substitute correctly
foreach($htmlunlinkedsas$htmlunlinked){// and that we don't detect links inside HTML, e.g. <img src="http://...">
$thishtmluntaggeds=array_reverse(preg_split('/<[^>]*>/',$htmlunlinked[0],-1,PREG_SPLIT_OFFSET_CAPTURE));// again, start from end
foreach($htmlunlinkedsas$htmlunlinked){// and that we don't detect links inside HTML, e.g. <img src="http://...">
$thishtmluntaggeds=array_reverse(preg_split('/<[^>]*>/',$htmlunlinked[0],-1,PREG_SPLIT_OFFSET_CAPTURE));// again, start from end
foreach($thishtmluntaggedsas$thishtmluntagged){
$innerhtml=$thishtmluntagged[0];
foreach($thishtmluntaggedsas$thishtmluntagged){
$innerhtml=$thishtmluntagged[0];
if(is_numeric(strpos($innerhtml,'://'))){// quick test first