....................................../////.===Hehe-Here===./////................................................ > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < > < ------------------------------------------------------------------------------------------------------------------- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////// RIFF¤ WEBPVP8 ˜ ðÑ *ôô>‘HŸK¥¤"§£±¨àð enü¹%½_F‘åè¿2ºQú³íªú`N¿­3ÿƒügµJžaÿ¯ÿ°~¼ÎùnúîÞÖô•òíôÁÉß®Sm¥Ü/ ‡ó˜f£Ùà<˜„xëJ¢Ù€SO3x<ªÔ©4¿+ç¶A`q@Ì“Úñè™ÍÿJÌ´ª-˜ÆtÊÛL]Ïq*‘Ý”ì#ŸÌÏãY]@ê`¿ /ªfkØB4·®£ó z—Üw¥Pxù–ÞLШKÇN¾AkÙTf½è'‰g gÆv›Øuh~ a˜Z— ïj*á¥t d£“uÒ ¨`K˜¹ßþ]b>˜]_ÏÔ6W—è2r4x•íÖ…"ƒÖNîä!¦å Ú}ýxGøÌ —@ ;ÆÚŠ=ɾ1ý8lªË¥ô ^yf®Œ¢u&2©nÙÇ›ñÂñŒ³ aPo['½»øFùà­+4ê“$!lövlüÞ=;N®3ð‚õ›DÉKòÞ>ÄÍ ¥ˆuߤ#ˆ$6ù™¥îЇy’ÍB¼ çxÛ;X"WL£R÷͝*ó-¶Zu}º.s¸sšXqù–DþÿvªhüïwyŸ ¯é³lÀ:KCûÄ£Ëá\…­ ~—ýóî ¼ûûÜTÓüÇy…ŽÆvc»¾×U ñ¸žþоP÷¦ó:Ò¨¨5;Ð#&#ÖúñläÿÁœ GxÉ­/ñ‡áQðìYÉtÒw޼GÔ´zàÒò ð*ëzƒ•4~H]Ø‹f ñÓÈñ`NåWçs'ÆÏW^ø¹!XžµmQ5ÃËoLœÎ: ÞËÍ¥J ù…î èo£ßPÎñ¶ž8.Œ]ʵ~5›ÙË-ù*8ÙÖß±~ ©¹rÓê‚j¶d¸{^Q'˜±Crß ÚH—#¥¥QlÀ×ëã‡DÜ«èî þ&Çæžî;ŽÏºò6ÒLÃXy&ZŒ'j‚¢Ù€IßÚù+–MGi‰*jE€‘JcÜ ÓÌ EÏÚj]o˜ Þr <¾U ûŪæÍ/šÝH¥˜b”¼ ÁñßX GP›ï2›4WŠÏà×£…íÓk†¦H·ÅíMh–*nó÷à]ÁjCº€b7<ب‹¨5車bp2:Á[UªM„QŒçiNMa#<5›áËó¸HýÊ"…×Éw¹¦ì2º–x<›»a±¸3Weü®FÝ⑱ö–î–³|LPÈ~çð~Çå‡|º kD¢µÏàÆAI %1À% ¹Ò – ”ϝS¦‰4&¶£°à Öý”û_Ò Áw°A«Å€?mÇÛgHÉ/8)á¾ÛìáöŽP í¨PŸNÙµº¦‡§Ùš"ÿ«>+ªÕ`Ê÷‡‚ß Õû˜þãÇ-PÍ.¾XV‘€ dÜ"þ4¹ ±Oú‘©t¥¦FªÄÃÄ•b‚znýu½—#cDs˜ÃiÑOˆñ×QO=*IAÊ,¶ŽZƒ;‡wøXè%EÐk:F±Ú” .Ѽ+Áu&Ç`."pÈÉw o&¿dE6‘’EqTuK@Ì¥ã™À(Êk(h‰,H}RÀIXÛš3µ1©_OqÚÒJAñ$ÊÙÜ;D3çŒ[þùœh¬Ã³™ö6ç†NY".Ú‰ï[ªŸŒ '²Ð öø_¨ÂÉ9ué¶³ÒŠõTàîMØ#û¯gN‡bÙ놚X„ö …ÉeüÌ^J ‹€.œ$Æ)βÄeæW#óüßĺŸ€ ÀzwV 9oä»f4V*uB «Ë†¹ì¯žR霓æHXa=&“I4K;¯ç‹h×·"UŠ~<•╪Vêª&ÍSÃÆÅ?ÔqÎ*mTM ˜›µwêd#[C¡©§‘D<©àb†–ÁœøvH/,í:¯( ²£|4-„Æövv„Yͼ™^Á$ˆ„¢Û[6yB.åH*V¨æ?$=˜Ñ€•ñ·­(VlŸ‘ nÀt8W÷´Bûba?q9ú¶Xƒl«ÿ\ù¶’þòUÐj/õ¢Ìµ³g$ƒÎR!¸»|Oߍë’BhîÚÑ¢ñåŒJ„®„£2Ð3•ô02Nt…!£Í]Ïc½Qÿ?ˆ<&ÃA¾Ú,JˆijÌ#5yz„‰Î|ÊŽ5QÏ:‹ÐaóVÔxW—CpeÏzÐïíçôÿÅ_[hãsÐ_/ŽTÝ?BîˆííV$<¿i>²F¬_Eß¿ †bÊŒº­ÿ®Z H“C}”¬,Mp ý/Bá£w>˜YV°aƒúh+cŠ- r/[%|üUMHäQ°X»|û/@|°¥Ð !BÔ Ç¢Ä©š+Õì D«7ìN¶ŽðÔ " ƶ’ÖçtA‰Û×}{tþz­¾GÍ›k¹OEJR$ Â׃ «ëÁ"oÉôž$oUK(Ä)Ãz³Ê-‹êN[Ò3Œñbï8P 4ƒ×q¢bo|?<ÛX¬òÄͰL–±›(™ûG?ýË©ÚÄ–ÂDØÐ_Ç¡ô ¾–ÄÏø ×e8Ë©$ÄF¹Å‹ì[©óìl:F¾f´‹‹Xì²ï®\¬ôùƒ ÿat¥óèÒùHß0äe‚;ü×h:ÆWðHž=Ã8骣"kœ'Y?³}Tûè€>?0l›e1Lòñ„aæKÆw…hÖŠùW…ÈÆÄ0ši·›[pcwËþñiêíY/~-Á5˜!¿†A›™Mÿþ(±“t@â“ö2­´TG5yé]çå僳 .·ÍïçÝ7UÚ±Ð/Nè»,_Ï ùdj7\ï Wì4›„»c¸àešg#ÒÊ⥭áØo5‘?ÌdÝô¯ ¹kzsƒ=´#ëÉK›Ø´±-¥eW?‡çßtòTã…$Ý+qÿ±ƒ÷_3Ô¥í÷:æ–ž<·Ö‡‰Å¢ š‡%Ô—utÌÈìðžgÖÀz²À—ï÷Óîäõ{K'´È÷³yaÏÁjƒô}ž§®æÊydÕÈë5¯èˆõvÕ©ã*çD„ “z„Ó‡^^xÂ3M§A´JG‚öï 3W'ˆ.OvXè¡ÊÕª?5º7†˜(˜Ç¶#çê’¶!ÌdZK§æ 0fãaN]òY³RV ™î$®K2R¨`W!1Ôó\;Ý ýB%qæK•&ÓÈe9È0êI±žeŸß -ú@žQr¦ ö4»M¼Áè¹µmw 9 EÆE_°2ó„ŸXKWÁ×Hóì^´²GѝF©óäR†¦‰ç"V»eØ<3ùd3ÿÚ¤Žú“Gi" —‘_ÙËÎ~Üö¯¥½Î»üŸEÚŽåmÞþí ;ÞólËΦMzA"Âf(´òá;Éï(/7½ûñÌ­cïÕçлþÝz¾-ÍvÑ“pH­–ðÓj$¸Äû¤‚‘ãUBË-n“2åPkS5&‹Â|+g^œ®Ì͆d!OïäîU«c;{Û!ÅŽ«ëZ9Ókóˆ]¯ƒ›né `ÇÒ+tÆš (ØKá¾—=3œ®•vuMñg²\ï Ec€ 05±d™‡×iÇ×›UúvÌ¢£Èþ¡ÕØô¶ßÎA"ß±#Ö²ˆÊŸ¦*Ä~ij|àø.-¼'»Ú¥£h ofº¦‡VsR=N½„Î v˜Z*SÌ{=jÑB‹tê…;’HžH¯8–îDù8ñ¢|Q•bÛçš–‹m³“ê¨ åÏ^m¬Žãþ©ïêO‡½6] µÆ„Ooòü ²x}N¦Ë3ïé¿»€›HA˜m%çÞ/¿í7Fø“‹léUk)É°Œµ8Q8›:ÀŠeT*šõ~ôڝG6 ¢}`ùH­–”¡k ‰P1>š†®9z11!X wKfmÁ¦xÑ,N1Q”–æB¶M…ÒÃv6SMˆhU¬ÊPŽï‘öj=·CŒ¯u¹ƒVIЃsx4’ömÛýcå¡¶7ßŠß 57^\wÒÐÆ k§h,Œý î«q^R½3]J¸ÇðN ‚çU¬ôº^Áì} ³f©Õœ§ˆã:FÄÈ‚é(€™?àýÓüè1Gô£¼éj‚OÅñ  #>×—ßtà 0G¥Åa뀐kßhc™À_ÉñÞ#±)GD" YîäË-ÿÙ̪ ¹™a¯´¢E\ÝÒö‚;™„ë]_ p8‰o¡ñ+^÷ 3‘'dT4œŽ ðVë½° :¬víÑ«£tßÚS-3¶“þ2 †üüʨòrš¹M{É_¤`Û¨0ìjœøJ‡:÷ÃáZ˜†@GP&œÑDGÏs¡þ¦þDGú‘1Yá9Ôþ¼ ûø…§÷8&–ÜÑnÄ_m®^üÆ`;ÉVÁJ£?â€-ßê}suÍ2sõA NÌúA磸‘îÿÚ»ƒìö·á¿±tÑÐ"Tÿü˜[@/äj¬€uüªìù¥Ý˜á8Ý´sõj 8@rˆð äþZÇD®ÿUÏ2ùôõrBzÆÏÞž>Ì™xœ“ wiÎ×7_… ¸ \#€MɁV¶¥üÕÿPÔ9Z‡ø§É8#H:ƒ5ÀÝå9ÍIŒ5åKÙŠ÷qÄ>1AÈøžj"µÂд/ªnÀ qªã}"iŸBå˜ÓÛŽ¦…&ݧ;G@—³b¯“•"´4í¨ôM¨åñC‹ïùÉó¯ÓsSH2Ý@ßáM‡ˆKÀªÛUeø/4\gnm¥‹ŸŒ qÄ b9ÞwÒNÏ_4Ég³ú=܆‚´ •â¥õeíþkjz>éÚyU«Íӝ݃6"8/ø{=Ô¢»G¥ äUw°W«,ô—¿ãㆅү¢³xŠUû™yŒ (øSópÐ 9\åTâ»—*oG$/×ÍT†Y¿1¤Þ¢_‡ ¼ „±ÍçèSaÓ 3ÛMÁBkxs‰’R/¡¤ˆÙçª(*õ„üXÌ´ƒ E§´¬EF"Ù”R/ÐNyÆÂ^°?™6¡œïJ·±$§?º>ÖüœcNÌù¯G ‹ñ2ЁBB„^·úìaz¨k:#¨Æ¨8LÎõލ£^§S&cŒÐU€ü(‡F±Š¼&P>8ÙÁ ‰ p5?0ÊÆƒZl¸aô š¼¡}gÿ¶zÆC²¹¬ÎÖG*HB¡O<º2#ñŒAƒ–¡B˜´É$¥›É:FÀÔx¾u?XÜÏÓvN©RS{2ʈãk9rmP¼Qq̳ è¼ÐFׄ^¡Öì fE“F4A…!ì/…¦Lƒ… … $%´¾yã@CI¬ á—3PþBÏNÿ<ý°4Ü ËÃ#ØÍ~âW«rEñw‹eùMMHß²`¬Öó½íf³:‹k˜¯÷}Z!ã¿<¥,\#öµÀ¯aÒNÆIé,Ћ–lŽ#Àæ9ÀÒS·I’½-Ïp Äz¤Š Â* ­íÄ9­< h>׍3ZkËU¹§˜ŒŠ±f­’¤º³Q ÏB?‹#µíÃ¥®@(Gs«†vI¥Mµ‹Á©e~2ú³ÁP4ìÕi‚²Ê^ö@-DþÓàlÜOÍ]n"µã:žpsŽ¢:! Aõ.ç~ÓBûH÷JCÌ]õVƒd «ú´QÙEA–¯¯Œ!.ˆˆëQ±ù œ·Ì!Õâ )ùL„ÅÀlÚè5@B…o´Æ¸XÓ&Û…O«˜”_#‡ƒ„ûÈt!¤ÁÏ›ÎÝŠ?c9 â\>lÓÁVÄÑ™£eØY]:fÝ–—ù+p{™ðè û³”g±OƒÚSù£áÁÊ„ä,ï7š²G ÕÌBk)~ÑiCµ|h#u¤¶îK¨² #²vݯGãeÖ϶ú…¾múÀ¶þÔñ‚Š9'^($¤§ò “š½{éúp÷J›ušS¹áªCÂubÃH9™D™/ZöØÁ‡¦ÝÙŸ·kð*_”.C‹{áXó€‡c¡c€§/šò/&éš÷,àéJþ‰X›fµ“C¨œ®r¬"kL‰Â_q…Z–.ÉL~O µ›zn‚¹À¦Öª7\àHµšÖ %»ÇníV[¥*Õ;ƒ#½¾HK-ÖIÊdÏEÚ#=o÷Óò³´Š: Ç?{¾+9›–‘OEáU·S€˜j"ÄaÜ ŒÛWt› á–c#a»pÔZÞdŽtWê=9éöÊ¢µ~ ë ;Öe‡Œ®:bî3±ýê¢wà¼îpêñ¹¾4 zc¾ðÖÿzdêŒÑÒŝÀ‰s6¤í³ÎÙB¿OZ”+F¤á‡3@Ñëäg©·Ž ˆèª<ù@É{&S„œÕúÀA)‰h:YÀ5^ÂÓŒ°õäU\ ùËÍû#²?Xe¬tu‰^zÒÔãë¼ÛWtEtû …‚g¶Úüâî*moGè¨7%u!]PhÏd™Ý%Îx: VÒ¦ôÊD3ÀŽKÛËãvÆî…N¯ä>Eró–ð`5 Œ%u5XkñÌ*NU%¶áœÊ:Qÿú»“úzyÏ6å-၇¾ ´ ÒÊ]y žO‘w2Äøæ…H’²f±ÎÇ.ª|¥'gîV•Ü .̘¯€šòü¤U~Ù†*¢!?ò wý,}´°ÔÞnïoKq5µb!áÓ3"vAßH¡³¡·G(ÐÎ0Îò¼MG!/ài®@—¬04*`…«é8ªøøló“ˆÊ”èù¤…ßÊoÿé'ËuÌÖ5×È¡§ˆˆfŽë9}hìâ_!!¯  B&Ëö¶‰ÀAÙNVŸ Wh›¸®XÑJì¨ú“¿÷3uj²˜¨ÍÎìë±aúŠÝå¯ð*Ó¨ôJ“yºØ)m°WýOè68†ŸÏ2—‰Ïüꪫٚ¥‹l1 ø ÏÄFjêµvÌbü¦èÝx:X±¢H=MÐß—,ˆÉÇ´(9ú¾^ÅÚ4¿m‡$âX‘å%(AlZo@½¨UOÌÕ”1ø¸jÎÀÃÃ_ µ‘Ü.œº¦Ut: Æï’!=¯uwû#,“pþÇúŒø(é@?³ü¥‘Mo §—s@Œ#)§ŒùkL}NOÆêA›¸~r½¼ÙA—HJ«eˆÖ´*¡ÓpÌŸö.m<-"³ûÈ$¬_6­åf£ïÚâj1y§ÕJ½@dÞÁr&Í\Z%D£Íñ·AZ Û³øüd/ªAi†/Й~  ‡âĮҮÏh§°b—›Û«mJžòG'[ÈYýŒ¦9psl ýÁ ®±f¦x,‰½tN ‚Xª9 ÙÖH.«Lo0×?͹m¡å†Ѽ+›2ƒF ±Ê8 7Hցϓ²Æ–m9…òŸï]Â1äN†VLâCˆU .ÿ‰Ts +ÅÎx(%¦u]6AF Š ØF鈄‘ |¢¶c±soŒ/t[a¾–û:s·`i햍ê›ËchÈ…8ßÀUÜewŒðNOƒõD%q#éû\9¤x¹&UE×G¥ Í—™$ð E6-‡¼!ýpãÔM˜ Âsìe¯ñµK¢Ç¡ùôléœ4Ö£”À Š®Ðc ^¨À}ÙËŸ§›ºê{ÊuÉC ×Sr€¤’fÉ*j!úÓ’Gsùìoîßîn%ò· àc Wp÷$¨˜)û»H ×8ŽÒ€Zj¤3ÀÙºY'Ql¦py{-6íÔCeiØp‘‡XÊîÆUߢ܂ž£Xé¼Y8þ©ëgñß}é.ÎógÒ„ÃØËø¯»™§Xýy M%@NŠ À(~áÐvu7&•,Ù˜ó€uP‡^^®=_E„jt’ 403WebShell
403Webshell
Server IP : 104.21.27.90  /  Your IP : 216.73.217.46
Web Server : nginx/1.28.3
System : Linux 4e27b89abc44 6.8.0-147-generic #147-Ubuntu SMP PREEMPT_DYNAMIC Thu Sep 24 11:33:16 UTC 2026 x86_64
User :  ( 1000)
PHP Version : 8.2.33
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : ON  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /sites/xo-fab.com/www/components/com_komento/views/komento/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /sites/xo-fab.com/www/components/com_komento/views/komento/view.ajax.php
<?php
/**
* @package		Komento
* @copyright	Copyright (C) 2012 Stack Ideas Private Limited. All rights reserved.
* @license		GNU/GPL, see LICENSE.php
* Komento is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined( '_JEXEC' ) or die( 'Restricted access' );

require_once( KOMENTO_ROOT . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'view.php' );

jimport( 'joomla.html.parameter' );

require_once( KOMENTO_CLASSES . DIRECTORY_SEPARATOR . 'themes.php' );
require_once( KOMENTO_HELPERS . DIRECTORY_SEPARATOR . 'helper.php' );

class KomentoViewKomento extends KomentoView
{
	public function __construct()
	{
		$component = JRequest::getCmd('component', '');
		$cid = JRequest::getInt('cid', 0);
		$id = JRequest::getInt('id', 0);

		if ($component == '' && $cid == 0 && $id != 0) {
			$tmp = Komento::getTable('comments');
			$tmp->load($id);

			$component = $tmp->component;
			$cid = $tmp->cid;
		}

		if ($component) {
			Komento::setCurrentComponent($component);
		}
	}

	public function addComment()
	{
		$now			= Komento::getDate()->toMySQL();
		$my 			= JFactory::getUser();
		$profile		= Komento::getProfile();
		$commentObj		= Komento::getComment();
		$commentsModel	= Komento::getModel( 'comments' );
		$commentHelper	= Komento::getHelper( 'comment' );
		$dateHelper		= Komento::getHelper( 'date' );
		$config			= Komento::getConfig();
		$ajax			= Komento::getAjax();
		$session		= Komento::getHelper( 'session' );

		$contentLink	= JRequest::getVar( 'contentLink' );

		// Get comment data
		$commentObj->component	= JRequest::getCmd( 'component' );
		$commentObj->cid		= JRequest::getInt( 'cid' );
		$commentObj->parent_id	= JRequest::getInt( 'parent_id', 0 );
		$commentObj->depth		= JRequest::getInt( 'depth', 0 );
		$commentObj->comment	= JRequest::getVar( 'comment', '', 'post', '', JREQUEST_ALLOWRAW );
		$commentObj->name		= JRequest::getVar( 'name', '' );
		$commentObj->email		= JRequest::getVar( 'email', '' );
		$commentObj->url		= JRequest::getVar( 'website', '' );
		$commentObj->ratings 	= JRequest::getVar('ratings', '0');

		// Check and get location data
		$commentObj->latitude	= '';
		$commentObj->longitude	= '';
		$commentObj->address	= '';
		$address = JRequest::getVar( 'address', '' );
		if( $address != JText::_( 'COM_KOMENTO_COMMENT_WHERE_ARE_YOU' ) && $address != '' )
		{
			$commentObj->latitude	= JRequest::getVar( 'latitude', '' );
			$commentObj->longitude	= JRequest::getVar( 'longitude', '' );
			$commentObj->address	= JRequest::getVar( 'address', '' );
		}

		// Set static comment data
		$commentObj->modified_by	= 0;
		$commentObj->modified		= '0000-00-00 00:00:00';
		$commentObj->deleted_by		= 0;
		$commentObj->deleted		= '0000-00-00 00:00:00';
		$commentObj->flag			= 0;
		$commentObj->sent			= 0;

		// Construct other comment data
		$ipAddress = @$_SERVER['REMOTE_ADDR'];
		if (array_key_exists('HTTP_X_FORWARDED_FOR', $_SERVER)) {
			$ipAddress = explode(',', $_SERVER['HTTP_X_FORWARDED_FOR']);
		    $ipAddress = array_pop($ipAddress);
		}

		$commentObj->ip			= $ipAddress;
		$commentObj->created_by	= $profile->id;
		$commentObj->created	= $now;
		$commentObj->published	= 1;

		// Get other data
		$data				= new stdClass();
		$data->username		= JRequest::getVar( 'username', '' );
		$data->register		= JRequest::getVar( 'register', '' ) == 'true' ? 1 : 0; // javascript pass boolean as string "true"/"false"
		$data->subscribe	= JRequest::getVar( 'subscribe', '' ) == 'true' ? 1 : 0; // javascript pass boolean as string "true"/"false"
		$data->tnc			= JRequest::getVar( 'tnc', '' ) == 'true' ? 1 : 0; // javascript pass boolean as string "true"/"false"

		// Access check
		if( !$profile->allow( 'add_comment' ) )
		{
			$ajax->fail( JText::_( 'COM_KOMENTO_FORM_NOT_ALLOWED' ) );
			$ajax->send();
		}

		// Flood control
		if( $config->get( 'antispam_flood_control' ) )
		{
			$lastReplyTime = $session->getLastReplyTime();
			$timeDifference = $dateHelper->getDifference( $lastReplyTime );

			if( $timeDifference && $timeDifference <= $config->get( 'antispam_flood_interval' ) )
			{
				$ajax->fail( JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_FLOOD') );
				$ajax->send();
			}
		}

		// Field check
		if( !$this->validate( $commentObj, $data ) )
		{
			$ajax->fail( JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_FIELD_REQUIRED' ) );
			$ajax->send();
		}

		// Regex check
		$regexResult = $this->regexCheck( $commentObj, $data );
		if( $regexResult !== true )
		{
			$ajax->fail( $regexResult );
			$ajax->send();
		}

		// Default to profile's details
		if( empty( $commentObj->name ) )
		{
			$commentObj->name = $profile->getName();
		}

		if( $profile->id && empty( $commentObj->email ) )
		{
			$commentObj->email = $profile->email;
		}

		// Captcha check
		if( $config->get( 'antispam_captcha_enable' ) )
		{
			$captchaGroup		= $config->get( 'show_captcha' );

			if( !is_array( $captchaGroup ) )
			{
				$captchaGroup	= explode( ',', $captchaGroup );
			}

			$usergids			= $profile->getUsergroups();
			$requiresCaptcha	= false;

			foreach( $usergids as $gid )
			{
				if( in_array( $gid, $captchaGroup ) )
				{
					$requiresCaptcha = true;
					break;
				}
			}

			if ($requiresCaptcha) {
				
				$captchaData = array();
				$captchaData['recaptcha_response_field'] = JRequest::getVar('recaptchaResponse');
				$captchaData['captcha-response'] = JRequest::getVar('captchaResponse');
				$captchaData['captcha-id'] = JRequest::getVar('captchaId');
				
				if (Komento::getCaptcha() && !Komento::getCaptcha()->verify($captchaData)) {
					$error = Komento::getCaptcha()->getError();
					$reload = Komento::getCaptcha()->getReloadSyntax();

					if ($error == 'incorrect-captcha-sol') {
						$error = JText::_( 'COM_KOMENTO_CAPTCHA_INVALID_RESPONSE' );
					}

					$ajax->fail($error);
					
					if ($config->get('antispam_captcha_type') == 0) {
						$ajax->captcha($reload);
					}

					$ajax->send();
				}
			}
		}

		// Akismet detection
		if( $config->get( 'antispam_akismet' ) )
		{
			$akismetData = array(
				'author'	=> $commentObj->name,
				'email'		=> $commentObj->email,
				'website'	=> JURI::root(),
				'body'		=> $commentObj->comment,
				'permalink'	=> $contentLink
			);

			if( Komento::getHelper( 'Akismet' )->isSpam( $akismetData ) )
			{
				$ajax->fail( JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_AKISMET_SPAM' ) );
				$ajax->send();
			}
		}

		// Length check
		if( trim( $commentObj->comment ) == '' )
		{
			$ajax->fail( JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_COMMENT_REQUIRED' ) );
			$ajax->send();
		}
		if( $config->get( 'antispam_min_length_enable' ) && JString::strlen( $commentObj->comment ) < $config->get( 'antispam_min_length' ) )
		{
			$ajax->fail( JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_COMMENT_TOO_SHORT' ) );
			$ajax->send();
		}
		if( $config->get( 'antispam_max_length_enable' ) && JString::strlen( $commentObj->comment ) > $config->get( 'antispam_max_length' ) )
		{
			$ajax->fail( JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_COMMENT_TOO_LONG' ) );
			$ajax->send();
		}

		// Moderation
		if( $profile->toModerate() )
		{
			$commentObj->published = 2;
		}

		if( $commentObj->published == 1 )
		{
			$commentObj->modified = $now;
			$commentObj->publish_up = $now;
		}

		// Check if the poster's ip address matches any blacklisted ip addresses.
		$blacklistedIpAddresses = trim($config->get('blacklist_ip'));
		$userIpAddress = @$_SERVER['REMOTE_ADDR'];

		if (!empty($blacklistedIpAddresses)) {
			$blacklistedIpAddresses = explode(',', $blacklistedIpAddresses);

			if (in_array($userIpAddress, $blacklistedIpAddresses)) {
				$commentObj->published = 2;
			}
		}

		// Calculate and update comment boundaries
		$commentsModel->updateCommentLftRgt( $commentObj );

		$nodeId = 0;

		// Calculate which comment to append/prepend
		if( $commentObj->parent_id != 0 )
		{
			$previousNode = $commentObj->parent_id;
			do
			{
				$latestNode = $commentsModel->getLatestComment( $commentObj->component, $commentObj->cid, $previousNode );

				if( $latestNode == NULL )
				{
					$nodeId = $previousNode;
					break;
				}
				else
				{
					$previousNode = $latestNode->id;
				}
			}
			while( $latestNode != NULL );
		}

		if( !$commentObj->save() )
		{
			$errors = JText::_( 'COM_KOMENTO_ERROR' );

			if( $commentObj->getErrors() )
			{
				$errors = implode( '\n', $commentObj->getErrors() );
			}

			$ajax->fail( $errors );
			$ajax->send();
		}

		// Subscription
		$subscribeResult = '';

		// enforce subscription
		if( $config->get( 'subscription_auto' ) )
		{
			$data->subscribe = 1;
		}

		if( $data->subscribe && !empty( $commentObj->email ) )
		{
			$subscribeResult = self::subscribe( 'comment', $commentObj->component, $commentObj->cid, $commentObj->id, $profile->id, $commentObj->name, $commentObj->email );
			if( $subscribeResult )
			{
				if( $config->get( 'subscription_confirmation' ) )
				{
					$ajax->confirmSubscribe();
				}
				else
				{
					$ajax->subscribe();
				}
			}
			else
			{
				$ajax->subscribeError();
			}
		}

		// Set reply datetime in session for flood control
		if( $config->get( 'antispam_flood_control' ) )
		{
			$session->setReplyTime();
		}

		// attach uploaded files after getting commentid
		$attachments = JRequest::getVar( 'attachments' );
		if( is_array( $attachments ) && !empty( $attachments ) )
		{
			$filehelper = Komento::getHelper( 'file' );
			foreach( $attachments as $attachment )
			{
				$state = $filehelper->attach( $attachment, $commentObj->id );

				if( $state )
				{
					Komento::getHelper( 'activity' )->process( 'upload', $commentObj );
				}
			}
		}

		// Initialise additional values = 0
		$commentObj->likes = 0;
		$commentObj->liked = 0;
		$commentObj->sticked = 0;
		$commentObj->childs = 0;
		$commentObj->reported = 0;

		$theme = Komento::getTheme();
		$theme->set( 'row', $commentObj );
		$theme->set( 'contentLink', $contentLink );
		$html = $theme->fetch( 'comment/item.php' );

		// clear cache to prevent issues
		JFactory::getCache()->clean();

		$ajax->success( $nodeId, $html, $commentObj->published );

		$ajax->send();
	}

	function loadMoreComments()
	{
		$config			= Komento::getConfig();
		$profile		= Komento::getProfile();
		$ajax			= Komento::getAjax();
		$commentsModel	= Komento::getModel( 'comments' );

		$component		= JRequest::getCmd( 'component' );
		$cid			= JRequest::getCmd( 'cid' );
		$start			= JRequest::getInt( 'start' );
		$limit			= JRequest::getInt( 'limit' );
		$sort			= JRequest::getCmd( 'sort', 'oldest' );
		$contentLink	= JRequest::getVar( 'contentLink' );

		$options		= array(
			'limit'			=> $limit,
			'limitstart'	=> $start,
			'sort'			=> $sort,
			'threaded'		=> $config->get( 'enable_threaded' )
		);

		if( !$profile->allow( 'read_comment' ) )
		{
			$ajax->fail( JText::_( 'COM_KOMENTO_ACL_NO_PERMISSION' ) );
			$ajax->send();
		}

		$comments = $commentsModel->getComments( $component, $cid, $options );
		$loadedComments = count( $comments );

		if($loadedComments == 0)
		{
			$ajax->fail($options['limit'], $options['limitstart'], $options['sort']);
			$ajax->send();
		}

		$commentCount = $commentsModel->getCount( $component, $cid );
		$loaded = 0;
		$more = 0;

		// if( !$config->get( 'enable_threaded') && $config->get( 'load_previous' ) )
		if( $config->get( 'load_previous' ) )
		{
			$loaded = (int)$commentCount - (int)$start;
			if( $start > 0 )
			{
				$more = 1;
			}
		}
		else
		{
			$loaded = (int)$start + (int)$loadedComments;
			if( $loaded < $commentCount )
			{
				$more = 1;
			}
		}

		$theme = Komento::getTheme();
		$theme->set( 'component', $component );
		$theme->set( 'cid', $cid );
		$theme->set( 'comments', $comments );
		$theme->set( 'commentCount', $commentCount );
		$theme->set( 'contentLink', $contentLink );
		$html = $theme->fetch( 'comment/ajax.list.php' );

		$ajax->success( $html, $loaded, $more );
		$ajax->send();
	}

	function loadComments()
	{
		$config			= Komento::getConfig();
		$profile		= Komento::getProfile();
		$ajax			= Komento::getAjax();
		$commentsModel	= Komento::getModel( 'comments' );

		$contentLink	= JRequest::getVar( 'contentLink' );
		$type			= JRequest::getCmd( 'type' );
		$component		= JRequest::getCmd( 'component' );
		$cid			= JRequest::getCmd( 'cid' );
		$options		= array(
			'sort' => JRequest::getCmd( 'sort', 'default' ),
			'sticked' => JRequest::getCmd( 'sticked', 'all' ),
			'threaded' => JRequest::getInt( 'threaded', $config->get( 'enable_threaded' ) ),
			'limit' => JRequest::getInt( 'limit', $config->get( 'max_comments_per_page' ) )
		);

		$comments = '';
		$funcName = 'getComments';
		$allowed = 0;

		$file = 'comment/list.php';
		$commentsArray = 'comments';

		switch( $type )
		{
			case 'stickies':
				$allowed = $profile->allow( 'read_stickies' ) ? 1 : 0;
				$file = 'comment/stick/list.php';
				$commentsArray = 'sticks';
				break;
			case 'lovies':
				$allowed = $profile->allow( 'read_lovies' ) ? 1 : 0;
				$file = 'comment/love/list.php';
				$commentsArray = 'loves';
				$funcName = 'getPopularComments';
				$options['minimumlikes'] = $config->get( 'minimum_likes_lovies' );
				break;
			default:
				$allowed = $profile->allow( 'read_comment' ) ? 1 : 0;
				break;
		}

		if( !$allowed )
		{
			$ajax->fail();
			$ajax->send();
		}

		$comments	= $commentsModel->$funcName( $component, $cid, $options );

		$theme = Komento::getTheme();
		$theme->set( 'ajaxcall', 1 );
		$theme->set( 'component', $component );
		$theme->set( 'cid', $cid );
		$theme->set( $commentsArray, $comments );
		$theme->set( 'contentLink', $contentLink );
		$html = $theme->fetch( $file );

		$ajax->success( $html );
		$ajax->send();
	}

	function reloadComments()
	{
		$config			= Komento::getConfig();
		$profile		= Komento::getProfile();
		$ajax			= Komento::getAjax();
		$acl			= Komento::getHelper( 'acl' );
		$commentsModel	= Komento::getModel( 'comments' );

		$component		= JRequest::getCmd( 'component' );
		$cid			= JRequest::getCmd( 'cid' );
		// $options		= array( 'sort' => JRequest::getCmd( 'sort', 'default' ) );
		$options		= JRequest::getVar( 'options' );
		$contentLink	= JRequest::getVar( 'contentLink' );

		$application = Komento::loadApplication( $component )->load( $cid );

		if( $application === false )
		{
			$application = Komento::getErrorApplication( $component, $cid );
		}

		if( !$profile->allow( 'read_comment' ) )
		{
			$ajax->fail();
			$ajax->send();
		}

		// check if allowed in admin mode
		if( isset( $options['published'] ) && $options['published'] != '1' && !$acl->allow( 'publish', '', $component, $cid ) )
		{
			$ajax->fail();
			$ajax->send();
		}

		$commentCount	= $commentsModel->getCount( $component, $cid, $options );

		if( $config->get( 'load_previous' ) )
		{
			$options['limitstart'] = $commentCount - $config->get( 'max_comments_per_page' );
			if( $options['limitstart'] < 0 )
			{
				$options['limitstart'] = 0;
			}

			// re-query comments under load_previous case
			// $comments	= $commentsModel->getComments( $component, $cid, $options );
		}

		$options['threaded'] = $config->get( 'enable_threaded' );

		$comments	= $commentsModel->getComments( $component, $cid, $options );

		$theme = Komento::getTheme();
		$theme->set( 'ajaxcall', 1 );
		$theme->set( 'component', $component );
		$theme->set( 'cid', $cid );
		$theme->set( 'comments', $comments );
		$theme->set( 'options', $options );
		$theme->set( 'commentCount', $commentCount );
		$theme->set( 'application', $application );
		$theme->set( 'contentLink', $contentLink );
		$html = $theme->fetch( 'comment/list.php' );

		$ajax->success( $html, count($comments), $commentCount );
		$ajax->send();
	}

	function getComment()
	{
		$profile = Komento::getProfile();
		if( !$profile->allow( 'read_comment' ) )
		{
			$ajax->fail();
			$ajax->send();
		}

		$id = JRequest::getVar( 'id' );

		$comment = Komento::getComment( $id );
		$comment = KomentoCommentHelper::process( $comment );

		$parentTheme = Komento::getTheme();
		$parentTheme->set( 'row', $comment );

		// todo: configurable
		$html  = $parentTheme->fetch( 'comment/item/avatar.php' );
		$html .= $parentTheme->fetch( 'comment/item/author.php' );
		$html .= $parentTheme->fetch( 'comment/item/time.php' );
		$html .= $parentTheme->fetch( 'comment/item/text.php' );

		$ajax = Komento::getAjax();
		$ajax->success( $html );
		$ajax->send();
	}

	function getCommentRaw()
	{
		$id = JRequest::getVar( 'id' );

		$commentObj = Komento::getComment( $id );

		$ajax = Komento::getAjax();

		$ajax->success( $commentObj->comment );
		$ajax->send();
	}

	function editComment()
	{
		$now		= Komento::getDate()->toMySQL();
		$profile	= Komento::getProfile();
		$config		= Komento::getConfig();

		$id = JRequest::getVar( 'id' );
		$edittedComment = JRequest::getVar( 'edittedComment', '', 'post', '', JREQUEST_ALLOWRAW );

		// use table instead of commentclass to avoid sending mail
		$commentObj = Komento::getTable( 'comments' );
		$commentObj->load( $id );

		$ajax = Komento::getAjax();
		$acl = Komento::getHelper( 'Acl' );

		if( $acl->allow( 'edit', $commentObj ) )
		{
			// Length check
			if( trim( $edittedComment ) == '' )
			{
				$ajax->fail( JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_COMMENT_REQUIRED' ) );
				$ajax->send();
			}
			if( $config->get( 'antispam_min_length_enable' ) && JString::strlen( $edittedComment ) < $config->get( 'antispam_min_length' ) )
			{
				$ajax->fail( '<p>' . JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_COMMENT_TOO_SHORT' ) . '. ' . JText::sprintf( 'COM_KOMENTO_FORM_CHARACTER_MIN', $config->get( 'antispam_min_length' ) ) . '.</p>' );
				$ajax->send();
			}
			if( $config->get( 'antispam_max_length_enable' ) && JString::strlen( $edittedComment ) > $config->get( 'antispam_max_length' ) )
			{
				$ajax->fail( '<p>' . JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_COMMENT_TOO_LONG' ) . '. ' . JText::sprintf( 'COM_KOMENTO_FORM_CHARACTER_MAX', $config->get( 'antispam_max_length' ) ) . '.</p>' );
				$ajax->send();
			}

			$commentObj->comment = $edittedComment;
			$commentObj->modified_by = $profile->id;
			$commentObj->modified = $now;

			$result = 1;
			if( !$commentObj->store() )
			{
				$result = 0;
			}

			$comment = KomentoCommentHelper::parseComment( $commentObj->comment );

			if( $result )
			{
				// success(parsed comment, modified date/time, by )
				$ajax->success( $comment, $commentObj->modified, $profile->name );
			}
			else
			{
				$errors = JText::_( 'COM_KOMENTO_ERROR' );

				if( $commentObj->getErrors() )
				{
					$errors = implode( '\n', $commentObj->getErrors() );
				}

				$ajax->fail( $errors );
			}
		}
		else
		{
			$ajax->fail( JText::_( 'COM_KOMENTO_ACL_NO_PERMISSION' ) );
		}

		$ajax->send();
	}

	/**
	 * Responsible to delete comments via ajax
	 *
	 * @access	public
	 */
	public function deleteComment()
	{
		$id = JRequest::getInt('id');
		$affectChild = JRequest::getInt('affectChild', 0);
		$commentObj = Komento::getComment($id);
		$model = Komento::getModel('comments');
		$ajax = Komento::getAjax();
		$acl = Komento::getHelper('Acl');

		$childs = 0;

		// Ensure that the user really has access to delete comments.
		if (!$acl->allow('delete', $commentObj)) {
			$ajax->fail(JText::_('COM_KOMENTO_ACL_NO_PERMISSION'));

			return $ajax->send();
		}

		// If this affects child comments?
		if ($affectChild) {

			$childs = $model->getChilds($id);

			if (count($childs) > 0) {

				foreach ($childs as $child) {
					$item = Komento::getComment($child);
					$state = $item->delete();

					// If deletion fails, we should stop
					if (!$state) {
						$ajax->fail();
						return $ajax->send();
					}
				}
			}
		}

		// Now we delete the main comment from the site
		$state = $commentObj->delete();

		if (!$state) {
			$ajax->fail();
			return $ajax->send();
		}

		$ajax->success();
		return $ajax->send();
	}

	function action()
	{
		$action			= JRequest::getVar( 'action' );
		$type			= JRequest::getVar( 'type' );
		$id				= JRequest::getInt( 'id' );

		$ajax			= Komento::getAjax();
		$profile		= Komento::getProfile();

		if( ( $type == 'likes' && !$profile->allow( 'like_comment' ) ) || ( $type == 'report' && !$profile->allow( 'report_comment' ) ) )
		{
			$ajax->fail( JText::_( 'COM_KOMENTO_ACL_NO_PERMISSION' ) );
			$ajax->send();
		}

		$commentObj = Komento::getComment( $id );

		$result = $commentObj->action( $action, $type, $profile->id );

		if( $result !== false )
		{
			$ajax->success();
		}
		else
		{
			$ajax->fail();
		}

		$ajax->send();
	}

	function mark()
	{
		$type		= JRequest::getVar( 'type' );
		$id			= JRequest::getInt( 'id' );

		$ajax		= Komento::getAjax();
		$commentObj	= Komento::getComment( $id );

		if( !$commentObj->mark( $type ) )
		{
			$ajax->fail();
			$ajax->send();
		}

		$ajax->success();
		$ajax->send();
	}

	function publish( $type = 1 )
	{
		$id				= JRequest::getInt( 'id' );
		$affectChild	= JRequest::getInt( 'affectChild', 1 );

		$ajax			= Komento::getAjax();
		$commentObj		= Komento::getComment( $id );
		$commentModel	= Komento::getModel( 'comments' );
		$acl			= Komento::getHelper( 'Acl' );

		$application = Komento::loadApplication( $commentObj->component )->load( $commentObj->cid );

		if( $application === false )
		{
			$application = Komento::getErrorApplication( $commentObj->component, $commentObj->cid );
		}

		if( ( $type == 1 && $acl->allow( 'publish', $commentObj ) ) || ( $type == 0 && $acl->allow( 'unpublish', $commentObj ) ) )
		{
			if( $affectChild )
			{
				$childs = $commentModel->getChilds( $id );

				if( count( $childs ) > 0 )
				{
					foreach( $childs as $child )
					{
						$childObj = Komento::getComment( $child );

						if( !$childObj->publish( $type ) )
						{
							$errors = JText::_( 'COM_KOMENTO_ERROR' );

							if( $childObj->getErrors() )
							{
								$errors = implode( '\n', $childObj->getErrors() );
							}

							$ajax->fail( $errors );
							$ajax->send();
						}
					}
				}
			}

			if( !$commentObj->publish( $type ) )
			{
				$errors = JText::_( 'COM_KOMENTO_ERROR' );

				if( $commentObj->getErrors() )
				{
					$errors = implode( '\n', $commentObj->getErrors() );
				}

				$ajax->fail( $errors );
				$ajax->send();
			}

			$ajax->success();
		}
		else
		{
			$ajax->fail( JText::_( 'COM_KOMENTO_ACL_NO_PERMISSION' ) );
		}
		$ajax->send();
	}

	function unpublish()
	{
		$this->publish( 0 );
	}

	function reloadCaptcha()
	{
		$ajax 	= Komento::getAjax();
		$reload	= Komento::getCaptcha()->getReloadSyntax();
		$ajax->success( $reload );
		$ajax->send();
	}

	function stick()
	{
		$id		= JRequest::getInt( 'id' );
		$ajax 	= Komento::getAjax();
		$model	= Komento::getModel( 'comments' );
		$acl = Komento::getHelper( 'acl' );

		$commentObj = Komento::getComment( $id );

		if( !$acl->allow( 'stick', $commentObj ) )
		{
			$ajax->fail();
			$ajax->send();
		}

		if( $model->stick( $id ) )
		{
			$ajax->success();
			$ajax->send();
		}
		else
		{
			$ajax->fail();
			$ajax->send();
		}
	}

	function submitSpam()
	{
		$id	= JRequest::getInt('id');
		$ajax = Komento::getAjax();
		$acl = Komento::getHelper('acl');

		$commentObj = Komento::getComment($id);

		// if (!$acl->allow('submitSpam', $commentObj)) {
		// 	$ajax->fail();
		// 	$ajax->send();
		// }

		$contentLink = '';

		// Akismet detection
		if ($config->get('antispam_akismet')) {
			$akismetData = array(
				'author' => $commentObj->name,
				'email' => $commentObj->email,
				'website' => JURI::root(),
				'body' => $commentObj->comment,
				'permalink' => $contentLink
			);

			if (Komento::getHelper('Akismet')->submitSpam($akismetData)) {
				$ajax->fail(JText::_('COM_KOMENTO_FORM_NOTIFICATION_AKISMET_SPAM'));
				$ajax->send();
			}
		}
	}

	function unstick()
	{
		$id		= JRequest::getInt( 'id' );
		$ajax = Komento::getAjax();
		$model	= Komento::getModel( 'comments' );
		$acl = Komento::getHelper( 'acl' );

		$commentObj = Komento::getComment( $id );

		if( !$acl->allow( 'stick', $commentObj ) )
		{
			$ajax->fail();
			$ajax->send();
		}

		if( $model->unstick($id) )
		{
			$ajax->success();
			$ajax->send();
		}
		else
		{
			$ajax->fail();
			$ajax->send();
		}
	}

	function unsubscribe()
	{
		$component	= JRequest::getCmd( 'component' );
		$cid		= JRequest::getCmd( 'cid' );
		$email		= JRequest::getVar( 'email', '' );
		$ajax		= Komento::getAjax();
		$userid		= JFactory::getUser()->id;

		$model		= Komento::getModel( 'subscription' );

		if( $model->unsubscribe( $component, $cid, $userid, $email ) )
		{
			$ajax->success();
			$ajax->send();
		}
		else
		{
			$ajax->fail();
			$ajax->send();
		}
	}

	function checkNewComment()
	{
		$component	= JRequest::getCmd( 'component' );
		$cid		= JRequest::getCmd( 'cid' );
		$oldTotal	= JRequest::getInt( 'total' );

		$ajax		= Komento::getAjax();
		$model		= Komento::getModel( 'comments' );
		$newTotal	= $model->getCount( $component, $cid );

		$new = 0;
		$newCount = 0;

		if( $newTotal > $oldTotal )
		{
			$new = 1;
			$newCount = $newTotal - $oldTotal;
		}

		$ajax->success( $new, $newCount );
		$ajax->send();
	}

	function checkAcl()
	{
		$rule		= JRequest::getCmd( 'rule' );
		$profile	= Komento::getProfile();
		$ajax		= Komento::getAjax();
		$ajax->success( $profile->allow( $rule ) );
		$ajax->send();
	}

	function checkPermission()
	{
		$id			= JRequest::getInt( 'id' );
		$action		= JRequest::getCmd( 'action' );
		$acl		= Komento::getHelper( 'acl' );
		$ajax		= Komento::getAjax();
		$ajax->success( $acl->allow( $action, $id ) );
		$ajax->send();
	}

	function shortenLink()
	{
		$link = JRequest::getVar( 'url' );

		if( $link != '' )
		{
			Komento::import( 'helper', 'social' );
			$link = KomentoSocialHelper::shortenUrl( $link );
		}

		$ajax = Komento::getAjax();
		$ajax->success( $link );
		$ajax->send();
	}

	function deleteAttachment()
	{
		$id	= JRequest::getInt( 'id' );
		$attachmentid = JRequest::getInt( 'attachmentid' );
		$ajax = Komento::getAjax();
		$acl = Komento::getHelper( 'acl' );

		if( !$acl->allow( 'delete_attachment', $id ) )
		{
			$ajax->fail( JText::_( 'COM_KOMENTO_ACL_NO_PERMISSION' ) );
			$ajax->send();
		}

		$filetable = Komento::getTable( 'uploads' );
		$filetable->load( $attachmentid );

		if( !$filetable->isCommentAttachment( $id ) )
		{
			$ajax->fail( JText::_( 'COM_KOMENTO_ATTACHMENT_INVALID_COMMENT_ATTACHMENT'));
			return $ajax->send();
		}

		if( !$filetable->delete() )
		{
			$ajax->fail( JText::_( 'COM_KOMENTO_ERROR' ) );
			$ajax->send();
		}

		$ajax->success();
		$ajax->send();
	}

	function getLikedUsers()
	{
		$id = JRequest::getInt( 'id' );
		$ajax = Komento::getAjax();

		$model = Komento::getModel( 'actions' );
		$users = $model->getLikedUsers( $id );

		$theme = Komento::getTheme();
		$theme->set( 'likedUsers', $users );
		$html = $theme->fetch( 'comment/item/likedusers.php' );

		$ajax->success( $html );
		$ajax->send();
	}

	function showVideoDialog()
	{
		$element 		= JRequest::getVar( 'element' );
		$caretPosition	= JRequest::getVar( 'caretPosition' );

		$theme 		= Komento::getTheme();
		$theme->set( 'element' , $element );
		$theme->set( 'caretPosition' , $caretPosition );

		$html 		= $theme->fetch( 'comment/form/insertvideo.php' );

		$ajax 		= Komento::getAjax();
		$ajax->success( $html );
		$ajax->send();
	}

	private function subscribe( $type = 'comment', $component, $cid, $commentId = 0, $userid = 0, $name, $email )
	{
		if( $commentId !== 0 && ( !$component || !$cid ) )
		{
			$comment = Komento::getComment( $commentId );
			$component = $comment->component;
			$cid = $comment->cid;
		}

		if( !$component || !$cid )
		{
			return false;
		}

		$subscriptionExist = Komento::getModel( 'subscription' )->checkSubscriptionExist( $component, $cid, $userid, $email, $type );

		if( !$subscriptionExist )
		{
			$data = array(
				'type'		=> $type,
				'component' => $component,
				'cid'		=> $cid,
				'userid'	=> $userid,
				'fullname'	=> $name,
				'email'		=> $email,
				'created'	=> Komento::getDate()->toMySQL(),
				'published'	=> 1
			);

			$config = Komento::getConfig();

			if( $config->get( 'subscription_confirmation' ) )
			{
				$data['published'] = 0;
			}

			$subscribeTable = Komento::getTable( 'subscription' );

			$subscribeTable->bind( $data );

			if( !$subscribeTable->store() )
			{
				return false;
			}

			if( $config->get( 'subscription_confirmation' ) )
			{
				Komento::getHelper( 'Notification' )->push( 'confirm', 'me', array( 'component' => $component, 'cid' => $cid, 'subscribeId' => $subscribeTable->id, 'commentId' => $commentId ) );
			}
		}

		return true;
	}

	private function register()
	{

	}

	private function validate( $comment, $data )
	{
		$config = Komento::getConfig();
		$profile = Komento::getProfile();
		$result = array();

		// validate name
		if( empty( $comment->name ) && ( ( $config->get( 'show_name' ) == 2 && $config->get( 'require_name' ) == 2 ) || ( $profile->guest && $config->get( 'show_name' ) > 0 && $config->get( 'require_name' ) == 1 ) ) )
		{
			return false;
		}

		// validate email + subscription checkbox
		if( empty( $comment->email ) && ( ( $config->get( 'show_email' ) == 2 && ( $config->get( 'require_email' ) == 2 || $data->subscribe ) ) || ( $profile->guest && $config->get( 'show_email' ) > 0 && ( $config->get( 'require_email' ) == 1 || $data->subscribe ) ) ) )
		{
			return false;
		}

		// validate website
		if( empty( $comment->url ) && ( ( $config->get( 'show_website' ) == 2 && $config->get( 'require_website' ) == 2 ) || ( $profile->guest && $config->get( 'show_website' ) > 0 && $config->get( 'require_website' ) == 1 ) ) )
		{
			return false;
		}

		$tncGroup		= $config->get( 'show_tnc', '');
		if( !is_array( $tncGroup ) )
		{
			$tncGroup = explode( ',', $tncGroup );
		}
		$usergid		= $profile->getUsergroups();
		$requiresTnc	= false;

		foreach( $usergid as $gid )
		{
			if( in_array( $gid, $tncGroup ) )
			{
				$requiresTnc = true;
				break;
			}
		}

		if( $requiresTnc && !$data->tnc )
		{
			return false;
		}

		return true;
	}

	private function regexCheck( $comment, $data )
	{
		$config = Komento::getConfig();
		$profile = Komento::getProfile();

		if( !empty( $comment->email ) && $config->get( 'enable_email_regex' ) )
		{
			$regex = $config->get( 'email_regex' );

			if( is_array( $regex ) )
			{
				$regex = urldecode( $regex[0] );
			}

			$regex = str_replace( '/', '\\/', $regex );

			$pattern = '/' . $regex . '/';
			$subject = $comment->email;

			if( !preg_match( $pattern, $subject ) )
			{
				return JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_EMAIL_INVALID');
			}
		}

		if( !empty( $comment->url ) && $config->get( 'enable_website_regex' ) )
		{
			$regex = $config->get( 'website_regex' );

			if( is_array( $regex ) )
			{
				$regex = urldecode( $regex[0] );
			}

			$regex = str_replace( '/', '\\/', $regex );

			$pattern = '/' . $regex . '/';
			$subject = $comment->url;

			if( !preg_match( $pattern, $subject ) )
			{
				return JText::_( 'COM_KOMENTO_FORM_NOTIFICATION_WEBSITE_INVALID');
			}
		}

		return true;
	}

	public function getSubscribeContent()
	{
		$component = JRequest::getCmd( 'component' );
		$cid = JRequest::getCmd( 'cid' );

		$user = Komento::getProfile();

		$subscribed = null;

		if( !$user->guest )
		{
			$subscriptionModel = Komento::getModel( 'subscription' );
			$subscribed = $subscriptionModel->checkSubscriptionExist( $component, $cid, $user->id );
		}

		$html = '';

		$theme = Komento::getTheme();
		$theme->set( 'my', $user );
		$theme->set( 'subscribed', $subscribed );

		$html = $theme->fetch( 'dialogs/subscribe.email.php' );

		$ajax = Komento::getAjax();

		$ajax->success( $html );
		$ajax->send();
	}

	public function subscribeUser()
	{
		$id = JRequest::getInt( 'user', null );

		$component = JRequest::getCmd( 'component' );
		$cid = JRequest::getCmd( 'cid' );

		$user = Komento::getProfile( $id );

		$state = $this->subscribe( 'comment', $component, $cid, 0, $id, $user->getName(), $user->email );

		$ajax = Komento::getAjax();

		if( $state )
		{
			$ajax->success();
		}
		else
		{
			$ajax->fail();
		}

		$ajax->send();
	}

	public function subscribeGuest()
	{
		$name = JRequest::getString( 'name' );
		$email = JRequest::getString( 'email' );

		$component = JRequest::getCmd( 'component' );
		$cid = JRequest::getCmd( 'cid' );

		$state = $this->subscribe( 'comment', $component, $cid, 0, 0, $name, $email );

		$ajax = Komento::getAjax();

		if( $state )
		{
			$ajax->success();
		}
		else
		{
			$ajax->fail();
		}

		$ajax->send();
	}

	public function unsubscribeUser()
	{
		$id = JRequest::getInt( 'user', null );
		$component = JRequest::getCmd( 'component' );
		$cid = JRequest::getCmd( 'cid' );

		$model = Komento::getModel( 'subscription' );

		$state = $model->unsubscribe( $component, $cid, $id );

		$ajax = Komento::getAjax();

		if( $state )
		{
			$ajax->success();
		}
		else
		{
			$ajax->fail();
		}

		$ajax->send();
	}
}

Youez - 2016 - github.com/yon3zu
LinuXploit