We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 25576
    • 27 Posts
    I’m using Jot 1.1.2 on MODx 0.9.6.1 and generally it’s working fine. I’d like to use captchas for comments (using &captcha=`2`), but there’s a problem. The captchas appear okay, but every time I try leaving a comment, the system reports that the "security code was incorrect". I’ve tried with captchas switched on and off generally for the site (from manager), to no avail.

    I think this might have something to do with my PHP setup, because the captchas work fine on my local system - it’s only on the live server (on shared hosting) that the code is always rejected. I’ll try playing with the php.ini settings, but does anyone have any idea where I could start looking? (I tried copying the php.ini file from the live server to my local system but it didn’t change anything, so I’m not entirely confident it’s going to make a difference).
      • 25576
      • 27 Posts
      Well, the above problem was posted in March and I’ve still no solution.

      I have two sites hosted on the same shared hosting. On one, the captcha is working properly. On the other, the entered code is always rejected. I can’t see any difference in the settings, so I have no idea where to start looking for the problem.

      On the user tab of the config settings, I have ’Use CAPTCHA codes’ set to no on both sites (Jot seems to ignore this setting). Changing this to ’yes’ has no effect on the comments - I still get ’The security code you entered was incorrect’.

      I really need to enable captcha in Jot because I’m getting a fair bit of comment spam on this site. Does anyone have any ideas?
        • 32525
        • 27 Posts
        Hey there Rotsky,

        I have just been informed by a site user that my captcha was not working on comments and therefore they couldn’t leave a message. I took a look at the jot code and I found that on my installation I had the following (around line 537 of /assets/snippets/jot/jot.class.inc.php):

        //-- Captcha/Veriword
        if ($saveComment && !(($this->config["captcha"] == 0 || isset($_POST['vericode']) && isset($_SESSION['veriword']) && $_SESSION['veriword'] == $_POST['vericode']))) {
             $this->form['error'] = 2; // Veriword / Captcha incorrect
             unset($pObj);
             return;
        } else {
             $_SESSION['veriword'] = md5($this->config["seed"]);
        }


        The problem here is that it included a double negative, as it was first checking that $saveComment is true and then checking a bunch of variables were not true - one of which was $this->config["captcha"] is inactive. So in summary to fix it I simply changed the following:

        $this->config["captcha"] == 0


        to


        $this->config["captcha"] == 1


        I hope this is the problem that you are having - if it is I’ll post the fix off. wink
          • 3749
          • 24,544 Posts
          The Captcha answer is stored in a $_SESSION variable for later comparison to the user’s input. There might be a problem with the persistence of $_SESSION variables on your site.

            Did I help you? Buy me a beer
            Get my Book: MODX:The Official Guide
            MODX info for everyone: http://bobsguides.com/modx.html
            My MODX Extras
            Bob's Guides is now hosted at A2 MODX Hosting
            • 32525
            • 27 Posts
            Hi BobRay,

            Wouldn’t the $_SESSION persistence issue affect quite a few areas of ModX as there appear to be many session variables used? This is a genuine question as I wonder whether it would have any impact on building snippets.
              • 3749
              • 24,544 Posts
              Quote from: Wiseguy at Feb 27, 2009, 03:36 AM

              Hi BobRay,

              Wouldn’t the $_SESSION persistence issue affect quite a few areas of ModX as there appear to be many session variables used? This is a genuine question as I wonder whether it would have any impact on building snippets.

              Possibly, depending on what components you have installed, although many of them might still work but not perfectly.

              It’s the only thing I can think of that fits your symptoms. I guess you could write a couple of snippets to test it easily enough

              SetSV snippet:
              [[SetSV? &string =`someArbitrayString']]
              
              
              <?php
              $_SESSION['MyTest'] = $string; 
              ?>


              TestSV snippet:
              [!TestSV? &loops=`100` &sleepTime=`10`!]
              
              <?php
              while ($loops > 0) {
              
              echo 'Counter = ' . $loops . '    String = '$_SESSION['MyString'] . '<br />';
              
              sleep($sleepTime);  
               
              $loops = $loops - 1;
              }
              
              ?>


              Set loops to 360 and it should run for an hour. wink I think you want the page cached but try it both ways.
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting
                • 33992 ☆ A M B ☆
                • 455 Posts
                Quote from: Wiseguy at Feb 26, 2009, 10:43 AM
                The problem here is that it included a double negative, as it was first checking that $saveComment is true and then checking a bunch of variables were not true - one of which was $this->config["captcha"] is inactive. So in summary to fix it I simply changed the following:
                $this->config["captcha"] == 0

                to
                $this->config["captcha"] == 1

                Please attention to !
                code is correct. ! ($this->config["captcha"] == 0) returns true when $this->config["captcha"] is 1 or 2 (or any else).



                I have problem with CAPTCHA (in php config), i can’t use it but i need it like you.
                So i created a custom captcha like this and a new customfield,

                in form template:
                ....
                <div class="jot-err">
                [+form.error:select=`
                ....
                &2= Are you OK? Today is [+form.field.custom.myvericode+]?!
                ....
                `+]
                </div>
                ....
                Today is: 
                <select name="myVericode">
                	<option value="Sat">Sat</option>
                	<option value="Sun">Sun</option>
                	<option value="Mon">Mon</option>
                	<option value="Tue">Tue</option>
                	<option value="Wed">Wed</option>
                	<option value="Thu">Thu</option>
                	<option value="Fri">Fri</option>
                </select>
                ....
                


                and add this in jot.class.inc.php after Jot captcha check (line 548):
                if ($saveComment && !( strtolower(date("D")) == strtolower($_POST['myVericode']) )  ){
                	$this->form['error'] = 2; // My Veriword / Captcha incorrect
                	unset($pObj);
                	return;
                } 

                and in Jot call: [!Jot? .... &customfields=`.... ,myVericode` ...!]


                You can also use usual trick, a CSS hidden field:
                <input type="text" name="myVeriword" value="0" style="display:none;" />

                user won’t see this field and can not change it’s value so....
                if ($saveComment && $_POST['myVericode'] != 0){
                	$this->form['error'] = 2; // My Veriword / Captcha incorrect
                	unset($pObj);
                	return;
                } 



                Robots can not pass these way.... (i hope) wink
                  God loves me. 【ツ】


                  MODX.ir (Persian Support)

                  Boplo.ir/modx/ (Persian)
                  • 1122
                  • 209 Posts
                  Hi rotsky, AHHP,

                  the message "security code you entered was incorrect" often means that the designer/developer called Jot (with captcha enabled) twice or more times on the same page. (You did not provide with details how you are calling Jot so I can only guess it.) Please read at least my last post to this thread http://modxcms.com/forums/index.php?topic=24511.0 -- I am explaining there details of the validation process. Maybe you will find it useful as it was found a year ago by virgil for whom I solved his captcha problem.