Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // So we have a topic!
- elseif (!empty($modSettings['enable_pretty_topics']) && (!isset($_GET['action']) || (!empty($modSettings['enable_pretty_actions']) && isset($path['call_parts'][0]) && in_array($path['call_parts'][0], unserialize($modSettings['seo_actions'])))) && preg_match("~topic=([0-9]+)(.*)~i", $request_path[1], $matches))
- {
- // Which one is our topic!
- $topic = (int) $matches[1];
- // Let's get the info of this topic
- $request = $smcFunc['db_query']('', '
- SELECT m.id_topic, b.id_board, m.subject, b.name
- FROM {db_prefix}messages AS m
- LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
- WHERE m.id_topic = {int:topic}
- LIMIT 1',
- array(
- 'topic' => $topic
- )
- );
- // Kill it!
- if ($smcFunc['db_num_rows']($request) == 0)
- die(show_error($topic));
- $row = $smcFunc['db_fetch_assoc']($request);
- $smcFunc['db_free_result']($request);
- // Get the format!
- if (!empty($modSettings['seo_board_redirect']) && $modSettings['seo_board_redirect'] == 'name/id')
- $new_url = $boardurl . '/' . format_url($row['name']) .'/' . $row['id_board'];
- else if (!empty($modSettings['seo_board_redirect']) && $modSettings['seo_board_redirect'] == 'bid')
- $new_url = $boardurl . '/b' . $row['id_board'];
- else if (!empty($modSettings['seo_board_redirect']) && $modSettings['seo_board_redirect'] == 'bid_name')
- $new_url = $boardurl . '/b' . $row['id_board'] . '_' . format_url($row['name']);
- else
- $new_url = $boardurl . '/board' . $row['id_board'];
- // And the one from the topic
- if (!empty($modSettings['seo_topic_redirect']) && $modSettings['seo_topic_redirect'] == 'subject/id')
- $new_url .= '/' . format_url($row['subject']) . '/' . $row['id_topic'];
- else if (!empty($modSettings['seo_topic_redirect']) && $modSettings['seo_topic_redirect'] == 'tid')
- $new_url .= '/t' . $row['id_topic'];
- else if (!empty($modSettings['seo_topic_redirect']) && $modSettings['seo_topic_redirect'] == 'topicid')
- $new_url .= '/topic' . $row['id_topic'];
- else
- $new_url .= '/t' . $row['id_topic'] . '_' . format_url($row['subject']);
- // Let's take care of the rest!
- if (!empty($matches[2]))
- {
- $add = $smcFunc['substr']($matches[2], 1);
- if ($add != '0')
- $new_url .= '/' . $add;
- }
- // Permanent redirect
- move_permanently($new_url);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement