Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="utf-8"?>
- <!DOCTYPE extension SYSTEM "ext-1.0.dtd">
- <!--
- /**
- * Add more seo options
- *
- * @copyright Copyright (C) 2011-2012 Helid
- * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
- * @package pun_seo
- */
- -->
- <extension engine="1.0">
- <id>pun_seo</id>
- <title>Punbb SEO</title>
- <version>1.0.1</version>
- <description>Add more seo options.</description>
- <author>Helid</author>
- <minversion>1.4</minversion>
- <maxtestedon>1.4.2</maxtestedon>
- <hooks>
- <hook id="fn_generate_crumbs_start"><![CDATA[
- global $lang_common, $forum_url, $forum_config, $forum_page;
- if (empty($forum_page['crumbs']))
- $forum_page['crumbs'][0] = $forum_config['o_board_title'];
- $crumbs = '';
- $num_crumbs = count($forum_page['crumbs']);
- if ($reverse)
- {
- for ($i = ($num_crumbs - 1); $i >= 0; --$i)
- $crumbs .= (is_array($forum_page['crumbs'][$i]) ? forum_htmlencode($forum_page['crumbs'][$i][0]) : forum_htmlencode($forum_page['crumbs'][$i])).((isset($forum_page['page']) && $i == ($num_crumbs - 1)) ? ' ('.$lang_common['Page'].' '.forum_number_format($forum_page['page']).')' : '').($i > 0 ? $lang_common['Title separator'] : '');
- }
- else
- for ($i = 0; $i < $num_crumbs; ++$i)
- {
- if ($i < ($num_crumbs - 1))
- $crumbs .= '<span style="float: left; font-size: 12px; font-weight: normal;";>'.(($i >= 1) ? '<span>'.$lang_common['Crumb separator'].'</span>' : '').(is_array($forum_page['crumbs'][$i]) ? '<a href="'.$forum_page['crumbs'][$i][1].'">'.forum_htmlencode($forum_page['crumbs'][$i][0]).'</a>' : forum_htmlencode($forum_page['crumbs'][$i])).'</span> ';
- else
- $crumbs .= '<span style="float: left; font-size: 12px; font-weight: normal;";><span>'.(($i >= 1) ? '<span>'.$lang_common['Crumb separator'].'</span>' : '').'</span><h2 style="font-size: 12px; float: left; margin: -3px 0 0 0;">'.(is_array($forum_page['crumbs'][$i]) ? '<a href="'.$forum_page['crumbs'][$i][1].'">'.forum_htmlencode($forum_page['crumbs'][$i][0]).'</a>' : forum_htmlencode($forum_page['crumbs'][$i])).'</span></h2> <div style="clear: both;"></div>';
- }
- return $crumbs;
- ]]></hook>
- <hook id="vf_modify_forum_info"><![CDATA[
- $current_url = forum_htmlencode(get_current_url());
- $seo_url = forum_sublink($forum_url['forum'], $forum_url['page'], (isset($_GET['p']) ? $_GET['p'] : 1), array($id, sef_friendly($cur_forum['forum_name'])));
- if ($seo_url !== $current_url) {
- header("Location: $seo_url", true, 301);
- exit();
- }
- ]]></hook>
- <hook id="vt_modify_topic_info"><![CDATA[
- $current_url = forum_htmlencode(get_current_url());
- if ($pid) {
- $seo_url = forum_link($forum_url['post'], $pid);
- if ($seo_url !== $current_url . '#p' . $pid) {
- header("Location: $seo_url", true, 301);
- exit();
- }
- } else if ($id) {
- $seo_url = forum_sublink($forum_url['topic'], $forum_url['page'], (isset($_GET['p']) ? $_GET['p'] : 1), array($id, sef_friendly($cur_topic['forum_name'] . ' ' . $cur_topic['subject'])));
- if ($seo_url !== $current_url) {
- header("Location: $seo_url", true, 301);
- exit();
- }
- }
- ]]></hook>
- <hook id="ps_handle_url_tag_start"><![CDATA[
- if (!$bbcode)
- {
- $full_url = str_replace(array(' ', '\'', '`', '"'), array('%20', '', '', ''), $url);
- if (strpos($url, 'www.') === 0) // If it starts with www, we add http://
- $full_url = 'http://'.$full_url;
- else if (strpos($url, 'ftp.') === 0) // Else if it starts with ftp, we add ftp://
- $full_url = 'ftp://'.$full_url;
- else if (!preg_match('#^([a-z0-9]{3,6})://#', $url)) // Else if it doesn't start with abcdef://, we add http://
- $full_url = 'http://'.$full_url;
- if (defined('FORUM_SUPPORT_PCRE_UNICODE') && defined('FORUM_ENABLE_IDNA'))
- {
- $link_name = ($link == '' || $link == $url) ? $url : $link;
- if (preg_match('!^(https?|ftp|news){1}'.preg_quote('://xn--', '!').'!', $link_name))
- {
- $link = $idn->decode($link_name);
- }
- }
- $link = ($link == '' || $link == $url) ? ((utf8_strlen($url) > 55) ? utf8_substr($url, 0 , 39).' … '.utf8_substr($url, -10) : $url) : stripslashes($link);
- return '<a href="'.$full_url.'" rel="nofollow">'.$link.'</a>';
- }
- ]]>
- </hook>
- </hooks>
- </extension>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement