Замена внутренней ссылки на название поста

Konstantin

Пользователь
Прочитать посты выше никак?
Вставил и ничего не изменилось.


PHP:
$script_name = preg_replace('/^\/?(.*?)\/?$/', '\1', trim($bb_cfg['script_path']));
        $script_name = ($script_name != '') ? $script_name . '/' : '';
        $server_name = trim($bb_cfg['server_name']);
        $server_protocol = ($bb_cfg['cookie_secure']) ? 'https://' : 'http://';
        $server_port = ($bb_cfg['server_port'] <> 80) ? ':' . trim($bb_cfg['server_port']) . '/' : '/';
        $board_path = $server_protocol . $server_name . $server_port . $script_name;
        $viewtopic_url = preg_quote($board_path . 'viewtopic.php?', '/') . '('. POST_TOPIC_URL . '|'. POST_POST_URL . ')=';
        preg_match_all('/(^|[\n ])(' . $viewtopic_url . ')([0-9]+)([\w\#$%&~\-;:=,?@\[\]+]*)/si', $message, $matches);
        foreach ($matches[0] as $k => $str)
        {
            $topic_post_id = $matches[4][$k];
            $topic_title = '';
            if ($matches[3][$k] == POST_TOPIC_URL)
            {
                $sql = ("SELECT topic_title
                    FROM " . BB_TOPICS . "
                    WHERE topic_id = " . (int) $topic_post_id);
            }
            else
            {
                $sql = ("SELECT t.topic_title
                    FROM " . BB_TOPICS . " t, " . BB_POSTS . " p
                    WHERE p.topic_id = t.topic_id
                    AND p.post_id = " . (int) $topic_post_id);
            }
            if ($result = DB()->sql_query($sql))
            {
                $row = DB()->sql_fetchrow($result);
                $topic_title =  $row['topic_title'];
 
            }
            DB()->sql_freeresult($result);
 
            if (!empty($topic_title))
            {
                $message = str_replace($str, $matches[1][$k] . '[url=' . trim($str) . ']' . $topic_title . '[/url]', $message);
            }
        }

PHP:
$message = prepare_message($message);
// Flood control
 
Сверху