All pastes #144734 Raw Edit

ingo

public php v1 · immutable
#144734 ·published 2006-08-22 17:32 UTC
rendered paste body
// Truncate v1.0 - addblock$isTruncated = false;if (!function_exists(clbTruncate)) {	function clbTruncate($match) {		global $isTruncated;				$intag = false;		for ($i = 0; $i < strlen($match[2]); $i++) {			$char = $match[2][$i];						if (!$intag && $char == '<') {				$intag = true;				$newstr .= $char;			} elseif ($intag && $char == '>') {				$intag = false;				$newstr .= $char;			} elseif ($intag) {				$newstr .= $char;			} else {				if ($match[1] > 0)					$newstr .= $char;				if ($match[1] == 0) {					$newstr .= '...';					$isTruncated = true;				}				$match[1]--;			}		}		return $newstr;	}}$output = preg_replace_callback('#\[truncate=(.*?)\](.*?)\[/truncate\]#i', clbTruncate, $output);if ($isTruncated) {	$output = str_replace("[trunc-link]", "<a href=\"truncated.php?subaction=showfull&amp;id=$news_arr[0]&amp;archive=$archive&amp;start_from=$my_start_from&amp;ucat=$news_arr[6]&amp;$user_query\">", $output);	$output = str_replace("[/trunc-link]", "</a>", $output);} else {	$output = preg_replace("'\\[trunc-link\\].*?\\[/trunc-link\\]'si", "<!-- no truncate link -->", $output);}// Truncate v1.0 - End addblock