Autolinks Mod

Allgemeiner Support zum phpBB 2 Board und phpBB 2 Modifikationen
Forumsregeln
Auch wenn hier der Support für phpBB 2 weiterhin aufrecht erhalten bleibt, weisen wir darauf hin, dass das phpBB 2 nicht mehr offiziell unterstützt und weiterentwickelt wird!
Antworten
Holger
Beiträge: 2253
Registriert: Mi 17.Mär, 2004 18:09

Autolinks Mod

Beitrag von Holger »

Bin am Verzweifeln!
Ich habe den Autolinks-Mod ausgebaut, alles funktioniert wie es soll, aber wenn ich die includes/functions.php hochlade, dann hört die Seite in viewtopic nach dem overall_header auf zu laden und ist danach leer (grau).
Laut Anweisungen muss ich einen grossen Block einach rauslöschen aus functions.php. Gefunden, kein Problem, gelöscht. Danach das oben genannte Problem. Sobald ich die alte functions.php hochlade (nur diese) wird die Seite wieder normal geladen.

Was mache ich falsch?

Gruss
Holger
Real men don’t back up, they learn data recovery. ;-)
http://www.mysqldumper.de
http://www.mysqldumper.se
Benutzeravatar
oxpus
Administrator
Beiträge: 28737
Registriert: Mo 27.Jan, 2003 22:13
Wohnort: Bad Wildungen
Kontaktdaten:

Re: Autolinks Mod

Beitrag von oxpus »

Poste doch mal den Block, der raus sollte, dann schaue ich nachher mal nach.
Karsten Ude
-={ Das Mädchen für alles }=-
Kein Support per Messenger, Email oder PN! Unaufgeforderte Nachrichten werden ignoriert!
No support per Messenger, Email or PM. Each unasked message will be ignored!
Holger
Beiträge: 2253
Registriert: Mi 17.Mär, 2004 18:09

Re: Autolinks Mod

Beitrag von Holger »

Der hier:

Code: Alles auswählen

// Start Autolinks For phpBB2 MOD
//
// Obtain list of autolink words and build preg style replacement arrays for use by the
// calling script, note that the vars are passed as references this just makes it easier
// to return both sets of arrays
//
// This is a copy of phpBB's obtain_word_list() function with slight changes.
//
function obtain_autolink_list(&$orig_autolink, &$replacement_autolink, $forum_id)
{
	global $db, $userdata, $phpEx;

	$where = ( $forum_id == 'pm' ) ? "link_pm = 1" : "link_forum LIKE '%" . $forum_id . "%'";
	$perms = ( $userdata['session_logged_in'] ) ? (( $userdata['user_level'] == ADMIN ) ? ' AND link_viewing = 0' : (( $userdata['user_level'] == MOD ) ? ' AND link_viewing <= 1' : (( $userdata['user_level'] == USER ) ? ' AND link_viewing <= 3' : ' AND (link_viewing <= 2 OR link_viewing = 4)'))) : ' AND (link_viewing <= 2 OR link_viewing = 4)';

	$sql = "SELECT link_id, link_keyword, link_text, link_url, link_comment, link_style, link_int FROM  " . AUTOLINKS_TABLE . "
		WHERE $where $perms
		ORDER BY link_order
		ASC";

	if( !($result = $db->sql_query($sql)) )
	{
		message_die(GENERAL_ERROR, 'Could not get autolink data from database', '', __LINE__, __FILE__, $sql);
	}

	if( $row = $db->sql_fetchrow($result) )
	{
		do
		{
			// Munge word boundaries to stop autolinks from linking to themselves
			// or other autolinks in step 2 in the autolink_transform() function.
			$row['link_text'] = preg_replace('/(\b)/', '\\1ALSPACEHOLDER', $row['link_text']);
			$row['link_url'] = preg_replace('/(\b)/', '\\1ALSPACEHOLDER', $row['link_url']);
			$row['link_comment'] = preg_replace('/(\b)/', '\\1ALSPACEHOLDER', $row['link_comment']);
			$row['link_style'] = preg_replace('/(\b)/', '\\1ALSPACEHOLDER', $row['link_style']);

			$internal = ( !$row['link_int'] ) ? ' target="new"' : '';
			$comment = ( $row['link_comment'] ) ? ' title="' . htmlspecialchars($row['link_comment']) . '"' : '';
			$style = ( $row['link_style'] ) ? ' style="' . htmlspecialchars($row['link_style']) . '"' : '';

			$orig_autolink[] = '/(?<![\/\w@\.:-])(?!\.\w)(' . phpbb_preg_quote($row['link_keyword'], '/'). ')(?![\/\w@:-])(?!\.\w)/i';

			$replacement_autolink[] = '<a href="' . append_sid("index.$phpEx") . '?lurl=' . urlencode($row['link_url']) . '&lid=' . $row['link_id'] . '"' . $style . $comment . $internal . ' onMouseover="window.status=\'' . $row['link_url'] . '\'; return true;" OnMouseout="window.status=\' \';">' . htmlspecialchars($row['link_text']) . '</a>';
		}
		while( $row = $db->sql_fetchrow($result) );
	}

	return true;
}

