Seite 1 von 3
Url mit Klammern
Verfasst: 01.09.2006 10:29
von I-Jack
Hallo Leute,
habe folgendes Problem, wenn jemand eine URL bei mir im Forum postet und diese URL eine Klammer enthält, dann wird diese nicht richtig dargestellt. Wo müsste ich was ändern damit es funktionieren würde?
Vielen Dank.
Verfasst: 01.09.2006 10:30
von Michael Zacher
Wenn man die URL mit dem Tag
Code: Alles auswählen
[url=http://lalala.de/muh(haha).php]Beschreibung[/url]
einfügt sollte es eigentlich gehen.
Verfasst: 01.09.2006 10:31
von SoLo1905
wie wird denn z.B. welche adresse dargestellt also
ein beispiel:
diese adresse
www.ichbindieseite.de
wird so angezeigt
www.ich)bin0dieseite.de
Verfasst: 01.09.2006 10:35
von I-Jack
SoLo1905 hat geschrieben:wie wird denn z.B. welche adresse dargestellt also
ein beispiel:
diese adresse
www.ichbindieseite.de
wird so angezeigt
www.ich)bin0dieseite.de
wie dein letztes Beispiel
Verfasst: 01.09.2006 10:40
von SoLo1905
Öffne
./includes/bbcode
Suche
und kopiere mal die davor liegenden 5 zeilen und die davor kommende 5 zeilen
Verfasst: 01.09.2006 10:45
von I-Jack
Hab mal beide Funkionen kopiert
Code: Alles auswählen
function make_clickable($text)
{
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);
// pad it with a space so we can match things at the start of the 1st line.
$ret = ' ' . $text;
// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
// xxxx can only be alpha characters.
// yyyy is anything up to the first space, newline, comma, double quote or <
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret);
// matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
// zzzz is optional.. will contain everything up to the first space, newline,
// comma, double quote or <.
$ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
// matches an email@domain type address at the start of a line, or after a space.
// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
$ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
// Remove our padding..
$ret = substr($ret, 1);
return($ret);
}
/**
* Nathan Codding - Feb 6, 2001
* Reverses the effects of make_clickable(), for use in editpost.
* - Does not distinguish between "www.xxxx.yyyy" and "http://aaaa.bbbb" type URLs.
*
*/
function undo_make_clickable($text)
{
$text = preg_replace("#<!-- BBCode auto-link start --><a href=\"(.*?)\" target=\"_blank\">.*?</a><!-- BBCode auto-link end -->#i", "\\1", $text);
$text = preg_replace("#<!-- BBcode auto-mailto start --><a href=\"mailto:(.*?)\">.*?</a><!-- BBCode auto-mailto end -->#i", "\\1", $text);
return $text;
}
Verfasst: 01.09.2006 10:51
von SoLo1905
ersetze mal die von dir geschriebene code durch
Code: Alles auswählen
function make_clickable($text)
{
$text = preg_replace('#(script|about|applet|activex|chrome):#is', "\\1:", $text);
// pad it with a space so we can match things at the start of the 1st line.
$ret = ' ' . $text;
// matches an "xxxx://yyyy" URL at the start of a line, or after a space.
// xxxx can only be alpha characters.
// yyyy is anything up to the first space, newline, comma, double quote or <
$ret = preg_replace("#(^|[\n ])([\w]+?://[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret);
// matches a "www|ftp.xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 2 dots. xxxx contains either alphanum, or "-"
// zzzz is optional.. will contain everything up to the first space, newline,
// comma, double quote or <.
$ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\#$%&~/.\-;:=,?@\[\]+]*)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
// matches an email@domain type address at the start of a line, or after a space.
// Note: Only the followed chars are valid; alphanums, "-", "_" and or ".".
$ret = preg_replace("#(^|[\n ])([a-z0-9&\-_.]+?)@([\w\-]+\.([\w\-\.]+\.)*[\w]+)#i", "\\1<a href=\"mailto:\\2@\\3\">\\2@\\3</a>", $ret);
$ret = preg_replace("/<a href=(.*?)>((http:\/\/|https:\/\/|ftp:\/\/|www.).*?)<\/a>/ie", "(strlen(\"\\2\") > 65 && !eregi(\"<\", \"\\2\") ) ? '<a href='.stripslashes(\"\\1\").'>'.substr(\"\\2\", 0, 35) . ' [...] ' . substr(\"\\2\", -25).'</a>' : '<a href='.stripslashes(\"\\1\").'>'.\"\\2\".'</a>'", $ret);
// Remove our padding..
$ret = substr($ret, 1);
return($ret);
}
/**
* Nathan Codding - Feb 6, 2001
* Reverses the effects of make_clickable(), for use in editpost.
* - Does not distinguish between "www.xxxx.yyyy" and "http://aaaa.bbbb" type URLs.
*
*/
function undo_make_clickable($text)
{
$text = preg_replace("#<!-- BBCode auto-link start --><a href=\"(.*?)\" target=\"_blank\">.*?</a><!-- BBCode auto-link end -->#i", "\\1", $text);
$text = preg_replace("#<!-- BBcode auto-mailto start --><a href=\"mailto:(.*?)\">.*?</a><!-- BBCode auto-mailto end -->#i", "\\1", $text);
return $text;
}
Verfasst: 01.09.2006 10:58
von I-Jack
Funktioniert leider nicht, aber schonmal vielen Dank.
Verfasst: 01.09.2006 10:59
von SoLo1905
pff verlink mal die bbCode als .txt datei
Verfasst: 01.09.2006 11:02
von I-Jack