Project

General

Profile

« Previous | Next » 

Revision 761

Added by thorn over 16 years ago

search: great speed-up with large pages - requires PHP >= 4.3.3; small speed-up for PHP < 4.3.3.
FCK-Editor: loads large pages faster

View differences:

frontend.functions.php
80 80
	$string = strtr($string, $string_ul_umlauts);
81 81
	// special-feature: '|' means word-boundary (\b). Searching for 'the|' will find 'the', but not 'thema'.
82 82
	$string = strtr($string, array('\\|'=>'\b'));
83
	
84 83
	// the highlighting
85 84
	// match $string, but not inside <style>...</style>, <script>...</script>, <!--...--> or HTML-Tags
86 85
	// split $string into pieces - "cut away" styles, scripts, comments, HTML-tags and eMail-addresses
87 86
	// for HTML-Tags use <(?:[^<]|<.*>)*> which will match strings like <input ... value="<b>value</b>" >
88
	$matches = preg_split("/(<style.*<\/style>|<script.*<\/script>|<!--.*-->|<(?:[^<]|<.*>)*>|\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b)/iUs",$foo,-1,(PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY));
87
	$matches = preg_split("/(<style.*<\/style>|<script.*<\/script>|<!--.*-->|<(?:[^<]|<.*>)*>|\b[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,8}\b)/iUs",$foo,-1,(PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY));
89 88
	if(is_array($matches) && $matches != array()) {
90 89
		$foo = "";
91
		$string = strtr($string, array('&lt;'=>'<', '&gt;'=>'>', '&amp;'=>'&', '&quot;'=>'"', '&#39;'=>'\'', '&nbsp;'=>"\xC2\xA0"));
92 90
		foreach($matches as $match) {
93
			if($match{0}!="<" && !preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i', $match)) {
91
			if($match{0}!="<" && !preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,8}$/i', $match)) {
94 92
				$match = strtr($match, array('&lt;'=>'<', '&gt;'=>'>', '&amp;'=>'&', '&quot;'=>'"', '&#39;'=>'\'', '&nbsp;'=>"\xC2\xA0"));
95 93
				$match = preg_replace('/('.$string.')/iS', '_span class=_highlight__$1_/span_',$match);
96 94
				$match = strtr($match, array('<'=>'&lt;', '>'=>'&gt;', '&'=>'&amp;', '"'=>'&quot;', '\''=>'&#39;', "\xC2\xA0"=>'&nbsp;'));

Also available in: Unified diff