Advertisement
Guest User

Untitled

a guest
Jun 3rd, 2012
496
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.27 KB | None | 0 0
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <!DOCTYPE extension SYSTEM "ext-1.0.dtd">
  3.  
  4. <!--
  5. /**
  6. * Add more seo options
  7. *
  8. * @copyright Copyright (C) 2011-2012 Helid
  9. * @license http://www.gnu.org/licenses/gpl.html GPL version 2 or higher
  10. * @package pun_seo
  11. */
  12. -->
  13.  
  14. <extension engine="1.0">
  15. <id>pun_seo</id>
  16. <title>Punbb SEO</title>
  17. <version>1.0.1</version>
  18. <description>Add more seo options.</description>
  19. <author>Helid</author>
  20.  
  21. <minversion>1.4</minversion>
  22. <maxtestedon>1.4.2</maxtestedon>
  23.  
  24. <hooks>
  25. <hook id="fn_generate_crumbs_start"><![CDATA[
  26. global $lang_common, $forum_url, $forum_config, $forum_page;
  27.  
  28. if (empty($forum_page['crumbs']))
  29. $forum_page['crumbs'][0] = $forum_config['o_board_title'];
  30.  
  31. $crumbs = '';
  32. $num_crumbs = count($forum_page['crumbs']);
  33.  
  34. if ($reverse)
  35. {
  36. for ($i = ($num_crumbs - 1); $i >= 0; --$i)
  37. $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'] : '');
  38. }
  39. else
  40. for ($i = 0; $i < $num_crumbs; ++$i)
  41. {
  42. if ($i < ($num_crumbs - 1))
  43. $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> ';
  44. else
  45. $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>';
  46. }
  47.  
  48. return $crumbs;
  49. ]]></hook>
  50. <hook id="vf_modify_forum_info"><![CDATA[
  51. $current_url = forum_htmlencode(get_current_url());
  52. $seo_url = forum_sublink($forum_url['forum'], $forum_url['page'], (isset($_GET['p']) ? $_GET['p'] : 1), array($id, sef_friendly($cur_forum['forum_name'])));
  53. if ($seo_url !== $current_url) {
  54. header("Location: $seo_url", true, 301);
  55. exit();
  56. }
  57. ]]></hook>
  58. <hook id="vt_modify_topic_info"><![CDATA[
  59. $current_url = forum_htmlencode(get_current_url());
  60. if ($pid) {
  61. $seo_url = forum_link($forum_url['post'], $pid);
  62. if ($seo_url !== $current_url . '#p' . $pid) {
  63. header("Location: $seo_url", true, 301);
  64. exit();
  65. }
  66. } else if ($id) {
  67. $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'])));
  68. if ($seo_url !== $current_url) {
  69. header("Location: $seo_url", true, 301);
  70. exit();
  71. }
  72. }
  73. ]]></hook>
  74. <hook id="ps_handle_url_tag_start"><![CDATA[
  75. if (!$bbcode)
  76. {
  77. $full_url = str_replace(array(' ', '\'', '`', '"'), array('%20', '', '', ''), $url);
  78. if (strpos($url, 'www.') === 0) // If it starts with www, we add http://
  79. $full_url = 'http://'.$full_url;
  80. else if (strpos($url, 'ftp.') === 0) // Else if it starts with ftp, we add ftp://
  81. $full_url = 'ftp://'.$full_url;
  82. else if (!preg_match('#^([a-z0-9]{3,6})://#', $url)) // Else if it doesn't start with abcdef://, we add http://
  83. $full_url = 'http://'.$full_url;
  84.  
  85. if (defined('FORUM_SUPPORT_PCRE_UNICODE') && defined('FORUM_ENABLE_IDNA'))
  86. {
  87. $link_name = ($link == '' || $link == $url) ? $url : $link;
  88. if (preg_match('!^(https?|ftp|news){1}'.preg_quote('://xn--', '!').'!', $link_name))
  89. {
  90. $link = $idn->decode($link_name);
  91. }
  92. }
  93.  
  94. $link = ($link == '' || $link == $url) ? ((utf8_strlen($url) > 55) ? utf8_substr($url, 0 , 39).' … '.utf8_substr($url, -10) : $url) : stripslashes($link);
  95. return '<a href="'.$full_url.'" rel="nofollow">'.$link.'</a>';
  96. }
  97. ]]>
  98. </hook>
  99. </hooks>
  100. </extension>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement