Advertisement
Guest User

Untitled

a guest
May 29th, 2017
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.41 KB | None | 0 0
  1.         // So we have a topic!
  2.         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))
  3.         {
  4.             // Which one is our topic!
  5.             $topic = (int) $matches[1];
  6.            
  7.             // Let's get the info of this topic
  8.             $request = $smcFunc['db_query']('', '
  9.                 SELECT m.id_topic, b.id_board, m.subject, b.name
  10.                 FROM {db_prefix}messages AS m
  11.                     LEFT JOIN {db_prefix}boards AS b ON (m.id_board = b.id_board)
  12.                 WHERE m.id_topic = {int:topic}
  13.                 LIMIT 1',
  14.                 array(
  15.                    'topic' => $topic
  16.                 )
  17.             );
  18.            
  19.             // Kill it!
  20.             if ($smcFunc['db_num_rows']($request) == 0)
  21.                 die(show_error($topic));
  22.            
  23.             $row = $smcFunc['db_fetch_assoc']($request);
  24.             $smcFunc['db_free_result']($request);
  25.            
  26.             // Get the format!
  27.             if (!empty($modSettings['seo_board_redirect']) && $modSettings['seo_board_redirect'] == 'name/id')
  28.                 $new_url = $boardurl . '/' . format_url($row['name']) .'/' . $row['id_board'];
  29.             else if (!empty($modSettings['seo_board_redirect']) && $modSettings['seo_board_redirect'] == 'bid')
  30.                 $new_url = $boardurl . '/b' . $row['id_board'];
  31.             else if (!empty($modSettings['seo_board_redirect']) && $modSettings['seo_board_redirect'] == 'bid_name')
  32.                 $new_url = $boardurl . '/b' . $row['id_board'] . '_' . format_url($row['name']);
  33.             else
  34.                 $new_url = $boardurl . '/board' . $row['id_board'];
  35.            
  36.             // And the one from the topic
  37.             if (!empty($modSettings['seo_topic_redirect']) && $modSettings['seo_topic_redirect'] == 'subject/id')
  38.                 $new_url .= '/' . format_url($row['subject']) . '/' . $row['id_topic'];
  39.             else if (!empty($modSettings['seo_topic_redirect']) && $modSettings['seo_topic_redirect'] == 'tid')
  40.                 $new_url .= '/t' . $row['id_topic'];
  41.             else if (!empty($modSettings['seo_topic_redirect']) && $modSettings['seo_topic_redirect'] == 'topicid')
  42.                 $new_url .= '/topic' . $row['id_topic'];
  43.             else
  44.                 $new_url .= '/t' . $row['id_topic'] . '_' . format_url($row['subject']);
  45.                
  46.             // Let's take care of the rest!
  47.             if (!empty($matches[2]))
  48.             {
  49.                 $add = $smcFunc['substr']($matches[2], 1);
  50.                
  51.                 if ($add != '0')
  52.                     $new_url .= '/' . $add;
  53.             }
  54.        
  55.             // Permanent redirect
  56.             move_permanently($new_url);
  57.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement