Seite 2 von 2

Verfasst: 11.08.2005 11:46
von shebaka
Genau!

Aber das tut es leider nicht!

Verfasst: 11.08.2005 14:38
von shebaka
Ich nehme an, dass das ganze unheil in der "include\bbcode.php" entsteht.

Deshalb poste ich die Datei hier mal:
http://board.shebaka.org/bbcode.txt

Ich hab sie schon durchgerackert. Komme aber nicht dahinter!

Verfasst: 11.08.2005 16:11
von shebaka
Ich hab mir zuerst die original BBCODE.php installiert.

Dann hab ich den Smile Mod eingebaut und jetzt wollte ich wieder SafeUrlHack einbauen und ab dann trat wieder der alte Fehler auf!

Hier ist der Mod:

Code: Alles auswählen

--- includes/bbcode.php.orig	2003-07-20 17:42:24.000000000 +0200
+++ includes/bbcode.php	2003-10-23 18:58:18.000000000 +0200
@@ -94,6 +94,7 @@
 
 	$bbcode_tpl['img'] = str_replace('{URL}', '\\1', $bbcode_tpl['img']);
 
+	/*
 	// We do URLs in several different ways..
 	$bbcode_tpl['url1'] = str_replace('{URL}', '\\1', $bbcode_tpl['url']);
 	$bbcode_tpl['url1'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url1']);
@@ -106,6 +107,7 @@
 
 	$bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
 	$bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\5', $bbcode_tpl['url4']);
+	*/
 
 	$bbcode_tpl['email'] = str_replace('{EMAIL}', '\\1', $bbcode_tpl['email']);
 
@@ -114,6 +116,20 @@
 	return $bbcode_tpl;
 }
 
+function checklink($url,$description='',$template='',$prefix='http://anonym.to/?')
+{
+	global $board_config, $HTTP_HOST;
+	
+	// Detect if URL is local - may need some more work
+	if (!stristr($url,$board_config['sitename']) && !stristr($url,$HTTP_HOST.'/'))
+	{
+		$url = $prefix.$url;
+	}
+	$template = str_replace('{URL}',$url,$template);
+	$template = str_replace('{DESCRIPTION}',$description,$template);
+
+	return $template;
+}
 
 /**
  * Does second-pass bbencoding. This should be used before displaying the message in
@@ -124,6 +140,7 @@
 {
 	global $lang, $bbcode_tpl;
 
+
 	// pad it with a space so we can distinguish between FALSE and matching the 1st char (index 0).
 	// This is important; bbencode_quote(), bbencode_list(), and bbencode_code() all depend on it.
 	$text = " " . $text;
@@ -198,20 +215,20 @@
 	$replacements[] = $bbcode_tpl['img'];
 
 	// matches a [url]xxxx://www.phpbb.com[/url] code..
-	$patterns[] = "#\[url\]([\w]+?://.*?[^ \"\n\r\t<]*?)\[/url\]#is";
-	$replacements[] = $bbcode_tpl['url1'];
+	$patterns[] = "#\[url\]([\w]+?://.*?[^ \"\n\r\t<]*?)\[/url\]#eis";
+	$replacements[] = "checklink('\\1', '\\1','{$bbcode_tpl['url']}')";
 
 	// [url]www.phpbb.com[/url] code.. (no xxxx:// prefix).
-	$patterns[] = "#\[url\]((www|ftp)\.([\w\-]+\.)*?[\w\-]+\.[a-z]{2,4}(:?[0-9]*?/[^ \"\n\r\t<]*)?)\[/url\]#is";
-	$replacements[] = $bbcode_tpl['url2'];
+	$patterns[] = "#\[url\]((www|ftp)\.([\w\-]+\.)*?[\w\-]+\.[a-z]{2,4}(:?[0-9]*?/[^ \"\n\r\t<]*)?)\[/url\]#eis";
+	$replacements[] = "checklink('\\1', '\\1','{$bbcode_tpl['url']}')";
 
 	// [url=xxxx://www.phpbb.com]phpBB[/url] code..
-	$patterns[] = "#\[url=([\w]+?://.*?[^ \"\n\r\t<]*?)\](.*?)\[/url\]#is";
-	$replacements[] = $bbcode_tpl['url3'];
+	$patterns[] = "#\[url=([\w]+?://.*?[^ \"\n\r\t<]*?)\](.*?)\[/url\]#eis";
+	$replacements[] = "checklink('\\1', '\\2','{$bbcode_tpl['url']}')";
 
 	// [url=www.phpbb.com]phpBB[/url] code.. (no xxxx:// prefix).
-	$patterns[] = "#\[url=((www|ftp)\.([\w\-]+\.)*?[\w\-]+\.[a-z]{2,4}(:?[0-9]*?/[^ \"\n\r\t<]*)?)\](.*?)\[/url\]#is";
-	$replacements[] = $bbcode_tpl['url4'];
+	$patterns[] = "#\[url=((www|ftp)\.([\w\-]+\.)*?[\w\-]+\.[a-z]{2,4}(:?[0-9]*?/[^ \"\n\r\t<]*)?)\](.*?)\[/url\]#eis";
+	$replacements[] = "checklink('\\1', '\\5','{$bbcode_tpl['url']}')";
 
 	// [email]user@domain.tld[/email] code..
 	$patterns[] = "#\[email\]([a-z0-9&\-_.]+?@[\w\-]+\.([\w\-\.]+\.)?[\w]+)\[/email\]#si";
@@ -621,13 +638,13 @@
 	// 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]+?://.*?[^ \"\n\r\t<]*)#is", "\\1<a href=\"\\2\" target=\"_blank\">\\2</a>", $ret);
+	$ret = preg_replace("#(^|[\n ])([\w]+?://.*?[^ \"\n\r\t<]*)#eis", "checklink('\\2','\\2','\\1<a href=\"{URL}\" target=\"_blank\">{DESCRIPTION}</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\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#is", "\\1<a href=\"http://\\2\" target=\"_blank\">\\2</a>", $ret);
+	$ret = preg_replace("#(^|[\n ])((www|ftp)\.[\w\-]+\.[\w\-.\~]+(?:/[^ \"\t\n\r<]*)?)#eis", "checklink('http://\\2','\\2','\\1<a href=\"{URL}\" target=\"_blank\">{DESCRIPTION}</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 ".".
erkennt vielleicht jemand das Problem?