PageRenderTime 49ms CodeModel.GetById 15ms RepoModel.GetById 0ms app.codeStats 0ms

/components/com_jomcomment/functions.jomcomment.php

https://bitbucket.org/dgough/annamaria-daneswood-25102012
PHP | 729 lines | 669 code | 26 blank | 34 comment | 27 complexity | 0e07bba4beaa8f6c21c9f64de909f890 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1
  1. <?php
  2. /**
  3. * Jom Comment
  4. * @package JomComment
  5. * @copyright (C) 2006 by Azrul Rahim - All rights reserved!
  6. * @license Copyrighted Commercial Software
  7. **/
  8. # Don't allow direct linking
  9. (defined('_VALID_MOS') OR defined('_JEXEC')) or die('Direct Access to this location is not allowed.');
  10. /** String utilities **/
  11. /**
  12. * A more comprehansive nl2br replacement. Note that we need to put a space
  13. * before the <br/>
  14. */
  15. function jcNl2BrStrict($text, $replac=" <br />") {
  16. return preg_replace("/\r\n|\n|\r/", $replac, $text);
  17. }
  18. // str_ireplace replacement for php4 compatibility
  19. function jcStrIReplace($search,$replace,$subject) {
  20. if ( function_exists('str_ireplace') ) {
  21. return str_ireplace($search,$replace,$subject); // php 5 only
  22. }
  23. $srchlen = strlen($search); // lenght of searched string
  24. $result = "";
  25. if(!empty($search)){
  26. while ($find = stristr($subject,$search)) { // find $search text in $subject - case insensitiv
  27. $srchtxt = substr($find,0,$srchlen); // get new case-sensitively-correct search text
  28. $pos = strpos( $subject, $srchtxt ); // stripos is php5 only...
  29. $result .= substr( $subject, 0, $pos ) . $replace; // replace found case insensitive search text with $replace
  30. $subject = substr( $subject, $pos + $srchlen );
  31. }
  32. }
  33. return $result . $subject;
  34. }
  35. function jcStrIPos( $search , $replace )
  36. {
  37. // PHP5 has stripos, just use it
  38. if( function_exists('stripos') ){
  39. return stripos( $search , $replace );
  40. }
  41. // Convert them to lower case and do the search
  42. return strpos($search, stristr( $search, $replace ));
  43. }
  44. function jcValidEmail($email){
  45. return(preg_match( '/^[\w\.\-]+@\w+[\w\.\-]*?\.\w{1,4}$/', $email ));
  46. }
  47. /**
  48. * jcCommentGetNum()
  49. * - Compatibility issues
  50. **/
  51. function jcCommentGetNum($articleId, $option = 'com_content'){
  52. global $mainframe;
  53. if(!function_exists('jcCountComment'))
  54. include_once($mainframe->getCfg('absolute_path') . '/components/com_jomcomment/helper/minimal.helper.php');
  55. return jcCountComment($articleId, $option);
  56. }
  57. // Transforme the utf-8 text into htmlentities compatible string
  58. function jcTransformDbText ($source) {
  59. // if default ISO is already utf-8, just return the string
  60. if(defined('_ISO')){
  61. if(strpos(_ISO, 'UTF-8')){
  62. return $str;
  63. }
  64. }
  65. // array used to figure what number to decrement from character order value
  66. // according to number of characters used to map unicode to ascii by utf-8
  67. $decrement[4] = 240;
  68. $decrement[3] = 224;
  69. $decrement[2] = 192;
  70. $decrement[1] = 0;
  71. // the number of bits to shift each charNum by
  72. $shift[1][0] = 0;
  73. $shift[2][0] = 6;
  74. $shift[2][1] = 0;
  75. $shift[3][0] = 12;
  76. $shift[3][1] = 6;
  77. $shift[3][2] = 0;
  78. $shift[4][0] = 18;
  79. $shift[4][1] = 12;
  80. $shift[4][2] = 6;
  81. $shift[4][3] = 0;
  82. $pos = 0;
  83. $len = strlen ($source);
  84. $encodedString = '';
  85. while ($pos < $len) {
  86. $asciiPos = ord (substr ($source, $pos, 1));
  87. // we must skip standard ascii cahracter from being unicode encoded!
  88. if($asciiPos > 31 && $asciiPos <= 127){
  89. $encodedString .= substr ($source, $pos, 1);
  90. $pos++;
  91. }
  92. else
  93. {
  94. if (($asciiPos >= 240) && ($asciiPos <= 255)) {
  95. // 4 chars representing one unicode character
  96. $thisLetter = substr ($source, $pos, 4);
  97. $pos += 4;
  98. }
  99. else if (($asciiPos >= 224) && ($asciiPos <= 239)) {
  100. // 3 chars representing one unicode character
  101. $thisLetter = substr ($source, $pos, 3);
  102. $pos += 3;
  103. }
  104. else if (($asciiPos >= 192) && ($asciiPos <= 223)) {
  105. // 2 chars representing one unicode character
  106. $thisLetter = substr ($source, $pos, 2);
  107. $pos += 2;
  108. }
  109. else {
  110. // 1 char (lower ascii)
  111. $thisLetter = substr ($source, $pos, 1);
  112. $pos += 1;
  113. }
  114. // process the string representing the letter to a unicode entity
  115. $thisLen = strlen ($thisLetter);
  116. $thisPos = 0;
  117. $decimalCode = 0;
  118. while ($thisPos < $thisLen) {
  119. $thisCharOrd = ord (substr ($thisLetter, $thisPos, 1));
  120. if ($thisPos == 0) {
  121. $charNum = intval ($thisCharOrd - $decrement[$thisLen]);
  122. $decimalCode += ($charNum << $shift[$thisLen][$thisPos]);
  123. }
  124. else {
  125. $charNum = intval ($thisCharOrd - 128);
  126. $decimalCode += ($charNum << $shift[$thisLen][$thisPos]);
  127. }
  128. $thisPos++;
  129. }
  130. if ($thisLen == 1)
  131. $encodedLetter = "&#". str_pad($decimalCode, 3, "0", STR_PAD_LEFT) . ';';
  132. else
  133. $encodedLetter = "&#". str_pad($decimalCode, 5, "0", STR_PAD_LEFT) . ';';
  134. $encodedString .= $encodedLetter;
  135. }
  136. }
  137. return $encodedString;
  138. }
  139. /**
  140. * trim the given variable
  141. */
  142. function jcTrim(& $val) {
  143. $val = trim($val);
  144. return $val;
  145. }
  146. // Wrap the given text
  147. function jcTextwrap($text, $width = 75) {
  148. if ($text)
  149. return preg_replace("/([^\n\r ?&\.\/<>\"\\-]{" . $width . "})/i", " \\1\n", $text);
  150. }
  151. /** Comments **/
  152. /**
  153. * Return valid Itemid for my blog links
  154. * If 'option' are currently on myblog, then use current ItemId
  155. */
  156. function jcGetMyBlogItemid(){
  157. static $jcItemid = -1;
  158. if($jcItemid == -1){
  159. global $Itemid;
  160. $db = &cmsInstance('CMSDb');
  161. $jcItemid = $Itemid;
  162. $db->query("select id from #__menu where link LIKE '%option=com_myblog%' and published='1' AND `id`='$jcItemid'");
  163. if(!$db->get_value()){
  164. // The current itemId is not myblog related, ignore it, and find a valid one
  165. // Menu type is 'component' for Joomla 1.0 and 'components' for Jooma 1.5
  166. $db->query("select id from #__menu where (type='component' or type='components') and link='index.php?option=com_myblog' and published='1'");
  167. $jcItemid = $db->get_value();
  168. }
  169. }
  170. return $jcItemid;
  171. }
  172. # Post request to remote server
  173. function jcHttpPost($host, $query, $others = '') {
  174. if(function_exists('curl_init')){
  175. $ch = curl_init();
  176. curl_setopt ($ch, CURLOPT_URL, "http://" .$host . "?". $query);
  177. curl_setopt ($ch, CURLOPT_HEADER, 0);
  178. ob_start();
  179. curl_exec ($ch);
  180. curl_close ($ch);
  181. $string = ob_get_contents();
  182. ob_end_clean();
  183. return $string;
  184. }
  185. //
  186. // if(ini_get('allow_url_fopen') == 1){
  187. // $dh = @fopen("http://". $host . "?". $query,'r');
  188. // if($dh === FALSE){
  189. // # fopen failed, Do nothing
  190. // } else {
  191. // $result = fread($dh,8192);
  192. // return $result;
  193. // }
  194. // }
  195. $path = explode('/', $host);
  196. $host = $path[0];
  197. $r = "";
  198. unset ($path[0]);
  199. $path = '/' . (implode('/', $path));
  200. $post = "POST $path HTTP/1.0\r\nHost: $host\r\nContent-type: application/x-www-form-urlencoded\r\n${others}User-Agent: Mozilla 4.0\r\nContent-length: " . strlen($query) . "\r\nConnection: close\r\n\r\n$query";
  201. $h = @fsockopen($host, 80, $errno, $errstr, 7);
  202. if ($h) {
  203. fwrite($h, $post);
  204. for ($a = 0, $r = ''; !$a;) {
  205. $b = fread($h, 8192);
  206. $r .= $b;
  207. $a = (($b == '') ? 1 : 0);
  208. }
  209. fclose($h);
  210. }
  211. return $r;
  212. }
  213. /**
  214. * Basically, we need to add the HTTPS support if required.
  215. */
  216. function jcFixLiveSiteUrl($content){
  217. //global
  218. $cms =& cmsInstance('CMSCore');
  219. $live_site = $cms->get_path('live');
  220. $reqURI = $live_site;
  221. # if host have wwww, but mosConfig doesn't
  222. if((substr_count($_SERVER['HTTP_HOST'], "www.") != 0) && (substr_count($reqURI, "www.") == 0)) {
  223. $reqURI = str_replace("://", "://www.", $reqURI);
  224. } else if((substr_count($_SERVER['HTTP_HOST'], "www.") == 0) && (substr_count($reqURI, "www.") != 0)) {
  225. // host do not have 'www' but mosConfig does
  226. $reqURI = str_replace("www.", "", $reqURI);
  227. }
  228. /* Check for HTTPS */
  229. if(isset($_SERVER)){
  230. if(isset($_SERVER['HTTPS'])){
  231. if(strtolower($_SERVER['HTTPS']) == "on" ){
  232. $reqURI = str_replace("http://", "https://", $reqURI);
  233. }
  234. }
  235. } else if(isset($_SERVER['REQUEST_URI'])) {
  236. // use REQUEST_URI method
  237. if(strpos($_SERVER['REQUEST_URI'], 'https://') === FALSE){
  238. // not a https
  239. } else {
  240. $reqURI = str_replace("http://", "https://", $reqURI);
  241. }
  242. }
  243. return str_replace($live_site, $reqURI, $content);
  244. }
  245. function jcGetTemplatePath($file){
  246. global $_JC_CONFIG;
  247. $path = JC_COM_PATH . '/templates/_default/' . $file;
  248. // Template overriding.
  249. if($_JC_CONFIG->get('overrideTemplate')){
  250. $customPath = JC_CUSTOM_TPL . '/' . $file;
  251. if(file_exists($customPath))
  252. $path = $customPath;
  253. } else {
  254. $template = JC_COM_PATH . '/templates/' . $_JC_CONFIG->get('template');
  255. if(file_exists($template . '/' . $file))
  256. $path = $template . '/' . $file;
  257. }
  258. return $path;
  259. }
  260. function jcCreatePagingLink($baseUrl, $total, $limit, $limitStart){
  261. $html = array();
  262. return $html;
  263. }
  264. function jcIsValidtf8($Str) {
  265. /*
  266. if(function_exists('mb_detect_encoding')){
  267. $enc = mb_detect_encoding($Str, "auto");
  268. $iso = explode( '=', _ISO );
  269. return ($enc == $iso);
  270. } else
  271. */ {
  272. for ($i = 0; $i < strlen($Str) / 5; $i++) {
  273. if (ord($Str[$i]) < 0x80)
  274. continue; # 0bbbbbbb
  275. elseif ((ord($Str[$i]) & 0xE0) == 0xC0) $n = 1; # 110bbbbb
  276. elseif ((ord($Str[$i]) & 0xF0) == 0xE0) $n = 2; # 1110bbbb
  277. elseif ((ord($Str[$i]) & 0xF8) == 0xF0) $n = 3; # 11110bbb
  278. elseif ((ord($Str[$i]) & 0xFC) == 0xF8) $n = 4; # 111110bb
  279. elseif ((ord($Str[$i]) & 0xFE) == 0xFC) $n = 5; # 1111110b
  280. else
  281. return false; # Does not match any model
  282. for ($j = 0; $j < $n; $j++) { # n bytes matching 10bbbbbb follow ?
  283. if ((++ $i == strlen($Str)) || ((ord($Str[$i]) & 0xC0) != 0x80))
  284. return false;
  285. }
  286. }
  287. return true;
  288. }
  289. }
  290. /**
  291. * Decode the BBCode
  292. */
  293. function jcDecodeSmilies($comment) {
  294. $cms =& cmsInstance('CMSCore');
  295. $live_site = $cms->get_path('live');
  296. $img_path = $live_site;
  297. # fix smilies
  298. $smilies = array (
  299. ":)" => "smilies/smiley.gif",
  300. ";)" => "smilies/wink.gif",
  301. ":D" => "smilies/cheesy.gif",
  302. ";D" => "smilies/grin.gif",
  303. ">:(" => "smilies/angry.gif",
  304. ":(" => "smilies/sad.gif",
  305. ":o" => "smilies/shocked.gif",
  306. "8)" => "smilies/cool.gif",
  307. "::)" => "smilies/rolleyes.gif",
  308. ":P" => "smilies/tongue.gif",
  309. ":-[" => "smilies/embarassed.gif",
  310. ":-X" => "smilies/lipsrsealed.gif",
  311. ":-*" => "smilies/kiss.gif",
  312. ":'(" => "smilies/cry.gif"
  313. );
  314. $smiliesAlt = array (
  315. ":)" => 'smile',
  316. ";)" => 'wink',
  317. ":D" => 'laugh',
  318. ";D" => 'grin',
  319. ">:(" => 'angry',
  320. ":(" => 'sad',
  321. ":o" => 'shocked',
  322. "8)" => 'cool',
  323. "::)" => "rolleyes",
  324. ":P" => 'tongue',
  325. ":-[" => "embarassed",
  326. ":-X" => "lips sealed",
  327. ":-*" => 'kiss',
  328. ":'(" => 'cry'
  329. );
  330. foreach ($smilies as $key => $value) {
  331. $comment = str_replace($key, "<img src='$img_path/"."components/com_jomcomment/" . $value . "' title='{$smiliesAlt[$key]}' border='0' alt='$value' />", $comment);
  332. }
  333. return $comment;
  334. }
  335. /**
  336. * Return the content author's id
  337. */
  338. function jcGetContentAuthor($cid) {
  339. $db = &cmsInstance('CMSDb');
  340. $db->query("SELECT created_by from #__content WHERE id=$cid");
  341. return $db->get_value();
  342. }
  343. function jcGetAuthorName($uid) {
  344. $db = &cmsInstance('CMSDb');
  345. $db->query("SELECT name from #__users WHERE id={$uid}");
  346. return $db->get_value();
  347. }
  348. function jcContentTitle($cid) {
  349. $db = &cmsInstance('CMSDb');
  350. $db->query("SELECT title from #__content WHERE id=$cid");
  351. $title = $db->get_value();
  352. if(!$title)
  353. $title = "n/a";
  354. return $title;
  355. }
  356. function jcContentPublished($cid){
  357. $db = &cmsInstance('CMSDb');
  358. $db->query("SELECT state from #__content WHERE id=$cid");
  359. return $db->get_value();
  360. }
  361. /**
  362. * $ip : ip to test
  363. * $ips: array of test condition
  364. */
  365. function jcCheckBlockedIp($ip, $ips) {
  366. # read in the ip address file
  367. $lines = $ips; //file("ipaddresses.txt");
  368. # set a variable as false
  369. $found = false;
  370. # convert ip address into a number
  371. $split_it = split("\.",$ip);
  372. $ip = "1" . sprintf("%03d",$split_it[0]) .
  373. sprintf("%03d",$split_it[1]) . sprintf("%03d",$split_it[2]) .
  374. sprintf("%03d",$split_it[3]);
  375. # loop through the ip address file
  376. foreach ($lines as $line) {
  377. # remove line feeds from the line
  378. $line = chop($line);
  379. # replace x with a *
  380. $line = str_replace("x","*",$line);
  381. # remove comments
  382. $line = preg_replace("|[A-Za-z#/]|","",$line);
  383. # set a maximum and minimum value
  384. $max = $line;
  385. $min = $line;
  386. # replace * with a 3 digit number
  387. if ( strpos($line,"*",0) <> "" ) {
  388. $max = str_replace("*","999",$line);
  389. $min = str_replace("*","000",$line);
  390. }
  391. # replace ? with a single digit
  392. if ( strpos($line,"?",0) <> "" ) {
  393. $max = str_replace("?","9",$line);
  394. $min = str_replace("?","0",$line);
  395. }
  396. # if the line is invalid go to the next line
  397. if ( $max == "" ) { continue; };
  398. # check for a range
  399. if ( strpos($max," - ",0) <> "" ) {
  400. $split_it = split(" - ",$max);
  401. # if the second part does not match an ip address
  402. if ( !preg_match("|\d{1,3}\.|",$split_it[1]) ) {
  403. $max = $split_it[0];
  404. }
  405. else {
  406. $max = $split_it[1];
  407. };
  408. }
  409. if ( strpos($min," - ",0) <> "" ) {
  410. $split_it = split(" - ",$min);
  411. $min = $split_it[0];
  412. }
  413. # make $max into a number
  414. $split_it = split("\.",$max);
  415. for ( $i=0;$i<4;$i++ ) {
  416. if ( $i == 0 ) { $max = 1; };
  417. if ( strpos($split_it[$i],"-",0) <> "" ) {
  418. $another_split = split("-",$split_it[$i]);
  419. $split_it[$i] = $another_split[1];
  420. }
  421. $max .= sprintf("%03d",$split_it[$i]);
  422. }
  423. # make $min into a number
  424. $split_it = split("\.",$min);
  425. for ( $i=0;$i<4;$i++ ) {
  426. if ( $i == 0 ) { $min = 1; };
  427. if ( strpos($split_it[$i],"-",0) <> "" ) {
  428. $another_split = split("-",$split_it[$i]);
  429. $split_it[$i] = $another_split[0];
  430. }
  431. $min .= sprintf("%03d",$split_it[$i]);
  432. }
  433. # check for a match
  434. if ( ($ip <= $max) && ($ip >= $min) ) {
  435. $found = true;
  436. break;
  437. };
  438. }
  439. return $found;
  440. }; # end function
  441. function jcClearCache(){
  442. global $mainframe;
  443. $cms =& cmsInstance('CMSCore');
  444. $cms->load('helper','directory');
  445. $cms->load('libraries', 'cache');
  446. $cms->cache->clear();
  447. $list = cmsGetFiles(JC_CACHE_PATH, '');
  448. foreach($list as $file){
  449. // Only remove files that contains the naming convention for cache_
  450. if(strstr($file, 'cache_')){
  451. @unlink(JC_CACHE_PATH . '/' . $file);
  452. }
  453. }
  454. // For Joomla 1.0 we would still need to clear the cached files
  455. // located in $mosConfig_cachepath
  456. if(cmsVersion() == _CMS_JOOMLA10 || cmsVersion() == _CMS_MAMBO){
  457. $list = cmsGetFiles($mainframe->getCfg('cachepath'), '');
  458. foreach($list as $file){
  459. if(strstr($file, 'cache_'))
  460. @unlink($mainframe->getCfg('cachepath') . '/' . $file);
  461. }
  462. }
  463. // For Joomla 1.5 we would also need to clear the cached files for JCache.
  464. if(cmsVersion() == _CMS_JOOMLA15){
  465. if($mainframe->getCfg('caching')){
  466. $cache =& JFactory::getCache();
  467. // Clear com_content's cache
  468. $cache->clean('com_content');
  469. }
  470. }
  471. }
  472. function jcGetCommentHtml($id, $extoption, $row){
  473. global $_JOMCOMMENT;
  474. return $_JOMCOMMENT->getHTML($id, $extoption, $row);
  475. }
  476. /**
  477. * Similar to mosCreateMail, except that we need to change the email
  478. * encoding to utf-8
  479. */
  480. function jomCreateMail($from = '', $fromname = '', $subject, $body) {
  481. $cms =& cmsInstance('CMSCore');
  482. if(cmsVersion() == _CMS_JOOMLA15){
  483. $cms->load('libraries','cfg');
  484. jimport('joomla.mail.mail');
  485. $mail =& JFactory::getMailer();
  486. $fromname = $fromname ? $fromname : $cms->cfg->get('fromname');
  487. $from = $from ? $from : $cms->cfg->get('mailfrom');
  488. $mail->setSender(array($from,$fromname));
  489. $mail->setSubject($subject);
  490. $mail->setBody($body);
  491. }else if(cmsVersion() == _CMS_JOOMLA10 || cmsVersion() == _CMS_MAMBO){
  492. $mail = new mosPHPMailer();
  493. global $mainframe;
  494. $mail->PluginDir = $cms->get_path('root') . '/includes/phpmailer/';
  495. $mail->SetLanguage('en', $cms->get_path('root') . '/includes/phpmailer/language/');
  496. $mail->CharSet = 'UTF-8'; //substr_replace(_ISO, '', 0, 8);
  497. $mail->IsMail();
  498. $mail->From = $from ? $from : $mainframe->getCfg('mailfrom');
  499. $mail->FromName = $fromname ? $fromname : $mainframe->getCfg('fromname');
  500. $mail->Mailer = $mainframe->getCfg('mailer');
  501. // Add smtp values if needed
  502. if ($mainframe->getCfg('mailer') == 'smtp') {
  503. $mail->IsSMTP();
  504. $mail->SMTPAuth = $mainframe->getCfg('smtpauth');
  505. $mail->Username = $mainframe->getCfg('smtpuser');
  506. $mail->Password = $mainframe->getCfg('smtppass');
  507. $smtphost = $mainframe->getCfg('smtphost');
  508. $hostIp = split(":", $smtphost);
  509. if(count($hostIp)> 1){
  510. $mail->Host = $hostIp[0];
  511. $mail->Port = $hostIp[1];
  512. } else {
  513. $mail->Host = $mainframe->getCfg('smtphost');
  514. }
  515. } else{
  516. // Set sendmail path
  517. if ($mainframe->getCfg('mailer') == 'sendmail') {
  518. $sendmail = $mainframe->getCfg('sendmail');
  519. if (isset ($sendmail))
  520. $mail->Sendmail = $sendmail;
  521. } // if
  522. }
  523. $mail->Subject = $subject;
  524. $mail->Body = $body;
  525. }
  526. return $mail;
  527. }
  528. /**
  529. * Sending out email. Very similar to mosMail, except that we uses jomCreateMail
  530. * instead of mosCreateMail to allow us to change the encoding.
  531. */
  532. function jomMail($from, $fromname, $recipient, $subject, $body, $mode = 0, $cc = NULL, $bcc = NULL, $attachment = NULL, $replyto = NULL, $replytoname = NULL) {
  533. $body = stripslashes($body);
  534. $mail = jomCreateMail($from, $fromname, $subject, $body);
  535. // activate HTML formatted emails
  536. if ($mode) {
  537. $mail->IsHTML(true);
  538. }
  539. // Check if mail address is valid.
  540. $regexp = "^([_a-z0-9-]+)(\.[_a-z0-9-]+)*@([a-z0-9-]+)(\.[a-z0-9-]+)*(\.[a-z]{2,4})$";
  541. if (is_array($recipient)) {
  542. foreach ($recipient as $to) {
  543. if(!empty($to) && eregi($regexp, $to)){
  544. $mail->AddAddress($to);
  545. }
  546. }
  547. } else {
  548. if(!empty($recipient) && eregi($regexp, $recipient)){
  549. $mail->AddAddress($recipient);
  550. }
  551. }
  552. if (isset ($cc)) {
  553. if (is_array($cc)) {
  554. foreach ($cc as $to) {
  555. $mail->AddCC($to);
  556. }
  557. } else {
  558. $mail->AddCC($cc);
  559. }
  560. }
  561. if (isset ($bcc)) {
  562. if (is_array($bcc)) {
  563. foreach ($bcc as $to) {
  564. $mail->AddBCC($to);
  565. }
  566. } else {
  567. $mail->AddBCC($bcc);
  568. }
  569. }
  570. if ($attachment) {
  571. if (is_array($attachment)) {
  572. foreach ($attachment as $fname) {
  573. $mail->AddAttachment($fname);
  574. }
  575. } else {
  576. $mail->AddAttachment($attachment);
  577. }
  578. }
  579. if(cmsVersion() == _CMS_JOOMLA15){
  580. if($replyto){
  581. $mail->addReplyTo(array($replyto, $replytoname));
  582. }
  583. } else {
  584. //Important for being able to use mosMail without spoofing...
  585. if ($replyto) {
  586. if (is_array($replyto)) {
  587. reset($replytoname);
  588. foreach ($replyto as $to) {
  589. $toname = ((list ($key, $value) = each($replytoname)) ? $value : '');
  590. $mail->AddReplyTo($to, $toname);
  591. }
  592. } else {
  593. $mail->AddReplyTo($replyto, $replytoname);
  594. }
  595. }
  596. }
  597. $mailssend = $mail->Send();
  598. return $mailssend;
  599. }
  600. // return ItemID for jom comment link
  601. function jcGetItemID(){
  602. $db = &cmsInstance('CMSDb');
  603. static $jcitemid = '';
  604. if(empty($jcitemid)){
  605. # autodetect Itemid
  606. $query = "SELECT id FROM #__menu WHERE type='components' "
  607. ."AND link='index.php?option=com_jomcomment' "
  608. ."AND published='1'";
  609. $db->query($query);
  610. $jcitemid = $db->get_value();
  611. if (!$jcitemid){
  612. if (isset ($_REQUEST['Itemid']) and $_REQUEST['Itemid'] != "" and $_REQUEST['Itemid'] != "0"){
  613. $jcitemid = $_REQUEST['Itemid'];
  614. } else
  615. $jcitemid = 1;
  616. }
  617. }
  618. return $jcitemid;
  619. }
  620. // Return the 'Powered by xxx' link
  621. function jcGetPoweredByLink(){
  622. return '';
  623. return '<div style="text-align:center;font-size:95%"><a target="_blank" href="http://www.azrul.com">Powered by Azrul&#39;s Jom Comment for Joomla!</a></div>';
  624. }