PageRenderTime 61ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/components/com_jfusionplugins/vbulletin/public.php

http://jfusion.googlecode.com/
PHP | 1437 lines | 1176 code | 140 blank | 121 comment | 135 complexity | a67240826071dfc1795851c34b1603d1 MD5 | raw file
Possible License(s): Apache-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. /**
  3. * @package JFusion_vBulletin
  4. * @author JFusion development team
  5. * @copyright Copyright (C) 2008 JFusion. All rights reserved.
  6. * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
  7. */
  8. // no direct access
  9. defined('_JEXEC' ) or die('Restricted access' );
  10. global $name, $baseURL, $fullURL, $integratedURL, $vbsefmode;
  11. /**
  12. * JFusion Public Class for vBulletin
  13. * For detailed descriptions on these functions please check the model.abstractpublic.php
  14. * @package JFusion_vBulletin
  15. */
  16. class JFusionPublic_vbulletin extends JFusionPublic{
  17. var $params;
  18. var $helper;
  19. function JFusionPublic_vbulletin()
  20. {
  21. //get the params object
  22. $this->params = & JFusionFactory::getParams($this->getJname());
  23. //get the helper object
  24. $this->helper = & JFusionFactory::getHelper($this->getJname());
  25. }
  26. function getJname()
  27. {
  28. return 'vbulletin';
  29. }
  30. function getRegistrationURL()
  31. {
  32. return 'register.php';
  33. }
  34. function getLostPasswordURL()
  35. {
  36. return 'login.php?do=lostpw';
  37. }
  38. function getLostUsernameURL()
  39. {
  40. return 'login.php?do=lostpw';
  41. }
  42. function getProfileURL($uid)
  43. {
  44. return $this->helper->getVbURL('member.php?u=' . $uid, 'members');
  45. }
  46. function getViewNewMessagesURL()
  47. {
  48. return 'search.php?do=getnew';
  49. }
  50. function getPrivateMessageURL()
  51. {
  52. return 'private.php';
  53. }
  54. function getPrivateMessageCounts($userid)
  55. {
  56. // initialise some objects
  57. $jdb = & JFusionFactory::getDatabase($this->getJname());
  58. $query = 'SELECT pmtotal,pmunread FROM #__user WHERE userid = '.$userid;
  59. $jdb->setQuery($query);
  60. $vbPMData = $jdb->loadObject();
  61. $pmcount['total'] = $vbPMData->pmtotal;
  62. $pmcount['unread'] = $vbPMData->pmunread;
  63. return $pmcount;
  64. }
  65. function getAvatar($userid)
  66. {
  67. $url = 0;
  68. if ($userid) {
  69. $db = & JFusionFactory::getDatabase($this->getJname());
  70. $query = "SELECT u.avatarid, u.avatarrevision, avatarpath, NOT ISNULL(c.userid) AS usecustom, c.dateline
  71. FROM #__user AS u
  72. LEFT JOIN #__avatar AS a ON a.avatarid = u.avatarid
  73. LEFT JOIN #__customavatar AS c ON c.userid = u.userid
  74. WHERE u.userid = $userid";
  75. $db->setQuery($query);
  76. $avatar = $db->loadObject();
  77. $query = "SELECT varname, value FROM #__setting WHERE varname = 'usefileavatar' OR varname = 'avatarurl'";
  78. $db->setQuery($query);
  79. $settings = $db->loadObjectList();
  80. foreach ($settings as $s) {
  81. ${$s->varname} = $s->value;
  82. }
  83. if (!empty($avatar->avatarpath)) {
  84. if (strpos($avatar->avatarpath, 'http') === false) {
  85. $url = $this->params->get('source_url') . $avatar->avatarpath;
  86. } else {
  87. $url = $avatar->avatarpath;
  88. }
  89. } elseif ($avatar->usecustom) {
  90. if ($usefileavatar) {
  91. //avatars are saved to the filesystem
  92. $url = (strpos($avatarurl, 'http') === false) ? $this->params->get('source_url') . $avatarurl : $avatarurl;
  93. $url.= "/avatar{$userid}_{$avatar->avatarrevision}.gif";
  94. } else {
  95. //avatars are saved in the database
  96. $url = $this->params->get('source_url') . 'image.php?u=' . $userid . '&amp;dateline=' . $avatar->dateline;
  97. }
  98. }
  99. }
  100. return $url;
  101. }
  102. function prepareText(&$text, $for = 'forum', $params = '', $object = '')
  103. {
  104. $status = array();
  105. if($for == 'forum') {
  106. //first thing is to remove all joomla plugins
  107. preg_match_all('/\{(.*)\}/U',$text,$matches);
  108. //find each thread by the id
  109. foreach($matches[1] AS $plugin) {
  110. //replace plugin with nothing
  111. $text = str_replace('{'.$plugin.'}',"",$text);
  112. }
  113. $text = html_entity_decode($text);
  114. JFusionFunction::parseCode($text,'bbcode');
  115. } elseif ($for == 'joomla' || ($for == 'activity' && $params->get('parse_text') == 'html')) {
  116. $db =& JFusionFactory::getDatabase($this->getJname());
  117. static $custom_smileys, $vb_bbcodes;
  118. $options = array();
  119. //parse smilies
  120. if (!is_array($custom_smileys)) {
  121. $query = "SELECT title, smilietext, smiliepath FROM #__smilie";
  122. $db->setQuery($query);
  123. $smilies = $db->loadObjectList();
  124. $vburl = $this->params->get('source_url');
  125. if (!empty($smilies)) {
  126. $custom_smileys = array();
  127. foreach ($smilies as $s) {
  128. $path = (strpos($s->smiliepath, 'http') !== false) ? $s->smiliepath : $vburl . $s->smiliepath;
  129. $custom_smileys[$s->smilietext] = $path;
  130. }
  131. }
  132. }
  133. $options['custom_smileys'] = $custom_smileys;
  134. $options['parse_smileys'] = true;
  135. //add custom bbcode rules
  136. if (!is_array($vb_bbcodes)) {
  137. $vb_bbcodes = array();
  138. $query = "SELECT bbcodetag, bbcodereplacement, twoparams FROM #__bbcode";
  139. $db->setQuery($query);
  140. $bbcodes = $db->loadObjectList();
  141. foreach ($bbcodes as $bb) {
  142. $template = $bb->bbcodereplacement;
  143. //replace vb's content holder with nbbc's
  144. $template = str_replace('%1$s', '{$_content}', $template);
  145. if ($bb->twoparams) {
  146. //if using the option tag, replace vb's option tag with one nbbc will understand
  147. $template = str_replace('%2$s', '{$_default}', $template);
  148. }
  149. $vb_bbcodes[$bb->bbcodetag] = array( 'mode' => 4, 'template' => $template, 'class' => 'inline', 'allow_in' => array('block', 'inline', 'link', 'list', 'listitem', 'columns', 'image'));
  150. }
  151. }
  152. if (!empty($vb_bbcodes)) {
  153. $options['html_patterns'] = $vb_bbcodes;
  154. }
  155. if (!empty($params) && $params->get('character_limit', false)) {
  156. $status['limit_applied'] = 1;
  157. $options['character_limit'] = $params->get('character_limit');
  158. }
  159. JFusionFunction::parseCode($text, 'html', $options);
  160. //remove the post id from any quote heads
  161. $text = preg_replace('#<div class="bbcode_quote_head">(.*?);(.*?) (.*?):</div>#' , '<div class="bbcode_quote_head">$1 $3:</div>', $text);
  162. } elseif ($for == 'discuss') {
  163. $text = preg_replace("#^\[quote=\"{$object->username}\"\]#si","[quote=\"{$object->username};{$object->postid}\"]",$text);
  164. } elseif ($for == 'activity' || $for == 'search') {
  165. $db =& JFusionFactory::getDatabase($this->getJname());
  166. static $vb_bbcodes_plain;
  167. $options = array();
  168. //add custom bbcode rules
  169. if (!is_array($vb_bbcodes_plain)) {
  170. $vb_bbcodes_plain = array();
  171. $query = "SELECT bbcodetag FROM #__bbcode";
  172. $db->setQuery($query);
  173. $vb_bbcodes_plain = $db->loadResultArray();
  174. }
  175. if (!empty($vb_bbcodes_plain)) {
  176. $options['plain_tags'] = $vb_bbcodes_plain;
  177. }
  178. if ($for == 'activity') {
  179. if ($params->get('parse_text') == 'plaintext') {
  180. $options = array();
  181. $options['plaintext_line_breaks'] = 'space';
  182. if ($params->get('character_limit')) {
  183. $status['limit_applied'] = 1;
  184. $options['character_limit'] = $params->get('character_limit');
  185. }
  186. JFusionFunction::parseCode($text, 'plaintext', $options);
  187. }
  188. } else {
  189. JFusionFunction::parseCode($text, 'plaintext');
  190. }
  191. }
  192. return $status;
  193. }
  194. /************************************************
  195. * Functions For JFusion Activity Module
  196. ***********************************************/
  197. function getActivityQuery($usedforums, $result_order, $result_limit)
  198. {
  199. $forum =& JFusionFactory::getForum($this->getJname());
  200. $usedforums = $forum->filterForumList($usedforums);
  201. //if no ther were no forums passed, the entire list is called and filtered in filterForumList
  202. //however if for some reason filterForumList fails, set forumid to 0 to prevent anything from showing protecting private forums
  203. $where = (!empty($usedforums)) ? 'WHERE a.forumid IN (' . implode(',',$usedforums) .') AND b.visible = 1 AND c.password = ""' : 'WHERE a.forumid = 0 AND b.visible = 1 AND c.password = ""';
  204. //add some extra posts to the $result_limit since filtering is going to take place afterward
  205. $end = $result_order . " LIMIT 0," . ($result_limit + 25);
  206. $numargs = func_num_args();
  207. if ($numargs > 3) {
  208. $db = & JFusionFactory::getDatabase($this->getJname());
  209. $filters = func_get_args();
  210. $i = 3;
  211. for ($i = 3; $i < $numargs; $i++) {
  212. if ($filters[$i][0] == 'userid') {
  213. $where.= ' AND b.userid = ' . $db->Quote($filters[$i][1]);
  214. }
  215. }
  216. }
  217. $name_field = $this->params->get('name_field');
  218. $query = array();
  219. if (empty($name_field)) {
  220. //Latest active topic with first post info
  221. $query[LAT . '0'] = "SELECT a.threadid, a.lastpostid AS postid, b.username, b.username as name, b.userid, CASE WHEN b.userid = 0 THEN 1 ELSE 0 END AS guest, a.title AS subject, b.dateline, a.forumid, a.lastpost FROM `#__thread` as a INNER JOIN `#__post` as b ON a.firstpostid = b.postid INNER JOIN #__forum as c ON a.forumid = c.forumid $where ORDER BY a.lastpost $end";
  222. //Latest active topic with lastest post info
  223. $query[LAT . '1'] = "SELECT a.threadid, a.lastpostid AS postid, b.username, b.username as name, b.userid, CASE WHEN b.userid = 0 THEN 1 ELSE 0 END AS guest, a.title AS subject, b.dateline, a.forumid, a.lastpost FROM `#__thread` as a INNER JOIN `#__post` as b ON a.lastpostid = b.postid INNER JOIN #__forum as c ON a.forumid = c.forumid $where ORDER BY a.lastpost $end";
  224. //Latest created topic
  225. $query[LCT] = "SELECT a.threadid, b.postid, b.username, b.username as name, b.userid, CASE WHEN b.userid = 0 THEN 1 ELSE 0 END AS guest, a.title AS subject, b.dateline, b.pagetext AS body, a.forumid, a.lastpost FROM `#__thread` as a INNER JOIN `#__post` as b ON a.firstpostid = b.postid INNER JOIN #__forum as c ON a.forumid = c.forumid $where ORDER BY a.dateline $end";
  226. //Latest created post
  227. $query[LCP] = "SELECT b.threadid, b.postid, b.username, b.username as name, b.userid, CASE WHEN b.userid = 0 THEN 1 ELSE 0 END AS guest, CASE WHEN b.title = '' THEN CONCAT(\"Re: \",a.title) ELSE b.title END AS subject, b.dateline, b.pagetext AS body, a.forumid, a.lastpost FROM `#__thread` as a INNER JOIN `#__post` AS b ON a.threadid = b.threadid INNER JOIN #__forum as c ON a.forumid = c.forumid $where ORDER BY b.dateline $end";
  228. } else {
  229. //Latest active topic with first post info
  230. $query[LAT . '0'] = "(SELECT a.threadid, a.lastpostid AS postid, b.username, b.userid, 0 AS guest, a.title AS subject, b.dateline, a.forumid, a.lastpost, a.lastpost as order_by_date, CASE WHEN f.$name_field IS NULL OR f.$name_field = '' THEN b.username ELSE f.$name_field END AS name FROM `#__thread` as a INNER JOIN `#__post` as b ON a.firstpostid = b.postid INNER JOIN #__forum as c ON a.forumid = c.forumid INNER JOIN `#__userfield` as f ON f.userid = b.userid $where AND b.userid != 0)";
  231. $query[LAT . '0'].= " UNION ";
  232. $query[LAT . '0'].= "(SELECT a.threadid, a.lastpostid AS postid, b.username, b.userid, 1 AS guest, a.title AS subject, b.dateline, a.forumid, a.lastpost, a.lastpost as order_by_date, b.username as name FROM `#__thread` as a INNER JOIN `#__post` as b ON a.firstpostid = b.postid INNER JOIN #__forum as c ON a.forumid = c.forumid $where AND b.userid = 0)";
  233. $query[LAT . '0'].= " ORDER BY order_by_date $end";
  234. //Latest active topic with lastest post info
  235. $query[LAT . '1'] = "(SELECT a.threadid, a.lastpostid AS postid, b.username, b.userid, 0 AS guest, a.title AS subject, b.dateline, a.forumid, a.lastpost, a.lastpost as order_by_date, CASE WHEN f.$name_field IS NULL OR f.$name_field = '' THEN b.username ELSE f.$name_field END AS name FROM `#__thread` as a INNER JOIN `#__post` as b ON a.lastpostid = b.postid INNER JOIN #__forum as c ON a.forumid = c.forumid INNER JOIN `#__userfield` as f ON f.userid = b.userid $where AND b.userid != 0)";
  236. $query[LAT . '1'].= " UNION ";
  237. $query[LAT . '1'].= "(SELECT a.threadid, a.lastpostid AS postid, b.username, b.userid, 1 AS guest, a.title AS subject, b.dateline, a.forumid, a.lastpost, a.lastpost as order_by_date, b.username as name FROM `#__thread` as a INNER JOIN `#__post` as b ON a.lastpostid = b.postid INNER JOIN #__forum as c ON a.forumid = c.forumid $where AND b.userid = 0)";
  238. $query[LAT . '1'].= " ORDER BY order_by_date $end";
  239. //Latest created topic
  240. $query[LCT] = "(SELECT a.threadid, b.postid, b.username, b.userid, 0 AS guest, a.title AS subject, b.dateline, b.pagetext AS body, a.forumid, a.lastpost, a.dateline as order_by_date, CASE WHEN f.$name_field IS NULL OR f.$name_field = '' THEN b.username ELSE f.$name_field END AS name FROM `#__thread` as a INNER JOIN `#__post` as b ON a.firstpostid = b.postid INNER JOIN #__forum as c ON a.forumid = c.forumid INNER JOIN `#__userfield` as f ON f.userid = b.userid $where AND b.userid != 0)";
  241. $query[LCT].= " UNION ";
  242. $query[LCT].= "(SELECT a.threadid, b.postid, b.username, b.userid, 1 AS guest, a.title AS subject, b.dateline, b.pagetext AS body, a.forumid, a.lastpost, a.dateline as order_by_date, b.username AS name FROM `#__thread` as a INNER JOIN `#__post` as b ON a.firstpostid = b.postid INNER JOIN #__forum as c ON a.forumid = c.forumid $where and b.userid = 0)";
  243. $query[LCT].= " ORDER BY order_by_date $end";
  244. //Latest created post
  245. $query[LCP] = "(SELECT b.threadid, b.postid, b.username, b.userid, 0 AS guest, CASE WHEN b.title = '' THEN CONCAT(\"Re: \",a.title) ELSE b.title END AS subject, b.dateline, b.pagetext AS body, a.forumid, a.lastpost, b.dateline as order_by_date, CASE WHEN f.$name_field IS NULL OR f.$name_field = '' THEN b.username ELSE f.$name_field END AS name FROM `#__thread` as a INNER JOIN `#__post` AS b ON a.threadid = b.threadid INNER JOIN #__forum as c ON a.forumid = c.forumid INNER JOIN `#__userfield` as f ON f.userid = b.userid $where AND b.userid != 0)";
  246. $query[LCP].= " UNION ";
  247. $query[LCP].= "(SELECT b.threadid, b.postid, b.username, b.userid, 1 AS guest, CASE WHEN b.title = '' THEN CONCAT(\"Re: \",a.title) ELSE b.title END AS subject, b.dateline, b.pagetext AS body, a.forumid, a.lastpost, b.dateline as order_by_date, b.username AS name FROM `#__thread` as a INNER JOIN `#__post` AS b ON a.threadid = b.threadid INNER JOIN #__forum as c ON a.forumid = c.forumid $where AND b.userid = 0)";
  248. $query[LCP].= " ORDER BY order_by_date $end";
  249. }
  250. return $query;
  251. }
  252. function filterActivityResults(&$results, $limit=0, $idKey='forumid', $search = false)
  253. {
  254. //get the joomla user
  255. $JoomlaUser =& JFactory::getUser();
  256. //get the vb user
  257. if(!$JoomlaUser->guest) {
  258. $user = JFusionFunction::lookupUser($this->getJname(), $JoomlaUser->id);
  259. if(!empty($user)) {
  260. $userid = $user->userid;
  261. } else {
  262. //oops, something has failed
  263. $userid = 0;
  264. }
  265. } else {
  266. $userid = 0;
  267. }
  268. $forum =& JFusionFactory::getForum($this->getJname());
  269. list($groupPerms, $forumPerms) = $forum->getForumPermissions($userid);
  270. //use a counter to keep track of number of results
  271. $counter = 0;
  272. if(is_array($results)) {
  273. foreach($results as $k => $r) {
  274. $forumid = $r->$idKey;
  275. $counter++;
  276. //use the custom forum permissions by default; if they are empty then use the groups permission
  277. $perms = (isset($forumPerms[$forumid])) ? $forumPerms[$forumid] : $groupPerms;
  278. //check permissions
  279. if($search) {
  280. if(!($perms & CAN_SEARCH_FORUM) || !($perms & CAN_VIEW_FORUM) || !($perms & CAN_VIEW_THREAD_CONTENT) || ($r->userid != $userid && !($perms & CAN_VIEW_OTHERS_THREADS))) {
  281. unset($results[$k]);
  282. $counter--;
  283. }
  284. } else {
  285. if(!$perms & CAN_VIEW_FORUM || ($r->userid != $userid && !($perms & CAN_VIEW_OTHERS_THREADS))) {
  286. //user does not have permission to view the forum or another user's thread
  287. unset($results[$k]);
  288. $counter--;
  289. } elseif(!($perms & CAN_VIEW_THREAD_CONTENT)) {
  290. //user cannot view posts within the thread
  291. if(defined('ACTIVITY_MODE') && ACTIVITY_MODE == LCP) {
  292. //in activity module and using latest created post mode so remove the entire post
  293. unset($results[$k]);
  294. $counter--;
  295. } else {
  296. //in activity module and using the latest active topic or latest created topic mode so just empty the post body
  297. $r->body = '';
  298. }
  299. }
  300. }
  301. //if the limit has been met, remove the rest of the results
  302. if(!empty($limit) && $counter == $limit) {
  303. $results = array_slice($results,0,$limit);
  304. break;
  305. }
  306. }
  307. }
  308. }
  309. /************************************************
  310. * Functions For JFusion Who's Online Module
  311. ***********************************************/
  312. /**
  313. * Returns a query to find online users
  314. * Make sure columns are named as userid, username, username_clean (if applicable), name (of user), and email
  315. */
  316. function getOnlineUserQuery($limit, $usergroups = '')
  317. {
  318. $limiter = (!empty($limit)) ? "LIMIT 0,$limit" : '';
  319. $usergroup_query = '';
  320. if(!empty($usergroups)) {
  321. if(is_array($usergroups)) {
  322. $usergroups = implode(',',$usergroups);
  323. $usergroup_query .= "AND (u.usergroupid IN ($usergroups)";
  324. foreach($usergroups AS $u) {
  325. $usergroup_query .= " OR FIND_IN_SET(" . intval($u) . ", u.membergroupids)";
  326. }
  327. $usergroup_query .= ")";
  328. } else {
  329. $usergroup_query .= "AND (u.usergroupid = $usergroups OR FIND_IN_SET($usergroups, u.membergroupids))";
  330. }
  331. }
  332. $name_field = $this->params->get('name_field');
  333. $query = "SELECT DISTINCT u.userid, u.username AS username, u.email";
  334. $query.= (!empty($name_field)) ? ", CASE WHEN f.$name_field IS NULL OR f.$name_field = '' THEN u.username ELSE f.$name_field END AS name FROM #__userfield as f INNER JOIN #__user AS u ON f.userid = u.userid" : ", u.username as name FROM #__user AS u";
  335. $query.= " INNER JOIN #__session AS s ON u.userid = s.userid WHERE s.userid != 0 $usergroup_query $limiter";
  336. return $query;
  337. }
  338. /**
  339. * Returns number of guests
  340. * @return int
  341. */
  342. function getNumberOnlineGuests()
  343. {
  344. $db =& JFusionFactory::getDatabase($this->getJname());
  345. $query = "SELECT COUNT(DISTINCT(host)) FROM #__session WHERE userid = 0";
  346. $db->setQuery($query);
  347. return $db->loadResult();
  348. }
  349. /**
  350. * Returns number of logged in users
  351. * @return int
  352. */
  353. function getNumberOnlineMembers($usergroups = '', $total = 1)
  354. {
  355. $usergroup_query = '';
  356. if(!empty($usergroups) && empty($total)) {
  357. if(is_array($usergroups)) {
  358. $usergroups = implode(',',$usergroups);
  359. $usergroup_query .= "AND (u.usergroupid IN ($usergroups)";
  360. foreach($usergroups AS $u) {
  361. $usergroup_query .= " OR FIND_IN_SET(" . intval($u) . ", u.membergroupids)";
  362. }
  363. $usergroup_query .= ")";
  364. } else {
  365. $usergroup_query .= "AND (u.usergroupid = $usergroups OR FIND_IN_SET($usergroups, u.membergroupids))";
  366. }
  367. }
  368. $db =& JFusionFactory::getDatabase($this->getJname());
  369. $query = "SELECT COUNT(DISTINCT(s.userid)) FROM #__user AS u INNER JOIN #__session AS s ON u.userid = s.userid WHERE s.userid != 0 $usergroup_query";
  370. $db->setQuery($query);
  371. return $db->loadResult();
  372. }
  373. /************************************************
  374. * Functions For Frameless View
  375. ************************************************/
  376. function getBuffer(&$jfdata)
  377. {
  378. global $vbsefmode, $vbJname, $vbsefenabled, $baseURL, $integratedURL, $hookFile;
  379. //make sure the curl model is loaded for the hooks file
  380. if(!class_exists('JFusionCurl')) {
  381. require_once(JPATH_ADMINISTRATOR.DS.'components'.DS.'com_jfusion'.DS.'models'.DS.'model.curl.php');
  382. }
  383. //frameless integration is only supported for 3.x
  384. $helper = & JFusionFactory::getHelper($this->getJname());
  385. $version = & $helper->getVersion();
  386. if ((int) substr($version, 0, 1) > 3) {
  387. JError::raiseWarning(500, JText::sprintf('VB_FRAMELESS_NOT_SUPPORTED',$version));
  388. return null;
  389. }
  390. //define('_JFUSION_DEBUG',1);
  391. //check to make sure the frameless hook is installed
  392. $db =& JFusionFactory::getDatabase($this->getJname());
  393. $q = "SELECT active FROM #__plugin WHERE hookname = 'init_startup' AND title = 'JFusion Frameless Integration Plugin'";
  394. $db->setQuery($q);
  395. $active = $db->loadResult();
  396. if($active!='1') {
  397. JError::raiseWarning(500, JText::_('VB_FRAMELESS_HOOK_NOT_INSTALLED'));
  398. return null;
  399. }
  400. //have to clear this as it shows up in some text boxes
  401. unset($q);
  402. // Get some params
  403. $params =& JFusionFactory::getParams($this->getJname());
  404. $vbsefmode = $params->get('sefmode',0);
  405. $source_path = $params->get('source_path');
  406. $source_url = $params->get('source_url');
  407. $baseURL = $jfdata->baseURL;
  408. $integratedURL = $jfdata->integratedURL;
  409. $config =& JFactory::getConfig();
  410. $vbsefenabled = $config->getValue('config.sef');
  411. $hookFile = JFUSION_PLUGIN_PATH.DS.$this->getJname().DS.'hooks.php';
  412. if($vbsefmode) {
  413. //need to set the base tag as vB JS/ajax requires it to function
  414. $document = JFactory::getDocument();
  415. $document->setBase($jfdata->baseURL);
  416. }
  417. //get the jname to be used in the hook file
  418. $vbJname = $this->getJname();
  419. //fix for some instances of vB redirecting
  420. $redirects = array(
  421. 'ajax.php'
  422. ,'attachment.php'
  423. ,'clientscript'
  424. ,'member.php'
  425. ,'misc.php'
  426. ,'picture.php'
  427. ,'sendmessage.php'
  428. );
  429. $custom_files = explode(',',$params->get('redirect_ignore'));
  430. if(is_array($custom_files)) {
  431. foreach($custom_files as $file) {
  432. //add file to the array of files to be redirected to forum
  433. if(!empty($file) && strpos($file,'.php')!==false) {
  434. $redirects[] = trim($file);
  435. }
  436. }
  437. }
  438. $uri =& JURI::getInstance();
  439. $url = $uri->toString();
  440. foreach($redirects as $r) {
  441. if(strpos($url,$r)!==false) {
  442. if($r=='member.php') {
  443. //only redirect if using another profile
  444. $profile_url = $this->getAlternateProfileURL($url);
  445. if(!empty($profile_url)) {
  446. $url = $profile_url;
  447. } else {
  448. continue;
  449. }
  450. } else {
  451. if($r=='sendmessage.php') {
  452. //only redirect if sending an IM
  453. $do = JRequest::getVar('do');
  454. if($do!='im') {
  455. continue;
  456. }
  457. }
  458. $url = $integratedURL . substr($url,strpos($url,$r));
  459. }
  460. $mainframe = & JFactory::getApplication();
  461. $mainframe->redirect($url);
  462. }
  463. }
  464. //get the filename
  465. $jfile = JRequest::getVar('jfile');
  466. if(!$jfile) {
  467. //use the default index.php
  468. $jfile = 'index.php';
  469. }
  470. //combine the path and filename
  471. if (substr($source_path, -1) == DS) {
  472. $index_file = $source_path . $jfile;
  473. } else {
  474. $index_file = $source_path . DS . $jfile;
  475. }
  476. if ( ! is_file($index_file) ) {
  477. JError::raiseWarning(500, 'The path to the requested does not exist');
  478. return null;
  479. }
  480. //set the current directory to vBulletin
  481. chdir($source_path);
  482. // Get the output
  483. ob_start();
  484. //aaaahhh; basically everything global in vbulletin must be declared here for it to work ;-{
  485. //did not include specific globals in admincp
  486. $vbGlobals = array(
  487. '_CALENDARHOLIDAYS'
  488. ,'_CALENDAROPTIONS'
  489. ,'_TEMPLATEQUERIES'
  490. ,'ad_location'
  491. ,'albumids'
  492. ,'allday'
  493. ,'altbgclass'
  494. ,'attachementids'
  495. ,'badwords'
  496. ,'bb_view_cache'
  497. ,'bgclass'
  498. ,'birthdaycache'
  499. ,'cache_postids'
  500. ,'calendarcache'
  501. ,'calendarids'
  502. ,'calendarinfo'
  503. ,'calmod'
  504. ,'checked'
  505. ,'checked'
  506. ,'cmodcache'
  507. ,'colspan'
  508. ,'copyrightyear'
  509. ,'count'
  510. ,'counters'
  511. ,'cpnav'
  512. ,'curforumid'
  513. ,'curpostid'
  514. ,'curpostidkey'
  515. ,'currentdepth'
  516. ,'customfields'
  517. ,'datastore_fetch'
  518. ,'date1'
  519. ,'date2'
  520. ,'datenow'
  521. ,'day'
  522. ,'days'
  523. ,'daysprune'
  524. ,'db'
  525. ,'defaultselected'
  526. ,'DEVDEBUG'
  527. ,'disablesmiliesoption'
  528. ,'display'
  529. ,'dotthreads'
  530. ,'doublemonth'
  531. ,'doublemonth1'
  532. ,'doublemonth2'
  533. ,'eastercache'
  534. ,'editor_css'
  535. ,'eventcache'
  536. ,'eventdate'
  537. ,'eventids'
  538. ,'faqbits'
  539. ,'faqcache'
  540. ,'faqjumpbits'
  541. ,'faqlinks'
  542. ,'faqparent'
  543. ,'firstnew'
  544. ,'folder'
  545. ,'folderid'
  546. ,'foldernames'
  547. ,'folderselect'
  548. ,'footer'
  549. ,'foruminfo'
  550. ,'forumjump'
  551. ,'forumpermissioncache'
  552. ,'forumperms'
  553. ,'forumrules'
  554. ,'forumshown'
  555. ,'frmjmpsel'
  556. ,'gobutton'
  557. ,'goodwords'
  558. ,'header'
  559. ,'headinclude'
  560. ,'holiday'
  561. ,'html_allowed'
  562. ,'hybridposts'
  563. ,'ifaqcache'
  564. ,'ignore'
  565. ,'imodcache'
  566. ,'imodecache'
  567. ,'inforum'
  568. ,'infractionids'
  569. ,'ipclass'
  570. ,'ipostarray'
  571. ,'istyles'
  572. ,'jumpforumbits'
  573. ,'jumpforumtitle'
  574. ,'langaugecount'
  575. ,'laspostinfo'
  576. ,'lastpostarray'
  577. ,'limitlower'
  578. ,'limitupper'
  579. ,'links'
  580. ,'message'
  581. ,'messagearea'
  582. ,'messagecounters'
  583. ,'messageid'
  584. ,'mod'
  585. ,'month'
  586. ,'months'
  587. ,'monthselected'
  588. ,'morereplies'
  589. ,'navclass'
  590. ,'newpm'
  591. ,'newthreads'
  592. ,'notifications_menubits'
  593. ,'notifications_total'
  594. ,'onload'
  595. ,'optionselected'
  596. ,'p'
  597. ,'p_two_linebreak'
  598. ,'pagestarttime'
  599. ,'pagetitle'
  600. ,'parent_postids'
  601. ,'parentassoc'
  602. ,'parentoptions'
  603. ,'parents'
  604. ,'pda'
  605. ,'period'
  606. ,'permissions'
  607. ,'permscache'
  608. ,'perpage'
  609. ,'phrasegroups'
  610. ,'phrasequery'
  611. ,'pictureids'
  612. ,'pmbox'
  613. ,'pmids'
  614. ,'pmpopupurl'
  615. ,'post'
  616. ,'postarray'
  617. ,'postattache'
  618. ,'postids'
  619. ,'postinfo'
  620. ,'postorder'
  621. ,'postparent'
  622. ,'postusername'
  623. ,'previewpost'
  624. ,'project_forums'
  625. ,'project_types'
  626. ,'querystring'
  627. ,'querytime'
  628. ,'rate'
  629. ,'ratescore'
  630. ,'recurcriteria'
  631. ,'reminder'
  632. ,'replyscore'
  633. ,'searchforumids'
  634. ,'searchids'
  635. ,'searchthread'
  636. ,'searchthreadid'
  637. ,'searchtype'
  638. ,'selectedicon'
  639. ,'selectedone'
  640. ,'serveroffset'
  641. ,'show'
  642. ,'smilebox'
  643. ,'socialgroups'
  644. ,'spacer_close'
  645. ,'spacer_open'
  646. ,'strikes'
  647. ,'style'
  648. ,'stylecount'
  649. ,'stylevar'
  650. ,'subscribecounters'
  651. ,'subscriptioncache'
  652. ,'template_hook'
  653. ,'templateassoc'
  654. ,'tempusagecache'
  655. ,'threadedmode'
  656. ,'threadids'
  657. ,'threadinfo'
  658. ,'time1'
  659. ,'time2'
  660. ,'timediff'
  661. ,'timenow'
  662. ,'timerange'
  663. ,'timezone'
  664. ,'titlecolor'
  665. ,'titleonly'
  666. ,'today'
  667. ,'usecategories'
  668. ,'usercache'
  669. ,'userids'
  670. ,'vbcollapse'
  671. ,'vBeditTemplate'
  672. ,'vboptions'
  673. ,'vbphrase'
  674. ,'vbulletin'
  675. ,'viewscore'
  676. ,'wol_album'
  677. ,'wol_attachement'
  678. ,'wol_calendar'
  679. ,'wol_event'
  680. ,'wol_inf'
  681. ,'wol_pm'
  682. ,'wol_post'
  683. ,'wol_search'
  684. ,'wol_socialgroup'
  685. ,'wol_thread'
  686. ,'wol_user'
  687. ,'year'
  688. );
  689. foreach($vbGlobals as $g)
  690. {
  691. //global the variable
  692. global $$g;
  693. }
  694. if(defined('_JFUSION_DEBUG')) {
  695. $_SESSION["jfvbdebug"] = array();
  696. }
  697. try {
  698. include_once($index_file);
  699. }
  700. catch(Exception $e) {
  701. $jfdata->buffer = ob_get_contents();
  702. ob_end_clean();
  703. }
  704. //change the current directory back to Joomla.
  705. chdir(JPATH_SITE);
  706. }
  707. function parseBody(&$data)
  708. {
  709. global $name, $baseURL, $fullURL, $integratedURL, $vbsefmode, $vbsefenabled;
  710. $name = $this->getJname();
  711. $baseURL = $data->baseURL;
  712. $fullURL = $data->fullURL;
  713. $integratedURL = $data->integratedURL;
  714. $params =& JFusionFactory::getParams($name);
  715. $vbsefmode = $params->get('sefmode',0);
  716. $config =& JFactory::getConfig();
  717. $vbsefenabled = $config->getValue('config.sef');
  718. //fix for form actions
  719. //cannot use preg_replace here because it adds unneeded slashes which messes up JS
  720. $action_search = '#action="(?!http)(.*?)"(.*?)>#mS';
  721. $data->body = preg_replace_callback($action_search,'fixAction',$data->body);
  722. //fix for the rest of the urls
  723. $url_search = '#href="(?!http)(.*?)"(.*?)>#mSs';
  724. $data->body = preg_replace_callback($url_search,'fixURL',$data->body);
  725. //$url_search = '#<link="(?!http)(.*?)"(.*?)>#mS';
  726. //$data->body = preg_replace_callback($url_search,'fixURL',$data->body);
  727. //convert relative urls in JS links
  728. $url_search = '#window.location=\'(?!http)(.*?)\'#mS';
  729. $data->body = preg_replace_callback($url_search, 'fixJS', $data->body);
  730. //convert relative links from images and js files into absolute links
  731. $include_search = "#(src=\"|background=\"|url\('|open_window\(\\\\'|window.open\('|window.open\(\"?)(?!http)(.*?)(\\\\',|',|\"|'\)|')#mS";
  732. $data->body = preg_replace_callback($include_search, 'fixInclude', $data->body);
  733. //we need to fix the cron.php file
  734. $data->body = preg_replace('#src="(.*)cron.php(.*)>#mS','src="'.$integratedURL.'cron.php$2>',$data->body);
  735. //if we have custom register and lost password urls and vBulletin uses an absolute URL, fixURL will not catch it
  736. $register_url = $params->get('register_url');
  737. if(!empty($register_url)) {
  738. $data->body = str_replace($integratedURL.'register.php',$register_url,$data->body);
  739. }
  740. $lostpassword_url = $params->get('lostpassword_url');
  741. if(!empty($lostpassword_url)) {
  742. $data->body = str_replace($integratedURL.'login.php?do=lostpw',$lostpassword_url,$data->body);
  743. }
  744. if($params->get('parseCSS',false)) {
  745. //we need to wrap the body in a div to prevent some CSS clashes
  746. $data->body = "<div id = 'framelessVb'>\n$data->body\n</div>";
  747. }
  748. if(defined('_JFUSION_DEBUG')) {
  749. $data->body .= "<pre><code>" . htmlentities(print_r($_SESSION["jfvbdebug"],true) ). "</code></pre>";
  750. $data->body .= "<pre><code>" . htmlentities(print_r($GLOBALS['vbulletin'],true) ). "</code></pre>";
  751. }
  752. }
  753. function parseHeader(&$data)
  754. {
  755. global $name, $baseURL, $fullURL, $integratedURL, $vbsefmode, $vbsefenabled;
  756. $name = $this->getJname();
  757. $baseURL = $data->baseURL;
  758. $fullURL = $data->fullURL;
  759. $integratedURL = $data->integratedURL;
  760. $params =& JFusionFactory::getParams($name);
  761. $vbsefmode = $params->get('sefmode',0);
  762. $config =& JFactory::getConfig();
  763. $vbsefenabled = $config->getValue('config.sef');
  764. $js = "<script type=\"text/javascript\">\n";
  765. $js .= "var vbSourceURL = '$integratedURL';\n";
  766. $js .= "</script>\n";
  767. //we need to find and change the call to vb's yahoo connection file to our own customized one
  768. //that adds the source url to the ajax calls
  769. $yuiURL = JFusionFunction::getJoomlaURL().JFUSION_PLUGIN_DIR_URL.$this->getJname();
  770. $data->header = preg_replace('#\<script type="text\/javascript" src="(.*?)(connection-min.js|connection.js)\?v=(.*?)"\>#mS',"$js <script type=\"text/javascript\" src=\"$yuiURL/yui/connection/connection.js?v=$3\">",$data->header);
  771. //convert relative links into absolute links
  772. $url_search = '#(src="|background="|href="|url\("|url\(\'?)(?!http)(.*?)("\)|\'\)|"?)#mS';
  773. $data->header = preg_replace_callback($url_search, 'fixInclude', $data->header);
  774. if($params->get('parseCSS',false)) {
  775. $css_search = '#<style type="text/css" id="vbulletin(.*?)">(.*?)</style>#ms';
  776. $data->header = preg_replace_callback($css_search,'fixCSS',$data->header);
  777. }
  778. }
  779. function getPathWay()
  780. {
  781. $mainframe = &JFactory::getApplication('site');
  782. $db =& JFusionFactory::getDatabase($this->getJname());
  783. $pathway = array();
  784. //let's get the jfile
  785. $jfile = JRequest::getVar('jfile');
  786. //we are viewing a forum
  787. if(JRequest::getVar('f',false)!==false) {
  788. $fid = JRequest::getVar('f');
  789. $query = "SELECT title, parentlist, parentid from #__forum WHERE forumid = $fid";
  790. $db->setQuery($query);
  791. $forum = $db->loadObject();
  792. if($forum->parentid!='-1') {
  793. $parents = array_reverse(explode(',',$forum->parentlist));
  794. foreach($parents as $p){
  795. if($p!="-1") {
  796. $query = "SELECT title from #__forum WHERE forumid = $p";
  797. $db->setQuery($query);
  798. $title = $db->loadResult();
  799. $crumb = new stdClass();
  800. $crumb->title = $title;
  801. $crumb->url = "forumdisplay.php?f=$p";
  802. $pathway[] = $crumb;
  803. }
  804. }
  805. } else {
  806. $crumb = new stdClass();
  807. $crumb->title = $forum->title;
  808. $crumb->url = "forumdisplay.php?f=$fid";
  809. $pathway[] = $crumb;
  810. }
  811. } elseif (JRequest::getVar('t',false)!==false) {
  812. $tid = JRequest::getVar('t');
  813. $query = "SELECT t.title AS thread, f.title AS forum, f.forumid, f.parentid, f.parentlist FROM #__thread AS t JOIN #__forum AS f ON t.forumid = f.forumid WHERE t.threadid = $tid";
  814. $db->setQuery($query);
  815. $result = $db->loadObject();
  816. if($result->parentid!='-1') {
  817. $parents = array_reverse(explode(',',$result->parentlist));
  818. foreach($parents as $p){
  819. if($p!="-1") {
  820. $query = "SELECT title from #__forum WHERE forumid = $p";
  821. $db->setQuery($query);
  822. $title = $db->loadResult();
  823. $crumb = new stdClass();
  824. $crumb->title = $title;
  825. $crumb->url = "forumdisplay.php?f=$p";
  826. $pathway[] = $crumb;
  827. }
  828. }
  829. } else {
  830. $crumb = new stdClass();
  831. $crumb->title = $result->forum;
  832. $crumb->url = "forumdisplay.php?f=$result->forumid";
  833. $pathway[] = $crumb;
  834. }
  835. $crumb = new stdClass();
  836. $crumb->title = $result->thread;
  837. $crumb->url = "showthread.php?t=$tid";
  838. $pathway[] = $crumb;
  839. } elseif(JRequest::getVar('p',false)!==false) {
  840. $pid = JRequest::getVar('p');
  841. $query = "SELECT t.title AS thread, t.threadid, f.title AS forum, f.forumid, f.parentid, f.parentlist FROM #__thread AS t JOIN #__forum AS f JOIN #__post AS p ON t.forumid = f.forumid AND t.threadid = p.threadid WHERE p.postid = $pid";
  842. $db->setQuery($query);
  843. $result = $db->loadObject();
  844. if($result->parentid!='-1') {
  845. $parents = array_reverse(explode(',',$result->parentlist));
  846. foreach($parents as $p){
  847. if($p!="-1") {
  848. $query = "SELECT title from #__forum WHERE forumid = $p";
  849. $db->setQuery($query);
  850. $title = $db->loadResult();
  851. $crumb = new stdClass();
  852. $crumb->title = $title;
  853. $crumb->url = "forumdisplay.php?f=$p";
  854. $pathway[] = $crumb;
  855. }
  856. }
  857. } else {
  858. $crumb = new stdClass();
  859. $crumb->title = $result->forum;
  860. $crumb->url = "forumdisplay.php?f=$result->forumid";
  861. $pathway[] = $crumb;
  862. }
  863. $crumb = new stdClass();
  864. $crumb->title = $result->thread;
  865. $crumb->url = "showthread.php?t=$result->threadid";
  866. $pathway[] = $crumb;
  867. } elseif (JRequest::getVar('u',false)!==false) {
  868. if($jfile=="member.php") {
  869. // we are viewing a member's profile
  870. $uid = JRequest::getVar('u');
  871. $crumb = new stdClass();
  872. $crumb->title = 'Members List';
  873. $crumb->url = 'memberslist.php';
  874. $pathway[] = $crumb;
  875. $query = "SELECT username FROM #__user WHERE userid = $uid";
  876. $db->setQuery($query);
  877. $username = $db->loadResult();
  878. $crumb = new stdClass();
  879. $crumb->title = "$username's Profile";
  880. $crumb->url = "member.php?u=$uid";
  881. $pathway[] = $crumb;
  882. }
  883. } elseif($jfile=="search.php") {
  884. $crumb = new stdClass();
  885. $crumb->title = "Search";
  886. $crumb->url = "search.php";
  887. $pathway[] = $crumb;
  888. if(JRequest::getVar('do',false) !== false) {
  889. $do = JRequest::getVar('do');
  890. if($do=="getnew") {
  891. $crumb = new stdClass();
  892. $crumb->title = "New Posts";
  893. $crumb->url = "search.php?do=getnew";
  894. $pathway[] = $crumb;
  895. } elseif($do=="getdaily") {
  896. $crumb = new stdClass();
  897. $crumb->title = "Today's Posts";
  898. $crumb->url = "search.php?do=getdaily";
  899. $pathway[] = $crumb;
  900. }
  901. }
  902. } elseif($jfile=="private.php") {
  903. $crumb = new stdClass();
  904. $crumb->title = "User Control Panel";
  905. $crumb->url = "usercp.php";
  906. $pathway[] = $crumb;
  907. $crumb = new stdClass();
  908. $crumb->title = "Private Messages";
  909. $crumb->url = "private.php";
  910. $pathway[] = $crumb;
  911. } elseif($jfile=="usercp.php") {
  912. $crumb = new stdClass();
  913. $crumb->title = "User Control Panel";
  914. $crumb->url = "usercp.php";
  915. $pathway[] = $crumb;
  916. } elseif($jfile=="profile.php") {
  917. $crumb = new stdClass();
  918. $crumb->title = "User Control Panel";
  919. $crumb->url = "usercp.php";
  920. $pathway[] = $crumb;
  921. if(JRequest::getVar('do',false) !== false) {
  922. $crumb = new stdClass();
  923. $crumb->title = "Your Profile";
  924. $crumb->url = "profile.php?do=editprofile";
  925. $pathway[] = $crumb;
  926. }
  927. } elseif($jfile=="moderation.php") {
  928. $crumb = new stdClass();
  929. $crumb->title = "User Control Panel";
  930. $crumb->url = "usercp.php";
  931. $pathway[] = $crumb;
  932. if(JRequest::getVar('do',false) !== false) {
  933. $crumb = new stdClass();
  934. $crumb->title = "Moderator Tasks";
  935. $crumb->url = "moderation.php";
  936. $pathway[] = $crumb;
  937. }
  938. } elseif($jfile=="memberlist.php") {
  939. $crumb = new stdClass();
  940. $crumb->title = "Members List";
  941. $crumb->url = "memberslist.php";
  942. $pathway[] = $crumb;
  943. }
  944. return $pathway;
  945. }
  946. function getAlternateProfileURL($vb_url)
  947. {
  948. $params =& JFusionFactory::getParams($this->getJname());
  949. $profile_plugin = $params->get('profile_plugin');
  950. $url = '';
  951. if(!empty($profile_plugin) && JFusionFunction::validPlugin($profile_plugin)) {
  952. $juri = new JURI($vb_url);
  953. $vbUid = $juri->getVar('u');
  954. if(!empty($vbUid)) {
  955. //first get Joomla's id for the vBulletin user
  956. $vbUser =& JFusionFactory::getUser($this->getJname());
  957. $userinfo =$vbUser->getUser($vbUid, 'userid');
  958. $vb_userlookup = JFusionFunction::lookupUser($this->getJname(),$vbUid,false,$userinfo->username);
  959. //now get the id of the selected plugin based on Joomla's id
  960. if(!empty($vb_userlookup)) {
  961. $profile_userlookup = JFusionFunction::lookupUser($profile_plugin,$vb_userlookup->id);
  962. //get the profile link
  963. $profilePublic =& JFusionFactory::getPublic($profile_plugin);
  964. $url = $profilePublic->getProfileURL($profile_userlookup->userid);
  965. }
  966. }
  967. }
  968. return $url;
  969. }
  970. /************************************************
  971. * For JFusion Search Plugin
  972. ***********************************************/
  973. function getSearchQueryColumns()
  974. {
  975. $columns = new stdClass();
  976. $columns->title = "p.title";
  977. $columns->text = "p.pagetext";
  978. return $columns;
  979. }
  980. function getSearchQuery(&$pluginParam)
  981. {
  982. //need to return threadid, postid, title, text, created, section
  983. $query = 'SELECT p.userid, p.threadid, p.postid, f.forumid, CASE WHEN p.title = "" THEN CONCAT("Re: ",t.title) ELSE p.title END AS title, p.pagetext AS text,
  984. FROM_UNIXTIME(p.dateline, "%Y-%m-%d %h:%i:%s") AS created,
  985. CONCAT_WS( "/", f.title_clean, t.title ) AS section,
  986. t.views AS hits
  987. FROM #__post AS p
  988. INNER JOIN #__thread AS t ON p.threadid = t.threadid
  989. INNER JOIN #__forum AS f on f.forumid = t.forumid';
  990. return $query;
  991. }
  992. function getSearchCriteria(&$where, &$pluginParam, $ordering)
  993. {
  994. $where .= " AND p.visible = 1 AND f.password = ''";
  995. if ($pluginParam->get('forum_mode', 0)) {
  996. $forumids = $pluginParam->get('selected_forums', array());
  997. if (empty($forumids)) {
  998. $forumids = array(0);
  999. }
  1000. $where.= " AND f.forumid IN (" . implode(',', $forumids) . ")";
  1001. }
  1002. //determine how to sort the results which is required for accurate results when a limit is placed
  1003. switch ($ordering) {
  1004. case 'oldest':
  1005. $sort = 'p.dateline ASC';
  1006. break;
  1007. case 'category':
  1008. $sort = 'section ASC';
  1009. break;
  1010. case 'popular':
  1011. $sort = 't.views DESC, p.dateline DESC';
  1012. case 'alpha':
  1013. $sort = 'title ASC';
  1014. break;
  1015. case 'newest':
  1016. default:
  1017. $sort = 'p.dateline DESC';
  1018. break;
  1019. }
  1020. $where .= " ORDER BY $sort";
  1021. }
  1022. function filterSearchResults(&$results, &$pluginParam)
  1023. {
  1024. $this->filterActivityResults($results, 0, 'forumid', true);
  1025. }
  1026. function getSearchResultLink($post)
  1027. {
  1028. $forum =& JFusionFactory::getForum($this->getJname());
  1029. return $forum->getPostURL($post->threadid,$post->postid);
  1030. }
  1031. }
  1032. function fixAction($matches)
  1033. {
  1034. global $name, $baseURL, $integratedURL, $vbsefmode, $vbsefenabled;
  1035. $url = $matches[1];
  1036. $extra = $matches[2];
  1037. if (defined('_JFUSION_DEBUG')) {
  1038. $debug = array();
  1039. $debug['original'] = $matches[0];
  1040. $debug['url'] = $url;
  1041. $debug['extra'] = $extra;
  1042. $debug['function'] = 'fixAction';
  1043. }
  1044. $url = htmlspecialchars_decode($url);
  1045. $url_details = parse_url($url);
  1046. $url_variables = array();
  1047. parse_str($url_details['query'], $url_variables);
  1048. if (defined('_JFUSION_DEBUG')) {
  1049. $debug['url_variables'] = $url_variables;
  1050. }
  1051. //add which file is being referred to
  1052. if ($url_variables['jfile']) {
  1053. //use the action file that was in jfile variable
  1054. $jfile = $url_variables['jfile'];
  1055. unset($url_variables['jfile']);
  1056. } else {
  1057. //use the action file from the action URL itself
  1058. $jfile = basename($url_details['path']);
  1059. }
  1060. $actionURL = JFusionFunction::routeURL($jfile, JRequest::getInt('Itemid'));
  1061. $replacement = 'action=\'' . $actionURL . '\'' . $extra . '>';
  1062. unset($url_variables['option']);
  1063. unset($url_variables['Itemid']);
  1064. //add any other variables
  1065. foreach ($url_variables as $key => $value) {
  1066. $replacement.= '<input type="hidden" name="' . $key . '" value="' . $value . '"/>';
  1067. }
  1068. if (defined('_JFUSION_DEBUG')) {
  1069. $debug['parsed'] = $replacement;
  1070. $_SESSION['jfvbdebug'][] = $debug;
  1071. }
  1072. return $replacement;
  1073. }
  1074. function fixURL($matches)
  1075. {
  1076. global $name, $baseURL, $integratedURL, $vbsefmode, $vbsefenabled;
  1077. $params =& JFusionFactory::getParams($name);
  1078. $plugin_itemid = $params->get('plugin_itemid');
  1079. $url = $matches[1];
  1080. $extra = $matches[2];
  1081. if(defined('_JFUSION_DEBUG')) {
  1082. $debug = array();
  1083. $debug['original'] = $matches[0];
  1084. $debug['url']= $url;
  1085. $debug['extra'] = $parts;
  1086. $debug['function'] = 'fixURL';
  1087. }
  1088. $uri =& JURI::getInstance();
  1089. $currentURL = $uri->toString();
  1090. if((string) strpos($url, '#') === (string)0 && strlen($url) != 1) {
  1091. $url = (str_replace('&', '&amp;', $currentURL)) . $url;
  1092. }
  1093. //we need to make some exceptions
  1094. //absolute url, already parsed URL, JS function, or jumpto
  1095. if(strpos($url,'http')!==false || strpos($url,$currentURL)!==false || strpos($url,'com_jfusion') !== false || ((string) strpos($url, '#') === (string)0 && strlen($url) == 1)) {
  1096. $replacement = "href=\"$url\" $extra>";
  1097. if(defined('_JFUSION_DEBUG')) {
  1098. $debug['parsed'] = $replacement;
  1099. }
  1100. return $replacement;
  1101. }
  1102. //admincp, mocp, archive, printthread.php or attachment.php
  1103. if (strpos($url,$params->get('admincp','admincp'))!==false || strpos($url,$params->get('modcp','modcp'))!==false || strpos($url,'archive')!==false || strpos($url,'printthread.php')!==false || strpos($url,'attachment.php')!==false) {
  1104. $replacement = 'href="' . $integratedURL . $url . "\" $extra>";
  1105. if(defined('_JFUSION_DEBUG')) {
  1106. $debug['parsed'] = $replacement;
  1107. }
  1108. return $replacement;
  1109. }
  1110. //if the plugin is set as a slave, find the master and replace register/lost password urls
  1111. if (strpos($url,'register.php')!==false) {
  1112. if(!empty($params)) {
  1113. $register_url = $params->get('register_url');
  1114. if(!empty($register_url)) {
  1115. $replacement = 'href="'.$register_url . '"' . $extra . '>';
  1116. if(defined('_JFUSION_DEBUG')) {
  1117. $debug['parsed'] = $replacement;
  1118. }
  1119. return $replacement;
  1120. }
  1121. }
  1122. }
  1123. if (strpos($url,'login.php?do=lostpw')!==false) {
  1124. if(!empty($params)) {
  1125. $lostpassword_url = $params->get('lostpassword_url');
  1126. if(!empty($lostpassword_url)) {
  1127. $replacement = 'href="'.$lostpassword_url . '"' . $extra . '>';
  1128. if(defined('_JFUSION_DEBUG')) {
  1129. $debug['parsed'] = $replacement;
  1130. }
  1131. return $replacement;
  1132. }
  1133. }
  1134. }
  1135. if(strpos($url,'member.php')!==false) {
  1136. $vbPublic =& JFusionFactory::getPublic($name);
  1137. $profile_url = $vbPublic->getAlternateProfileURL($url);
  1138. if(!empty($profile_url)) {
  1139. $replacement = 'href="'.$profile_url.'"'.$extra.'>';
  1140. if(defined('_JFUSION_DEBUG')) {
  1141. $debug['parsed'] = $replacement;
  1142. }
  1143. return $replacement;
  1144. }
  1145. }
  1146. if (empty($vbsefenabled)){
  1147. //non sef URls
  1148. $url = str_replace('?', '&amp;', $url);
  1149. $url = $baseURL . '&amp;jfile=' .$url;
  1150. } else {
  1151. $url = JFusionFunction::routeURL($url, $plugin_itemid);
  1152. }
  1153. //set the correct url and close the a tag
  1154. $replacement = 'href="'.$url . '"' . $extra . '>';
  1155. if(defined('_JFUSION_DEBUG')) {
  1156. $debug['parsed'] = $replacement;
  1157. $_SESSION["jfvbdebug"][] = $debug;
  1158. }
  1159. return $replacement;
  1160. }
  1161. function fixJS($matches)
  1162. {
  1163. global $name, $baseURL, $integratedURL, $vbsefmode, $vbsefenabled;
  1164. $params =& JFusionFactory::getParams($name);
  1165. $plugin_itemid = $params->get('plugin_itemid');
  1166. $url = $matches[1];
  1167. if(defined('_JFUSION_DEBUG')) {
  1168. $debug = array();
  1169. $debug['original'] = $matches[0];
  1170. $debug['url']= $url;
  1171. $debug['function'] = 'fixJS';
  1172. }
  1173. if(strpos($url,'http')!==false) {
  1174. if(defined('_JFUSION_DEBUG')) {
  1175. $debug['parsed'] = "window.location='$url'";;
  1176. }
  1177. return "window.location='$url'";
  1178. }
  1179. if (empty($vbsefenabled)){
  1180. //non sef URls
  1181. $url = str_replace('?', '&amp;', $url);
  1182. $url = $baseURL . '&amp;jfile=' .$url;
  1183. } else {
  1184. $url = JFusionFunction::routeURL($url, $plugin_itemid);
  1185. }
  1186. $url = str_replace('&amp;', '&', $url);
  1187. if(defined('_JFUSION_DEBUG')) {
  1188. $debug['parsed'] = "window.location='$url'";;
  1189. $_SESSION["jfvbdebug"][] = $debug;
  1190. }
  1191. return "window.location='$url'";;
  1192. }
  1193. function fixInclude($matches)
  1194. {
  1195. global $integratedURL;
  1196. $pre = $matches[1];
  1197. $url = $matches[2];
  1198. $post = $matches[3];
  1199. $replacement = $pre . $integratedURL . $url . $post;
  1200. if(defined('_JFUSION_DEBUG')) {
  1201. $debug = array();
  1202. $debug['original'] = $matches[0];
  1203. $debug['pre'] = $pre;
  1204. $debug['url'] = $url;
  1205. $debug['post'] = $post;
  1206. $debug['function'] = 'fixInclude';
  1207. $debug['replacement'] = $replacement;
  1208. $_SESSION['jfvbdebug'][] = $debug;
  1209. }
  1210. return $replacement;
  1211. }
  1212. function fixCSS($matches)
  1213. {
  1214. if(defined('_JFUSION_DEBUG')) {
  1215. $debug = array();
  1216. $debug['function'] = 'fixCSS';
  1217. $debug['original'] = $matches[0];
  1218. }
  1219. $css = $matches[2];
  1220. //remove html comments
  1221. $css = str_replace(array('<!--','-->'),'',$css);
  1222. //remove PHP comments
  1223. $css = preg_replace('#\/\*(.*?)\*\/#mSs','',$css);
  1224. //strip newlines
  1225. $css = str_replace("\r\n","",$css);
  1226. //break up the CSS into styles
  1227. $elements = explode('}',$css);
  1228. //unset the last one as it is empty
  1229. unset($elements[count($elements)-1]);
  1230. $imports = array();
  1231. //rewrite css
  1232. foreach($elements as $k => $v) {
  1233. //breakup each element into selectors and properties
  1234. $element = explode("{", $v);
  1235. //breakup the selectors
  1236. $selectors = explode(",",$element[0]);
  1237. foreach($selectors as $sk => $sv){
  1238. //add vb framless container
  1239. if(strpos($sv,'<!--')!==false) die(var_dump($sv));
  1240. if($sv == 'body' || $sv == 'html' || $sv == '*'){
  1241. $selectors[$sk] = "$sv #framelessVb";
  1242. } elseif(strpos($sv,'@')===0) {
  1243. $import = explode(';',$sv);
  1244. $import = $import[0].';';
  1245. $sv = substr($sv,strlen($import));
  1246. if($sv == 'body' || $sv == 'html' || $sv == '*'){
  1247. $selectors[$sk] = "$sv #framelessVb";
  1248. } else {
  1249. $selectors[$sk] = "#framelessVb $sv";
  1250. }
  1251. $selectors[$sk] - "framelessVb $sv";
  1252. $imports[]=$import;
  1253. } elseif(strpos($sv,'wysiwyg')===false) {
  1254. $selectors[$sk] = "#framelessVb $sv";
  1255. }
  1256. }
  1257. //reconstruct the element
  1258. $elements[$k] = implode(', ', $selectors) . ' {' . $element[1] . '}';
  1259. }
  1260. //reconstruct theā€¦

Large files files are truncated, but you can click here to view the full file