hooligan

Untitled

Feb 11th, 2013
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.44 KB | None | 0 0
  1. <?php
  2. # Zoints SEO 2.3.2
  3. # Copyright (C) 2006 Zoints Inc
  4. #
  5. # This library is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU Lesser General Public
  7. # License as published by the Free Software Foundation; either
  8. # version 2.1 of the License, or (at your option) any later version.
  9. #
  10. # This library is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. # Lesser General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Lesser General Public
  16. # License along with this library; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  18. #
  19.  
  20.  
  21. error_reporting(E_ALL & ~E_NOTICE);
  22.  
  23. #
  24. # GLOBAL Functions
  25. #
  26.  
  27. function redirect_301($url)
  28. {
  29. global $vbulletin;
  30.  
  31. if (strpos($url, 'http://') === false)
  32. {
  33. $url = $vbulletin->options['bburl'] . '/' . $url;
  34. }
  35.  
  36. header("HTTP/1.1 301 Moved Permanently");
  37. header("Location: $url");
  38. exit;
  39. }
  40.  
  41. function zseo_url_thread($info, $page = 1, $extra = '', $pos = '', $archive = false, $redirectcheck = false, $forcenoarchive = false)
  42. {
  43. global $vbulletin, $show;
  44.  
  45. $prefix = '';
  46.  
  47. if ($show['guest'] AND $vbulletin->options['zointsseo_thread_decay'])
  48. {
  49. if ($info['lastpost'] < (TIMENOW - 86400 * $vbulletin->options['zointsseo_thread_decay_days']))
  50. {
  51. # thread is decayed
  52. if ($vbulletin->options['zointsseo_style_decay'] OR $vbulletin->options['zointsseo_archive_sitemap'])
  53. {
  54. if (THIS_SCRIPT == 'archive')
  55. {
  56. $prefix = $vbulletin->options['bburl'] . '/';
  57. }
  58. $archive = false;
  59. }
  60. else
  61. {
  62. if (THIS_SCRIPT != 'archive')
  63. {
  64. $prefix = $vbulletin->options['bburl'] . '/' . iif($vbulletin->options['zointsseo_rewrite_sitemap'], 'sitemap', 'archive') . '/';
  65. }
  66. $archive = true;
  67. if ($forcenoarchive)
  68. {
  69. $archive = false;
  70. }
  71.  
  72. if (THIS_SCRIPT == 'archive' AND $vbulletin->options['zointsseo_archive_sitemap'])
  73. {
  74. $prefix = $vbulletin->options['bburl'] . '/';
  75. $archive = false;
  76. }
  77. }
  78. }
  79. }
  80.  
  81. if (THIS_SCRIPT == 'archive' AND $vbulletin->options['zointsseo_archive_sitemap'] AND !$redirectcheck)
  82. {
  83. $prefix = $vbulletin->options['bburl'] . '/';
  84. $archive = false;
  85. }
  86.  
  87.  
  88.  
  89. $info['title'] = !empty($info['threadtitle']) ? $info['threadtitle'] : $info['title'];
  90. $extra = $vbulletin->session->vars['sessionurl'] . $extra;
  91.  
  92. $file = true;
  93. if ($archive OR $vbulletin->options['zointsseo_rewrite_urls'] == 2)
  94. {
  95. $file = false;
  96. }
  97.  
  98. if ($archive)
  99. {
  100. $archive_file = iif($vbulletin->options['zointsseo_rewrite_urls'] == 2, '', 'index.php/');
  101. }
  102.  
  103. if ($vbulletin->options['zointsseo_on'] AND $vbulletin->options['zointsseo_rewrite_urls'])
  104. {
  105. $suffix = (empty($extra) ? '' : "?$extra") . $pos;
  106.  
  107. if ($vbulletin->options['zointsseo_rewrite_index'])
  108. {
  109. return $prefix . iif($file, 'showthread.php/', $archive_file) . zseo_cleaned_string($info['title']) . '-' . iif(!$file, 't') . "$info[threadid]/index" . iif($page > 1, $page) . ".html$suffix";
  110. }
  111. return $prefix . iif($file, 'showthread.php/', $archive_file) . zseo_cleaned_string($info['title']) . '-' . iif(!$file, 't') . "$info[threadid]" . iif($page > 1, "p$page") . ".html$suffix";
  112. }
  113.  
  114. if ($archive)
  115. {
  116. return $prefix . "t-$info[threadid]" . iif($page > 1, "-p-$page") . '.html' . (empty($extra) ? '' : "&amp;$extra" . $pos);
  117. }
  118.  
  119. return $prefix . "showthread.php?t=$info[threadid]" . iif($page > 1, "&page=$page") . (empty($extra) ? '' : "&amp;$extra" . $pos);
  120. }
  121.  
  122. function zseo_url_post($info, $page = 1, $extra = '', $pos = '')
  123. {
  124. global $vbulletin;
  125.  
  126. $info['title'] = !empty($info['threadtitle']) ? $info['threadtitle'] : $info['title'];
  127. $extra = $vbulletin->session->vars['sessionurl'] . $extra;
  128.  
  129. $file = true;
  130. if ($vbulletin->options['zointsseo_rewrite_urls'] == 2)
  131. {
  132. $file = false;
  133. }
  134. if ($vbulletin->options['zointsseo_on'] AND $vbulletin->options['zointsseo_rewrite_urls'])
  135. {
  136. $suffix = (empty($extra) ? '' : "?$extra") . $pos;
  137. if ($vbulletin->options['zointsseo_rewrite_index'])
  138. {
  139. return iif($file, "showthread.php/") . zseo_cleaned_string($info['title']) . "-p$info[postid]/index" . iif($page > 1, $page) . ".html$suffix";
  140. }
  141. return iif($file, "showthread.php/") . zseo_cleaned_string($info['title']) . "-p$info[postid]" . iif($page > 1, "p$page") . ".html$suffix";
  142. }
  143. #var_dump($page);
  144. return "showthread.php?p=$info[postid]" . iif($page > 1, "&page=$page") . (empty($extra) ? '' : "&$extra" . $pos);
  145. }
  146.  
  147. function zseo_url_forum($info, $page = 1, $extra = '', $pos = '', $archive = false)
  148. {
  149. global $vbulletin;
  150.  
  151. $info['title'] = !empty($info['forumtitle']) ? $info['forumtitle'] : $info['title'];
  152. $extra = $vbulletin->session->vars['sessionurl'] . $extra;
  153.  
  154. $file = true;
  155. if ($archive OR $vbulletin->options['zointsseo_rewrite_urls'] == 2)
  156. {
  157. $file = false;
  158. }
  159.  
  160. if ($vbulletin->options['zointsseo_on'] AND $vbulletin->options['zointsseo_rewrite_urls'])
  161. {
  162. $suffix = (empty($extra) ? '' : "?$extra") . $pos;
  163. if ($vbulletin->options['zointsseo_rewrite_index'])
  164. {
  165. return iif($file, 'forumdisplay.php/') . zseo_cleaned_string($info['title']) . "-" . iif(!$file, iif($info['z'],'z','f')) . "$info[forumid]/index" . iif($page > 1, $page) . ".html$suffix";
  166. }
  167. return iif($file, 'forumdisplay.php/') . zseo_cleaned_string($info['title']) . "-" . iif(!$file, iif($info['z'],'z','f')) . "$info[forumid]" . iif($page > 1, "p$page") . ".html$suffix";
  168. }
  169. if ($archive)
  170. {
  171. return iif($info['z'], 'z', 'f') . "-$info[forumid]" . iif($page > 1, "-p-$page") . '.html' . (empty($extra) ? '' : "&amp;$extra" . $pos);
  172. }
  173. return "forumdisplay.php?f=$info[forumid]" . iif($page > 1, "&page=$page") . (empty($extra) ? '' : "&$extra") . $pos;
  174. }
  175.  
  176. function zseo_url_allpage($info, $page = 1)
  177. {
  178. global $vbulletin;
  179.  
  180.  
  181. $file = true;
  182.  
  183. if ($vbulletin->options['zointsseo_on'] AND $vbulletin->options['zointsseo_rewrite_urls'])
  184. {
  185. if ($vbulletin->options['zointsseo_rewrite_index'])
  186. {
  187. return iif($file, "forumdisplay.php/") . zseo_cleaned_string($info['title']) . "-all$info[forumid]/index" . iif($page > 1, $page) . ".html";
  188. }
  189. return iif($file, "forumdisplay.php/") . zseo_cleaned_string($info['title']) . "-all$info[forumid]" . iif($page > 1, "p$page") . ".html";
  190. }
  191. return "forumdisplay.php?f=$info[forumid]&do=allpage" . iif($page > 1, "&page=$page");
  192. }
  193.  
  194. function zseo_cleaned_string($string)
  195. {
  196. global $vbulletin;
  197.  
  198. $bit = iif($vbulletin->options['zointsseo_url_separator'], '_', '-');
  199.  
  200. $string = preg_replace("/(а)/i", 'a', $string);
  201. $string = preg_replace("/(б)/i", 'b', $string);
  202. $string = preg_replace("/(в)/i", 'v', $string);
  203. $string = preg_replace("/(г)/i", 'g', $string);
  204. $string = preg_replace("/(д)/i", 'd', $string);
  205. $string = preg_replace("/(е)/i", 'e', $string);
  206. $string = preg_replace("/(ё)/i", 'yo', $string);
  207. $string = preg_replace("/(ж)/i", 'zh', $string);
  208. $string = preg_replace("/(з)/i", 'z', $string);
  209. $string = preg_replace("/(и)/i", 'i', $string);
  210. $string = preg_replace("/(й)/i", 'i', $string);
  211. $string = preg_replace("/(к)/i", 'k', $string);
  212. $string = preg_replace("/(л)/i", 'l', $string);
  213. $string = preg_replace("/(м)/i", 'm', $string);
  214. $string = preg_replace("/(н)/i", 'n', $string);
  215. $string = preg_replace("/(о)/i", 'o', $string);
  216. $string = preg_replace("/(п)/i", 'p', $string);
  217. $string = preg_replace("/(р)/i", 'r', $string);
  218. $string = preg_replace("/(с)/i", 's', $string);
  219. $string = preg_replace("/(т)/iu", 't', $string);
  220. $string = preg_replace("/(у)/iu", 'u', $string);
  221. $string = preg_replace("/(ф)/iu", 'f', $string);
  222. $string = preg_replace("/(х)/i", 'h', $string);
  223. $string = preg_replace("/(ц)/i", 'c', $string);
  224. $string = preg_replace("/(ч)/i", 'ch', $string);
  225. $string = preg_replace("/(ш)/i", 'sh', $string);
  226. $string = preg_replace("/(щ)/i", 'sch', $string);
  227. $string = preg_replace("/(ъ)/i", '`', $string);
  228. $string = preg_replace("/(ы)/i", 'y', $string);
  229. $string = preg_replace("/(ь)/i", '`', $string);
  230. $string = preg_replace("/(э)/i", 'e', $string);
  231. $string = preg_replace("/(ю)/i", 'yu', $string);
  232. $string = preg_replace("/(я)/i", 'ya', $string);
  233.  
  234. $string = strtolower($string);
  235. $string = unhtmlspecialchars($string);
  236.  
  237. $string = str_replace("'", '', $string);
  238. $words = preg_split("#[^a-z0-9]#", $string, -1, PREG_SPLIT_NO_EMPTY);
  239.  
  240. $words = zseo_strip_stopwords($words, $bit);
  241. $words = zseo_limit_keywords($words, $bit);
  242. return implode($bit, $words);
  243. }
  244.  
  245. function zseo_limit_keywords($words, $bit)
  246. {
  247. global $vbulletin;
  248.  
  249. if ($vbulletin->options['zointsseo_url_keyword_limit'] > 0 AND count($words) > $vbulletin->options['zointsseo_url_keyword_limit'])
  250. {
  251. return array_slice($words,0,$vbulletin->options['zointsseo_url_keyword_limit']);
  252. }
  253. return $words;
  254. }
  255.  
  256. function zseo_strip_stopwords($words, $bit)
  257. {
  258. global $vbulletin;
  259.  
  260. if ($vbulletin->options['zointsseo_strip_stopwords'] AND !empty($vbulletin->options['zointsseo_stopwords']))
  261. {
  262. $stopwords = strtolower($vbulletin->options['zointsseo_stopwords']);
  263. $stopwords = preg_split("#[\s\r\n,]+#", $stopwords, -1, PREG_SPLIT_NO_EMPTY);
  264.  
  265. foreach ($words as $key => $word)
  266. {
  267. if (in_array($word, $stopwords))
  268. {
  269. unset($words[$key]);
  270. }
  271. }
  272. }
  273.  
  274. return $words;
  275. }
  276.  
  277. function fetch_dynamic_guest_message($forumid, $onlytitle = false)
  278. {
  279. global $vbulletin;
  280.  
  281. if ($forumid < 1)
  282. {
  283. if ($onlytitle)
  284. {
  285. return $vbulletin->options['zointsseo_dynguestmessage_title'];
  286. }
  287. return array(
  288. 'title' => $vbulletin->options['zointsseo_dynguestmessage_title'],
  289. 'message' => $vbulletin->options['zointsseo_dynguestmessage_message']
  290. );
  291. }
  292.  
  293. if (!isset($vbulletin->forumcache[$forumid]))
  294. {
  295. return fetch_dynamic_guest_message(-1, $onlytitle);
  296. }
  297.  
  298. $forum = $vbulletin->forumcache[$forumid];
  299.  
  300. if ($onlytitle)
  301. {
  302. if (!empty($forum['dynguestmsg_title']))
  303. {
  304. return $forum['dynguestmsg_title'];
  305. }
  306. return fetch_dynamic_guest_message($forum['parentid'], true);
  307. }
  308.  
  309. if (empty($forum['dynguestmsg']))
  310. {
  311. return fetch_dynamic_guest_message($forum['parentid']);
  312. }
  313.  
  314. $message = array(
  315. 'title' => $forum['dynguestmsg_title'],
  316. 'message' => $forum['dynguestmsg']
  317. );
  318.  
  319. if (empty($message['title']))
  320. {
  321. $message['title'] = fetch_dynamic_guest_message($foruminfo['parentid'], true);
  322. }
  323.  
  324. return $message;
  325. }
  326.  
  327. function fetch_dynamic_permission_message($forumid, $onlytitle = false)
  328. {
  329. global $vbulletin;
  330.  
  331. if ($forumid < 1)
  332. {
  333. if ($onlytitle)
  334. {
  335. return $vbulletin->options['zointsseo_dynpermissionmessage_title'];
  336. }
  337. return array(
  338. 'title' => $vbulletin->options['zointsseo_dynpermissionmessage_title'],
  339. 'message' => $vbulletin->options['zointsseo_dynpermissionmessage_message']
  340. );
  341. }
  342.  
  343. if (!isset($vbulletin->forumcache[$forumid]))
  344. {
  345. return fetch_dynamic_permission_message(-1, $onlytitle);
  346. }
  347.  
  348. $forum = $vbulletin->forumcache[$forumid];
  349.  
  350. if ($onlytitle)
  351. {
  352. if (!empty($forum['permmsg_title']))
  353. {
  354. return $forum['permmsg_title'];
  355. }
  356. return fetch_dynamic_permission_message($forum['parentid'], true);
  357. }
  358.  
  359. if (empty($forum['permmsg']))
  360. {
  361. return fetch_dynamic_permission_message($forum['parentid']);
  362. }
  363.  
  364. if ($forum['permmsg'] == '-1')
  365. {
  366. return fetch_dynamic_guest_message($forum['forumid']);
  367. }
  368.  
  369. $message = array(
  370. 'title' => $forum['permmsg_title'],
  371. 'message' => $forum['permmsg']
  372. );
  373.  
  374. if (empty($message['title']))
  375. {
  376. $message['title'] = fetch_dynamic_permission_message($foruminfo['parentid'], true);
  377. }
  378.  
  379. return $message;
  380. }
  381.  
  382. function zseo_build_ads()
  383. {
  384. global $vbulletin;
  385.  
  386. $ads = array();
  387. $placements = $vbulletin->db->query_read("
  388. SELECT zap.*, za.*, zak.rcl is_rcl
  389. FROM " . TABLE_PREFIX . "zseo_ad_placement zap
  390. LEFT JOIN " . TABLE_PREFIX . "zseo_ad za ON(za.adid = zap.adid)
  391. LEFT JOIN " . TABLE_PREFIX . "zseo_ad_key zak ON(zak.ad_key = zap.ad_key)
  392. WHERE active = 1
  393. ORDER BY zap.ad_key, zap.adid
  394. ");
  395.  
  396. while ($placement = $vbulletin->db->fetch_array($placements))
  397. {
  398. $ad = array(
  399. 'rcl' => intval($placement['rcl']),
  400. 'ad' => $placement['ad'],
  401. 'is_rcl' => intval($placement['is_rcl'])
  402. );
  403.  
  404. if ($placement['ad_key'] == 't_postx')
  405. {
  406. $ad['post'] = intval($placement['post']);
  407. }
  408.  
  409. $ads["$placement[ad_key]"][] = $ad;
  410. }
  411.  
  412. build_datastore('zseo_ads', serialize($ads));
  413. }
  414. ?>
Advertisement
Add Comment
Please, Sign In to add comment