<?php
function text_url($str, $target=NULL, $css_class=NULL)
{
$ins_str = "";
if ($css_class)
$ins_str .= " class=\"".$css_class."\"";
if ($target)
$ins_str .= " target=\"".$target."\"";
$str = preg_replace_callback ("/(ftp|http|https|telnet|news|nntp|file|irc):\/\/([a-z0-9~#&:;=!',_æøå\(\)\?\/\.\-\+\[\]\|\*\$\%\^\{\}]+)/i", create_function('$matches','if( strlen($matches[2]) > 25 ) $name = substr($matches[2],0,25) . ".."; else $name = $matches[2]; return "<a".$ins_str." href=\"{$matches[1]}://{$matches[2]}\">$name</a>";'),$str);
$str = preg_replace_callback ("/(\s|tp\:|\(|\[|\>)(www\.)([a-z0-9~#&:;=!',_æøå\(\)\?\/\.\-\+\[\]\|\*\$\%\^\{\}]+)/i", create_function('$matches','if( strlen($matches[3]) > 25 ) $name = substr($matches[3],0,25) . ".."; else $name = $matches[3]; return "<a".$ins_str." href=\"
http://$matches[2]$matches[3]\">$name</a>";'), $str);
$str = preg_replace_callback ("/(\s|tp\:|\(|\[|\>)(ftp\.)([a-z0-9~#&:;=!',_æøå\(\)\?\/\.\-\+\[\]\|\*\$\%\^\{\}]+)/i", create_function('$matches','if( strlen($matches[3]) > 25 ) $name = substr($matches[3],0,25) . ".."; else $name = $matches[3]; return "<a".$ins_str." href=\"
ftp://$matches[2]$matches[3]\">$name</a>";'), $str);
return $str;
}
$mysql['host'] = 'localhost'; // Host til database
$mysql['username'] = 'root'; // Brugernavn til database
$mysql['password'] = ''; // Kodeord til database
$mysql['database'] = 'nytest'; // Database
mysql_connect($mysql['host'],$mysql['username'],$mysql['password']);
mysql_select_db($mysql['database']);
$query = mysql_query("SELECT * FROM forum") or die(mysql_error());
while ($forum = mysql_fetch_assoc($query))
{
if ($i++ != 0)
echo '';
echo $forum['overskrift'];
echo "<br>";
echo text_url($forum['tekst'],"_blank");
}
?>