From c1b00129208242007f9a717bdae3f563cf1ee81f Mon Sep 17 00:00:00 2001 From: Benjamin Southall Date: Sat, 17 Aug 2019 23:55:02 +1000 Subject: [PATCH] Fix cross board linking support for board aliases. Note this doesn't have overboard support yet --- inc/functions.php | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/inc/functions.php b/inc/functions.php index 982f8f11..07585b2c 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -2076,10 +2076,17 @@ function markup(&$body, $track_cites = false, $op = false) { if ($board['uri'] != $_board) { if (!openBoard($_board)){ if (in_array($_board,array_keys($config['boards_alias']))){ - //$_board = $config['boards_alias'][$_board]; - //openBoard($_board); + $_board = $config['boards_alias'][$_board]; + if (openBoard($_board)){ + + } + else { + continue; // Unknown board + } } - continue; // Unknown board + else { + continue; // Unknown board + } } } @@ -2104,7 +2111,13 @@ function markup(&$body, $track_cites = false, $op = false) { openBoard($tmp_board); foreach ($cites as $matches) { + $original_board = NULL; $_board = $matches[2][0]; + if (in_array($_board,array_keys($config['boards_alias']))){ + $original_board = $_board; + $_board = $config['boards_alias'][$_board]; + + } $cite = @$matches[3][0]; // preg_match_all is not multibyte-safe @@ -2115,14 +2128,25 @@ function markup(&$body, $track_cites = false, $op = false) { if ($cite) { if (isset($cited_posts[$_board][$cite])) { $link = $cited_posts[$_board][$cite]; - - $replacement = '' . + '>>>/' . $original_board . '/' . $cite . + ''; + + } + else { + $replacement = '' . '>>>/' . $_board . '/' . $cite . ''; + } + $body = mb_substr_replace($body, $matches[1][0] . $replacement . $matches[4][0], $matches[0][1] + $skip_chars, mb_strlen($matches[0][0])); $skip_chars += mb_strlen($matches[1][0] . $replacement . $matches[4][0]) - mb_strlen($matches[0][0]);