[Projet] ReCaptcha dans Register+Affiliate+Contact

Programmation, discussions et suggestions pour l'amélioration de OpenCart

[Projet] ReCaptcha dans Register+Affiliate+Contact

Messagepar lordbdp » 17 Oct 2011, 22:46

Le but de l'opération : Avoir un Captcha dans toutes les pages qui demandent une inscription.

Etant un peu (voir beaucoup) limité en programmation je suis partie sur recaptcha_free_oc1.5.1.x_v1.0.1 en espérant que quelqu'un proposerait une évolution du module pour toutes les autres pages. Et puis apparu Register on Captcha 1.5.x qui ajoute un captcha sur les pages manquantes.
Donc je me suis dit pourquoi ne pas faire gérer ReCaptcha Free les autres pages où se trouvent désormais Register on Captcha.
J'ai donc trouvé que je n'avais qu'à ajouter une commande dans le xml de ReCaptcha Free de la façon suivante :
Code: Tout sélectionner
<modification>
   <id>ReCAPTCHA Free</id>
   <version>1.0.2</version>
   <vqmver>2.1</vqmver>
   <author>Ryan (rph) - OpenCartHelp.com</author>
   <file name="catalog/controller/information/contact.php">
      <operation error="abort">
         <search position="before"><![CDATA[if (isset($this->request->post['name'])) {]]></search>
         <add><![CDATA[      if ($this->config->get('recaptcha_private_key') && $this->config->get('recaptcha_public_key')) {
         require_once(DIR_SYSTEM . 'library/recaptchalib.php');

         $this->data['recaptcha'] = recaptcha_get_html($this->config->get('recaptcha_public_key'));
      } else {
         $this->data['recaptcha'] = '';
      }
]]></add>
      </operation>
      <operation error="abort">
         <search position="before"><![CDATA[if (!isset($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {]]></search>
         <add><![CDATA[      if (!$this->config->get('recaptcha_private_key') || !$this->config->get('recaptcha_public_key')) {]]></add>
      </operation>
      <operation error="abort">
         <search position="before"><![CDATA[if (!$this->error) {]]></search>
         <add><![CDATA[      } else {
         require_once(DIR_SYSTEM . 'library/recaptchalib.php');

         $response = recaptcha_check_answer($this->config->get('recaptcha_private_key'), $this->request->server['REMOTE_ADDR'], $this->request->post['recaptcha_challenge_field'], $this->request->post['recaptcha_response_field']);

         if (!$response->is_valid) {
            $this->error['captcha'] = $this->language->get('error_captcha');
         }
      }
]]></add>
      </operation>
   </file>
   <file name="catalog/view/theme/*/template/information/contact.tpl">
      <operation error="abort">
         <search position="before"><![CDATA[<b><?php echo $entry_captcha; ?></b><br />]]></search>
         <add><![CDATA[    <?php if ($recaptcha) { ?>
    <?php echo $recaptcha; ?>
    <br />
    <?php if ($error_captcha) { ?>
    <span class="error"><?php echo $error_captcha; ?></span>
    <?php } ?>
    <?php } else { ?>]]></add>
      </operation>
      <operation error="abort">
         <search position="after" index="2"><![CDATA[<span class="error"><?php echo $error_captcha; ?></span>]]></search>
         <add><![CDATA[    <?php } ?>]]></add>
      </operation>
   </file>
      <file name="catalog/controller/account/register.php">
      <operation error="abort">
         <search position="before"><![CDATA[if (isset($this->request->post['name'])) {]]></search>
         <add><![CDATA[      if ($this->config->get('recaptcha_private_key') && $this->config->get('recaptcha_public_key')) {
         require_once(DIR_SYSTEM . 'library/recaptchalib.php');

         $this->data['recaptcha'] = recaptcha_get_html($this->config->get('recaptcha_public_key'));
      } else {
         $this->data['recaptcha'] = '';
      }
]]></add>
      </operation>
      <operation error="abort">
         <search position="before"><![CDATA[if (!isset($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {]]></search>
         <add><![CDATA[      if (!$this->config->get('recaptcha_private_key') || !$this->config->get('recaptcha_public_key')) {]]></add>
      </operation>
      <operation error="abort">
         <search position="before"><![CDATA[if (!$this->error) {]]></search>
         <add><![CDATA[      } else {
         require_once(DIR_SYSTEM . 'library/recaptchalib.php');

         $response = recaptcha_check_answer($this->config->get('recaptcha_private_key'), $this->request->server['REMOTE_ADDR'], $this->request->post['recaptcha_challenge_field'], $this->request->post['recaptcha_response_field']);

         if (!$response->is_valid) {
            $this->error['captcha'] = $this->language->get('error_captcha');
         }
      }
]]></add>
      </operation>
   </file>
   <file name="catalog/view/theme/*/template/account/register.tpl">
      <operation error="abort">
         <search position="before"><![CDATA[<b><?php echo $entry_captcha; ?></b><br />]]></search>
         <add><![CDATA[    <?php if ($recaptcha) { ?>
    <?php echo $recaptcha; ?>
    <br />
    <?php if ($error_captcha) { ?>
    <span class="error"><?php echo $error_captcha; ?></span>
    <?php } ?>
    <?php } else { ?>]]></add>
      </operation>
      <operation error="abort">
         <search position="after" index="2"><![CDATA[<span class="error"><?php echo $error_captcha; ?></span>]]></search>
         <add><![CDATA[    <?php } ?>]]></add>
      </operation>
   </file>
   <file name="catalog/controller/affiliate/register.php">
      <operation error="abort">
         <search position="before"><![CDATA[if (isset($this->request->post['name'])) {]]></search>
         <add><![CDATA[      if ($this->config->get('recaptcha_private_key') && $this->config->get('recaptcha_public_key')) {
         require_once(DIR_SYSTEM . 'library/recaptchalib.php');

         $this->data['recaptcha'] = recaptcha_get_html($this->config->get('recaptcha_public_key'));
      } else {
         $this->data['recaptcha'] = '';
      }
]]></add>
      </operation>
      <operation error="abort">
         <search position="before"><![CDATA[if (!isset($this->session->data['captcha']) || ($this->session->data['captcha'] != $this->request->post['captcha'])) {]]></search>
         <add><![CDATA[      if (!$this->config->get('recaptcha_private_key') || !$this->config->get('recaptcha_public_key')) {]]></add>
      </operation>
      <operation error="abort">
         <search position="before"><![CDATA[if (!$this->error) {]]></search>
         <add><![CDATA[      } else {
         require_once(DIR_SYSTEM . 'library/recaptchalib.php');

         $response = recaptcha_check_answer($this->config->get('recaptcha_private_key'), $this->request->server['REMOTE_ADDR'], $this->request->post['recaptcha_challenge_field'], $this->request->post['recaptcha_response_field']);

         if (!$response->is_valid) {
            $this->error['captcha'] = $this->language->get('error_captcha');
         }
      }
]]></add>
      </operation>
   </file>
   <file name="catalog/view/theme/*/template/affiliate/register.tpl">
      <operation error="abort">
         <search position="before"><![CDATA[<b><?php echo $entry_captcha; ?></b><br />]]></search>
         <add><![CDATA[    <?php if ($recaptcha) { ?>
    <?php echo $recaptcha; ?>
    <br />
    <?php if ($error_captcha) { ?>
    <span class="error"><?php echo $error_captcha; ?></span>
    <?php } ?>
    <?php } else { ?>]]></add>
      </operation>
      <operation error="abort">
         <search position="after" index="2"><![CDATA[<span class="error"><?php echo $error_captcha; ?></span>]]></search>
         <add><![CDATA[    <?php } ?>]]></add>
      </operation>
   </file>
</modification>


Mais ça ne marche pas. J'ai l'impression qu'il me manque juste une commande entre chaque instruction pour que si la 1ère instruction (contact) n'est pas à traiter le programme doit passer à la 2eme instruction (register), et si pas la 2e alors passer à la 3e(affiliate)...

Je suis allé dans le PHP Manual mais je ne sais quelle commande choisir...
Open Cart 1.5.1.3 U.S
Traduction 1.5.1.3.1 FR
Hébergement Planethoster
Avatar de l’utilisateur
lordbdp
 
Messages: 87
Inscrit le: 11 Oct 2011, 22:36

Re: [Projet] ReCaptcha dans Register+Affiliate+Contact

Messagepar LeorLindel » 18 Oct 2011, 02:50

lordbdp a écrit:Mais ça ne marche pas. J'ai l'impression qu'il me manque juste une commande entre chaque instruction pour que si la 1ère instruction (contact) n'est pas à traiter le programme doit passer à la 2eme instruction (register), et si pas la 2e alors passer à la 3e(affiliate)...
Chaque enregistrement est différent et ne dépend pas l'un de l'autre.

Je viens de faire le vQmod XML pour le captcha de "account" et "affiliate", il se trouve ici, tu peux donc t'en servir pour le modifier en Recaptcha (captcha de google) et en faire un fichier XML.
1 - A lire avant de poster un sujet
2 - Politique sur la signature.

Image
Il vaut mieux poser une question et paraître idiot cinq minutes que de ne pas la poser et être idiot toute sa vie.
Cool Boutik
Avatar de l’utilisateur
LeorLindel
 
Messages: 1987
Inscrit le: 19 Fév 2010, 13:44
Localisation: Lutéce


Retour vers Développement

Qui est en ligne ?

Utilisateur(s) parcourant actuellement ce forum : Exabot [Bot] et 1 invité

cron
Partenaires de paiement