Seite 2 von 2

Verfasst: 23.12.2004 15:20
von BZebra
Ah, ich habs so gut wie.

Also, erst mal die original Anleitung zum relative link MOD:

Code: Alles auswählen

###############################################
##	Hack Title:		Relative links
##	Hack Version:	1.0.0
##	Author:			Freakin' Booty ;-P
##	Website:		http://freakingbooty.no-ip.com
##	Description:	Adds the functionality to point to links relative to the forum's root
##					directory. Moving a forum to another server will automatically update the
##					relative links once the variables in the board configuration have been
##					updated.
##	Compatibility:	2.0.0 - 2.0.10
##	Usage:
##		[url]rel://viewtopic.php?t=1[/url]
##		[url=rel://viewforum.php?f=1]description[/url]
##
##	Installation Level: Easy
##	Installation Time: 2 - 3 minutes
##
##	Files To Edit: 1
##		includes/bbcode.php
##
##	Included Files: 0
##
##	History:
##		1.0.0	Initial release
##
##	Author Notes:
##		From now on, I will be supplying patch files as much as possible. If you don't know
##		what these are, either Google it or just leave them alone.
##
##	Support:		http://www.phpbbhacks.com/forums
##	Copyright:		©2004 Freakin' Booty ;-P - Relative links 1.0.0
##
###############################################
##   You downloaded this hack from phpBBHacks.com, the #1 source for phpBB related downloads.
##   Please visit http://www.phpbbhacks.com/forums for support.
###############################################
##
###############################################
##	This hack is released under the GPL License.
##	This hack can be freely used, but not distributed, without permission.
##	Intellectual Property is retained by the hack author(s) listed above.
###############################################

#
#-----[ OPEN ]--------------------------------------------
#
includes/bbcode.php

#
#-----[ FIND ]--------------------------------------------
#
	$bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
	$bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url4']);

#
#-----[ AFTER, ADD ]--------------------------------------
#
	$bbcode_tpl['url5'] = str_replace('{URL}', bbcode_relative_links() . '\\2', $bbcode_tpl['url']);
	$bbcode_tpl['url5'] = str_replace('{DESCRIPTION}', bbcode_relative_links() . '\\2', $bbcode_tpl['url5']);

	$bbcode_tpl['url6'] = str_replace('{URL}', bbcode_relative_links() . '\\2', $bbcode_tpl['url']);
	$bbcode_tpl['url6'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url6']);

#
#-----[ FIND ]--------------------------------------------
#
	// matches a [url]xxxx://www.phpbb.com[/url] code..
	$patterns[] = "#\[url\]([\w]+?://[^ \"\n\r\t<]*?)\[/url\]#is";
	$replacements[] = $bbcode_tpl['url1'];

#
#-----[ BEFORE, ADD ]-------------------------------------
#
	// matches a [url]rel://viewtopic.php[/url] code..
	$patterns[] = "#\[url\](rel://[\./]*([^ \"\n\r\t<]*?))\[/url\]#is";
	$replacements[] = $bbcode_tpl['url5'];

#
#-----[ FIND ]--------------------------------------------
#
	// [url=xxxx://www.phpbb.com]phpBB[/url] code..
	$patterns[] = "#\[url=([\w]+?://[^ \"\n\r\t<]*?)\](.*?)\[/url\]#is";
	$replacements[] = $bbcode_tpl['url3'];

#
#-----[ BEFORE, ADD ]-------------------------------------
#
	// matches a [url=rel://viewtopic.php]view topic[/url] code..
	$patterns[] = "#\[url\=(rel://[\./]*([^ \"\n\r\t<]*?))\](.*?)\[/url\]#is";
	$replacements[] = $bbcode_tpl['url6'];

#
#-----[ FIND ]--------------------------------------------
#
?>

#
#-----[ BEFORE, ADD ]-------------------------------------
#
function bbcode_relative_links()
{
	global $board_config;

	$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($board_config['script_path']));
	$script_name = ($script_name != '') ? $script_name . '/' : '/';
	$server_name = trim($board_config['server_name']) . '/';
	$server_protocol = ($board_config['cookie_secure']) ? 'https://' : 'http://';
	$server_port = ($board_config['server_port'] <> 80) ? ':' . trim($board_config['server_port']) . '/' : '/';

	return $server_protocol . $server_name . $script_name;
}

#
#-----[ SAVE & CLOSE ALL FILES ]--------------------------
#
Die Abgewandelte Form müsste so aussehen:
#
#-----[ OPEN ]--------------------------------------------
#
includes/bbcode.php

