<?
	//--- check url's on length ---//
	function checkurl($url)
	{
		//--- url must begin with http:// or intern links will occur ---//
		if (substr($url, 0, 7) != "http://")
			$url = "http://" . $url;
		
		//--- check if the url is bigger than 40 chars ---//
		if (strlen($url) > 40)
			$short = substr($url, 0, 18) . "...." . substr($url, -18);
		else
			$short = $url;
		
		//--- return the possible ajustments ---//
		return "<a href=\"" . $url . "\" title=\"" . $url . "\" target=\"_blank\">" . $short . "</a>";
	}

	//--- url recognition ---//
	function parse_tekst($tekst)
	{
		$tekst = preg_replace("/\[url\](.+?)\[\/url\]/sie", "checkurl('$1')", $tekst);
		//--- some posibile other UBB codes ---//
		return $tekst;
	}
?>