<?php
/*############################################################
String Converter 0.46
--------------------------------------------------------------
This is a simpel text string converter...
$a_string
Your text variabel have to go here.
$a_url_target
Select between the different url target types. (e.g. '_blank', '_self' or '_top')
Default: '_blank'
$a_url_length
The maks length a URL is visible. ('...' will finish the url if to long)
Made by Thomas Hansen
http://domaz.dk - find more scripts!
############################################################*/
function a_string_out($a_string, $a_url_target = "_blank", $a_url_length = "25") {
$a_string = " ".$a_string;
$url_ins_str = ' target="'.$a_url_target.'"';
$a_string = str_replace("&", '&', $a_string);
$a_string = str_replace("<", '<', $a_string);
$a_string = str_replace(">", '>', $a_string);
$a_string = str_replace("\n", '<br>\n', $a_string);
$a_string = preg_replace("/\[([biu])\]/i", '<$1>', $a_string); // convert
, or to html-tags
$a_string = preg_replace("/\[\/([biu])\]/i", '</$1>', $a_string); // convert , or to html-tags
// make LINK's automatically
$a_string = preg_replace_callback("/(ftp|http|https|telnet|news|nntp|file|irc):\/\/([a-z0-9~#&:;=!',_æøå\(\)\?\/\.\-\+\[\]\|\*\$\%\^\{\}]+)/i", create_function('$matches','if( strlen($matches[2]) > '.$a_url_length.' ) $name = substr($matches[2],0,'.$a_url_length.') . "..."; else $name = $matches[2]; return "<a".$url_ins_str." href=\"{$matches[1]}://{$matches[2]}\">$name</a>";'),$a_string);
$a_string = preg_replace_callback ("/( www\.)([a-z0-9~#&:;=!',_æøå\(\)\?\/\.\-\+\[\]\|\*\$\%\^\{\}]+)/i", create_function('$matches','if( strlen($matches[2]) > '.$a_url_length.' ) $name = substr($matches[1], 1).substr($matches[2],0,'.$a_url_length.') . "..."; else $name = substr($matches[1], 1).$matches[2]; return " <a".$url_ins_str." href=\"
http://".substr($matches[1], 1).$matches[2]."\">$name</a>";'), $a_string);
$a_string = preg_replace_callback ("/( ftp\.)([a-z0-9~#&:;=!',_æøå\(\)\?\/\.\-\+\[\]\|\*\$\%\^\{\}]+)/i", create_function('$matches','if( strlen($matches[2]) > '.$a_url_length.' ) $name = substr($matches[1], 1).substr($matches[2],0,'.$a_url_length.') . "..."; else $name = substr($matches[1], 1).$matches[2]; return " <a".$url_ins_str." href=\"
ftp://".substr($matches[1], 1).$matches[2]."\">$name</a>";'), $a_string);
// make EMAIL's automatically
$a_string = preg_replace("/[\\d\\w\\.\\-_]+@[\\d\\w\\-_\\.]+?\\.[\\w]{2,3}(\\.[\\w]{2,3})?/i", '<a href="mailto:\\0">\\0</a>', $a_string);
return substr($a_string, 1);
}
?>