//
// Taken from the POST-NUKE pnuserapi.php Autolinks user API file with slight changes.
// Original Author - Jim McDonald.
//
function autolink_transform($message, $orig, $replacement)
{
	global $board_config;

	// Step 1 - move all tags out of the text and replace them with placeholders
	preg_match_all('/(<a\s+.*?\/a>|<[^>]+>)/i', $message, $matches);
	$matchnum = count($matches[1]);
	for( $i=0; $i<$matchnum; $i++ )
	{
		$message = preg_replace('/' . preg_quote($matches[1][$i], '/') . '/', "ALPLACEHOLDER{$i}PH", $message, 1);
	}

	// Step 2 - s/r of the remaining text
	if( $board_config['autolink_first'] )
	{
		$message = preg_replace($orig, $replacement, $message, 1);
	}
	else
	{
		$message = preg_replace($orig, $replacement, $message);
	}

	// Step 3 - replace the spaces we munged in the previous function
	$message = preg_replace('/ALSPACEHOLDER/', '', $message);

	// Step 4 - replace the HTML tags that we removed in step 1
	for( $i=0; $i<$matchnum; $i++ )
	{
		$message = preg_replace("/ALPLACEHOLDER{$i}PH/", $matches[1][$i], $message, 1);
	}

	return $message;
}

//
// If the forum has no autolinks then the above function
// wont be called and the placeholders need to be removed.
//
function autolink_return_empty($message)
{
	$message = preg_replace('/ALSPACEHOLDER/', '', $message);

	return $message;
}
// End Autolinks For phpBB2 MOD
Real men don’t back up, they learn data recovery. ;-)
http://www.mysqldumper.de
http://www.mysqldumper.se
Benutzeravatar
oxpus
Administrator
Beiträge: 28737
Registriert: Mo 27.Jan, 2003 22:13
Wohnort: Bad Wildungen
Kontaktdaten:

Re: Autolinks Mod

Beitrag von oxpus »

Kein Wunder, dass das nicht ging:
Für die Lexikoneinträge wurde von den 3 Funktionen noch eine verwendet, um die Einträge zu verlinken.
Die Funktion habe ich jetzt in der functions.php belassen, um eben die Lexikoneinträge weiterhin umzusetzen.
Karsten Ude
-={ Das Mädchen für alles }=-
Kein Support per Messenger, Email oder PN! Unaufgeforderte Nachrichten werden ignoriert!
No support per Messenger, Email or PM. Each unasked message will be ignored!
Holger
Beiträge: 2253
Registriert: Mi 17.Mär, 2004 18:09

Re: Autolinks Mod

Beitrag von Holger »

Oooops! Alles klar! Danke! :!:
Real men don’t back up, they learn data recovery. ;-)
http://www.mysqldumper.de
http://www.mysqldumper.se
Antworten