#
#-----[ FIND ]--------------------------------------------
#
$bbcode_tpl['url4'] = str_replace('{URL}', 'http://\\1', $bbcode_tpl['url']);
$bbcode_tpl['url4'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url4']);

#
#-----[ AFTER, ADD ]--------------------------------------
#
$bbcode_tpl['url5'] = str_replace('{URL}', '\\1', $bbcode_tpl['rel']);
$bbcode_tpl['url5'] = str_replace('{DESCRIPTION}', '\\1', $bbcode_tpl['url5']);

$bbcode_tpl['url6'] = str_replace('{URL}', '\\1', $bbcode_tpl['rel']);
$bbcode_tpl['url6'] = str_replace('{DESCRIPTION}', '\\3', $bbcode_tpl['url6']);

#
#-----[ FIND ]--------------------------------------------
#
// matches a [url]xxxx://www.phpbb.com[/url] code..
$patterns[] = "#\[url\]([\w]+?://[^ \"\n\r\t<]*?)\[/url\]#is";
$replacements[] = $bbcode_tpl['url1'];

#
#-----[ BEFORE, ADD ]-------------------------------------
#
// matches a [url]rel://viewtopic.php[/url] code..
$patterns[] = "#\[url\](forum_root_path[\./]*([^ \"\n\r\t<]*?))\[/url\]#is";
$replacements[] = $bbcode_tpl['url5'];

#
#-----[ FIND ]--------------------------------------------
#
// [url=xxxx://www.phpbb.com]phpBB[/url] code..
$patterns[] = "#\+?://[^ \"\n\r\t<]*?)\](.*?)\[/url\]#is";
$replacements[] = $bbcode_tpl['url3'];

#
#-----[ BEFORE, ADD ]-------------------------------------
#
// matches a [url=rel://viewtopic.php]view topic
code..
$patterns[] = "#\[url\=(forum_root_path[\./]*([^ \"\n\r\t<]*?))\](.*?)\[/url\]#is";
$replacements[] = $bbcode_tpl['url6'];

#
#-----[ FIND ]--------------------------------------------
#

// pad it with a space so we can match things at the start of the 1st line.
$ret = ' ' . $text;

#
#-----[ AFTER, ADD ]--------------------------------------
#

// matches a "forum_root_path/xxxx.yyyy[/zzzz]" kinda lazy URL thing
// Must contain at least 1 dot. 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 ])((forum_root_path)[^ \"\t\n\r<]*)#is", "\\1<a href=\"\\2\" target=\"_self\">\\2</a>", $ret);

#
#-----[ OPEN ]--------------------------------------------
#
templates/subSilver/bbcode.tpl

#
#-----[ FIND ]--------------------------------------------
#

<!-- BEGIN url --><a href="{URL}" target="_blank" class="postlink">{DESCRIPTION}</a><!-- END url -->

#
#-----[ AFTER, ADD ]--------------------------------------
#

<!-- BEGIN rel --><a href="{URL}" target="_self" class="postlink">{DESCRIPTION}</a><!-- END rel -->

#
#-----[ SAVE & CLOSE ALL FILES ]--------------------------
#
Für forum_root_path brauch ich jetzt noch die Variable. $phpbb_root_path vielleicht? Aber keine Ahnung wie man die einbaut.

Ich hab den Anfangsteil der URL bei mir jetzt mal im Klartext eingetragen, da funktioniert es für die Versionen:

Code: Alles auswählen

http://meinedomain.tld/forum/viewtopic.php?irgdenwas
[url]http://meinedomain.tld/forum/viewtopic.php?irgdenwas[/url]
[url=http://meinedomain.tld/forum/viewtopic.php?irgdenwas]Beitrag[/url]

Verfasst: 28.01.2005 03:36
von BZebra
BZebra hat geschrieben:Für forum_root_path brauch ich jetzt noch die Variable. $phpbb_root_path vielleicht? Aber keine Ahnung wie man die einbaut.
Wollte noch mal fragen, ob und wie man an die drei blau markierten stellen den forum_root_path automatisch einsetzen lassen kann.
Dann könnte man nämlich daraus mal nen MOD machen. Den root_path dort direkt einzutragen wäre ein bißchen blöd und schon garnicht EM-kompatibel. Außerdem könnte evt. mal jemand drüber schauen, ob der Code so korrekt ist.

Verfasst: 28.01.2005 19:23
von Nico Haase
naja, wenn du eine variable mit dem wert hast, setzt du die einfach ein ;) problem wird nur sein: wo kriegemer die variable her? war da nich eine in $board_config[]? moooooment mal.... die array-elemente script-host und script-path sollten es sein, siehe http://www.phpbb.de/doku/doku2.php?mode=config#config