forum.easy-joomla.org

Projects/Projekte => J! 1.0.x Serie - EasyCaptcha => Thema gestartet von: cybergurk am 01. 02. 2008 15:36



Titel: Workaround - EasyCaptcha auch für das Joomla Kontakt-Formular
Beitrag von: cybergurk am 01. 02. 2008 15:36
Workaround - EasyCaptcha auch für das Joomla Kontakt-Formular

Hierbei handelt es sich um ein Hack wie folgt:

Beachtet aber, das nach einem Update auf einer neueren Version dieser Hack verloren gehen kann. Backup nicht vergessen

Diese Hack ermöglicht es die Komponente EasyCaptcha  (http://joomlacode.org/gf/project/easyjoomla/frs/?action=FrsReleaseBrowse&frs_package_id=227) auch für das Joomla!-Kontakt-Formular der Joomla Version 1.0.15 zu benutzen.

Hinweis: Die beiden Dateien aus dem Anhang contact.php und contact.html.php ins Verzeichnis components/com_contact hochladen/überschreiben, aber bitte dann ein Backup dieser beiden Dateien nicht vergessen!

Solltet Ihr eurer Kontaktformular schon manuell bearbeitet haben dann könnt ihr es auch manuell also wie folgt ergänzen/ändern, da ansonsten alles überschrieben wird.


Manuell also wie folgt:

In der Datei contact.php

suche nach

Code

          
(php):

          
  1. defined( '_VALID_MOS' ) or die( 'Restricted access' );

darunter einfügen

Code

          
(php):

          
  1. //EasyCaptcha Integration - added by EasyJoomla.org Project
  2. if(file_exists($mosConfig_absolute_path.'/components/com_easycaptcha/class.easycaptcha.php')) {
  3. include_once($mosConfig_absolute_path.'/components/com_easycaptcha/class.easycaptcha.php');
  4. }

suche nach

Code

          
(php):

          
  1. HTML_contact::viewcontact( $contact, $params, $count, $list, $menu_params );

ersetzen durch

Code

          
(php):

          
  1. //EasyCaptcha Integration - added by EasyJoomla.org Project
  2. if( class_exists("EasyCaptcha") AND !$my->gid ) {
  3. $captcha = new easyCaptcha();
  4. }
  5. else
  6. {
  7. $captcha = null;
  8. }
  9.  
  10. HTML_contact::viewcontact( $contact, $params, $count, $list, $menu_params, &$captcha );

suche nach

Code

          
(php):

          
  1. global $mosConfig_sitename, $mosConfig_live_site, $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_db;

ersetze durch

Code

          
(php):

          
  1. global $mosConfig_sitename, $mosConfig_live_site, $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_db, $my;

suche nach

Code

          
(php):

          
  1. // check for session cookie

darüber einfügen

Code

          
(php):

          
  1. //EasyCaptcha Integration - added by EasyJoomla.org Project
  2. if(class_exists("EasyCaptcha") AND !$my->gid)
  3. {
  4. $captcha_id = strval( mosGetParam( $_POST, 'captcha_id', '' ) );
  5. $captcha_code = strval( mosGetParam( $_POST, 'captcha_code', '' ) );
  6. $captcha = new EasyCaptcha($captcha_id);
  7. if(!$captcha->checkEnteredCode($captcha_code))
  8. {
  9. mosErrorAlert( "Wrong Code entered" );
  10. }
  11. }


In der contact.html.php

suche nach

Code

          
(php):

          
  1. function viewcontact( &$contact, &$params, $count, &$list, &$menu_params ) {

ersetze durch

Code

          
(php):

          
  1. function viewcontact( &$contact, &$params, $count, &$list, &$menu_params, &$captcha ) {

suche nach

Code

          
(php):

          
  1. <script language="JavaScript" type="text/javascript">
  2. <!--

ersetze durch

Code

          
(php):

          
  1. <script type="text/javascript">
  2. <?php
  3. //EasyCaptcha Integration - added by EasyJoomla.org Project
  4. if($captcha->captcha_id)
  5. {
  6. ?>
  7. /*<[CDATA[*/
  8. function validate(){
  9. if ( ( document.emailForm.text.value == "" ) || ( document.emailForm.email.value.search("@") == -1 ) || ( document.emailForm.email.value.search("[.*]" ) == -1 ) ) {
  10. alert( "<?php echo addslashes( _CONTACT_FORM_NC ); ?>" );
  11. } else if ( ( document.emailForm.email.value.search(";") != -1 ) || ( document.emailForm.email.value.search(",") != -1 ) || ( document.emailForm.email.value.search(" ") != -1 ) ) {
  12. alert( "<?php echo addslashes( _CONTACT_ONE_EMAIL ); ?>" );
  13. } else {
  14. checkEasyCaptcha("contact_captcha");
  15. }
  16. }
  17. function submitMailForm(){
  18. if (http_request.readyState == 4) {
  19. if( http_request.responseText=="true") {
  20. document.emailForm.action = "<?php echo sefRelToAbs("index.php?option=com_contact&Itemid=$Itemid"); ?>"
  21. document.emailForm.submit();
  22. }
  23. else {
  24. alert( "<?php echo addslashes( "Please enter correct Code" ); ?>" );
  25. }
  26. }
  27. }
  28. /*]]>*/
  29. </script>
  30. <?php
  31. echo $captcha->getAjax("submitMailForm");
  32. }
  33. else
  34. {
  35. ?>
  36. <!--

suche nach

Code

          
(php):

          
  1. <script type="text/javascript">
  2. <!--
  3. function ViewCrossReference( selSelectObject ){

darüber einfügen

Code

          
(php):

          
  1. <?php
  2. }
  3. //End EasyCaptcha Integration
  4. ?>

suche nach

Code

          
(php):

          
  1. HTML_contact::_writeEmailForm( $contact, $params, $sitename, $menu_params );

ersetze durch

Code

          
(php):

          
  1. HTML_contact::_writeEmailForm( $contact, $params, $sitename, $menu_params, &$captcha );

suche nach

Code

          
(php):

          
  1. function _writeEmailForm( &$contact, &$params, $sitename, &$menu_params ) {

ersetze durch

Code

          
(php):

          
  1. function _writeEmailForm( &$contact, &$params, $sitename, &$menu_params, &$captcha ) {

suche nach

Code

          
(php):

          
  1. <br />
  2. <br />
  3. <input type="button" name="send" value="<?php echo(_SEND_BUTTON); ?>" class="button" onclick="validate()" />


darüber einfügen

Code

          
(php):

          
  1. <?php
  2. //EasyCaptcha Integration - added by EasyJoomla.org Project
  3. if($captcha->captcha_id)
  4. {
  5. ?>
  6. <br />
  7. <br />
  8. <input type="hidden" name="captcha_id" value="<?php echo $captcha->getCaptchaId(); ?>" />
  9. Captcha-Code:
  10. <input type='text' name='captcha_code' id="contact_captcha" class='inputbox' /><br /><br />
  11. <img src="<?php echo $captcha->getImageUrl(); ?>" alt="<?php echo $captcha->getAltText(); ?>" id='code' />
  12. <?php echo $captcha->getReloadButton("code");
  13. echo $captcha->getReloadCode();
  14. }
  15. ?>


Oder einfach nur die beiden Dateien aus dem Anhang --> file contact.php und file contact.html.php per FTP überschreiben!

BACKUP NICHT VERGESSEN !

Viel Erfolg! und ein Danke an David aka Snipersister easy-joomla.org  :D


Titel: Workaround - EasyCaptcha auch für das Joomla Kontakt-Formular
Beitrag von: cybergurk am 22. 02. 2008 20:52
Update 1.0.15 ;)


Powered by SMF 1.1.8 | SMF © 2006, Simple Machines LLC