$htmlshift+=$replacelength-$replacepart;// HTML might have moved around if we replaced multi-byte characters
if($replacepart>=$textlength)
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.'util/string.php';
require_onceQA_INCLUDE_DIR.'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
$thishtmluntaggeds=array_reverse(preg_split('/<[^>]*>/',$htmlunlinked[0],-1,PREG_SPLIT_OFFSET_CAPTURE));// again, start from end
foreach($thishtmluntaggedsas$thishtmluntagged){
$innerhtml=$thishtmluntagged[0];
$innerhtml=$thishtmluntagged[0];
if(is_numeric(strpos($innerhtml,'://'))){// quick test first
// Check the validity of the currently entered directory (if any)
// Check the validity of the currently entered directory (if any)
$directory=qa_opt('event_logger_directory');
$directory=qa_opt('event_logger_directory');
$note=null;
$error=null;
$note=null;
$error=null;
if(!strlen($directory))
$note='Please specify a directory that is writable by the web server.';
$note='Please specify a directory that is writable by the web server.';
elseif(!file_exists($directory))
$error='This directory cannot be found. Please enter the full path.';
$error='This directory cannot be found. Please enter the full path.';
elseif(!is_dir($directory))
$error='This is a file. Please enter the full path of a directory.';
$error='This is a file. Please enter the full path of a directory.';
elseif(!is_writable($directory))
$error='This directory is not writable by the web server. Please choose a different directory, use chown/chmod to change permissions, or contact your web hosting company for assistance.';
$error='This directory is not writable by the web server. Please choose a different directory, use chown/chmod to change permissions, or contact your web hosting company for assistance.';