This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Home » plugins » General plug-ins » New Plugin sfCaptchaGD
Re: New Plugin sfCaptchaGD [message #59965 is a reply to message #54790 ] Tue, 02 September 2008 14:14 Go to previous messageGo to next message
shaolin  is currently offline shaolin
Messages: 20
Registered: April 2008
Junior Member
Hi everyone,
i am trying to use this plugin for my symfony project (version 1.0) and it gives me an error :
Fatal error: Using $this when not in object context in D:\myWebSite\plugins\sfCaptchaGDPlugin\config\config.php on line 5

the incriminated line is :
$this->dispatcher->connect('routing.load_configuration', array('sfCaptchaGDRouting', 'listenToRoutingLoadConfigurationEvent'));


I 've followed the instructions step by step so i don't know where is the problem Confused
Can someone help me please ?
Re: New Plugin sfCaptchaGD [message #60361 is a reply to message #59965 ] Sun, 07 September 2008 14:28 Go to previous messageGo to next message
JessOVR  is currently offline JessOVR
Messages: 48
Registered: April 2008
Location: France
Member
Hi,

I tried with adding in my app.yml
  sfCaptchaGDPlugin:
    routes_register:  false
and to add in my routing.yml
sf_captchagd:
  url:    /captcha
  param:  { module: sfCaptchaGD, action: GetImage }


it works !

edit : well, I mean, I got no errors, but still don't see an image !! Rolling Eyes

[Updated on: Sun, 07 September 2008 14:38]

Re: New Plugin sfCaptchaGD [message #60366 is a reply to message #60361 ] Sun, 07 September 2008 17:27 Go to previous messageGo to next message
JessOVR  is currently offline JessOVR
Messages: 48
Registered: April 2008
Location: France
Member
Gee.. I went mad to make it work.

Now it does.

taking into account my previous post stuffs,

1. replace this in sfCaptchaGD.class.php :
//    if ($context->getRequest()->getGetParameter('reload') || ! $securityCode){
    if ($context->getRequest()->getParameter('reload') || ! $securityCode){


2. replace the routing.yml rule by :
sf_captchagd:
  url:    /captcha/:key/:reload
  param:  { module: sfCaptchaGD, action: getImage, key: failed, reload: 0 }


3. here is my code inside my form :
      <?php echo input_tag('captcha', null) ?>
      <?php echo link_to_function(image_tag(url_for('@sf_captchagd?key='.time()), array('id'=>'captcha_img', 'alt'=>'Click if you cannot read the picture')),
                                    'document.getElementById(\'captcha_img\').src=\''.
                                    url_for('@sf_captchagd?reload=1').
                                    '&key=\'+Math.round(Math.random(0)*1000)+1+\'\'') ?>


Hope it helps.
J.

[Updated on: Fri, 12 September 2008 19:56]

Re: New Plugin sfCaptchaGD [message #60904 is a reply to message #54790 ] Fri, 12 September 2008 19:36 Go to previous messageGo to next message
boteeka  is currently offline boteeka
Messages: 19
Registered: January 2008
Location: Romania
Junior Member
I have the same problem as shaolin.
Using Symfony 1.0.

Please help.
Re: New Plugin sfCaptchaGD [message #60906 is a reply to message #54790 ] Fri, 12 September 2008 19:52 Go to previous messageGo to next message
boteeka  is currently offline boteeka
Messages: 19
Registered: January 2008
Location: Romania
Junior Member
@JessOVR:

I managed to get through the errors, but I get no image.

I followed your previous two posts. In your second post at bullet #2 I put the code in the routing.yml, not the settings.yml because it seemed more appropriate. The rest I did just as you wrote.

Any ideas?
Re: New Plugin sfCaptchaGD [message #60907 is a reply to message #60906 ] Fri, 12 September 2008 20:03 Go to previous messageGo to next message
JessOVR  is currently offline JessOVR
Messages: 48
Registered: April 2008
Location: France
Member
In your second post at bullet #2 I put the code in the routing.yml, not the settings.yml because it seemed more appropriate.

Ooops, I've just fixed it, thanx Rolling Eyes

I managed to get through the errors, but I get no image.

mmm.. that means my fix proposal is not that good Confused
by the way, in IE6 I don't see the image the 1st time, I've to click once on the alternative link to make it appear. While it's working perfect in FF3.

Do you, at least, see that alt. link ? And nothing happen when you click on it ?

Re: New Plugin sfCaptchaGD [message #60908 is a reply to message #60907 ] Fri, 12 September 2008 20:20 Go to previous messageGo to next message
boteeka  is currently offline boteeka
Messages: 19
Registered: January 2008
Location: Romania
Junior Member
@JessOVR:
I'm using Firefox 3 on Ubuntu 8.04, but I think that not the browser is the main problem.

And yes, I see the alt link, but nothing happens when I click on it.

Note: Also, I had to include the Javascript helper in my template first in order to get it working. link_to_function() is part of the Javascript helper.
Re: New Plugin sfCaptchaGD [message #60924 is a reply to message #60908 ] Sat, 13 September 2008 14:29 Go to previous messageGo to next message
JessOVR  is currently offline JessOVR
Messages: 48
Registered: April 2008
Location: France
Member
Note: Also, I had to include the Javascript helper in my template first in order to get it working. link_to_function() is part of the Javascript helper.

yeah. mine was included before in the includes chain.

I'm using Firefox 3 on Ubuntu 8.04, but I think that not the browser is the main problem.

ok, I've juste tried on FF2 + Ubuntu 7.10, it works as welle so it does not seem to be a matter of environment.

And yes, I see the alt link, but nothing happens when I click on it.

sorry, don't see the trick Crying or Very Sad up to know.
I keep tracking the post, and will pass by if any idea.
Re: New Plugin sfCaptchaGD [message #60939 is a reply to message #54790 ] Sat, 13 September 2008 17:35 Go to previous messageGo to next message
boteeka  is currently offline boteeka
Messages: 19
Registered: January 2008
Location: Romania
Junior Member
Ok, and thanks for your help so far.
Re: New Plugin sfCaptchaGD [message #61344 is a reply to message #54790 ] Fri, 19 September 2008 16:19 Go to previous messageGo to next message
shaolin  is currently offline shaolin
Messages: 20
Registered: April 2008
Junior Member
i didn't succeed to install this plugin and finally i installed an old symfony captcha plugin.
But may be your image problem is from gb2 library.
Make sure this library is installed on your apache server.
Re: New Plugin sfCaptchaGD [message #61408 is a reply to message #54790 ] Sat, 20 September 2008 15:57 Go to previous messageGo to next message
boteeka  is currently offline boteeka
Messages: 19
Registered: January 2008
Location: Romania
Junior Member
I checked and I have installed and enabled the GD2 library.

Since my last post I managed to find out some more on the issue.
I think I found a problem in the sfCaptchaGD.class.php file. In the generateImage function on the last line there was
$context->getResponse()->send();
but send() does not exist in sfResponse class, neither in sfWebResponse class. Instead there is a sendContent() method in sfResponse and sfWebResponse uses the method of its parent class, which is sfResponse. So I corrected that line in sfCaptchaGD.class.php to
$context->getResponse()->sendContent();
, but still no cake.

The output from http://myproject/frontend_dev.php/sfCaptchaGD/GetImage is weird, to say the least. It outputs the gif contents but in ASCII characters and then I get two warnings:

Warning: Cannot modify header information - headers already sent by (output started at /home/boteeka/Work/rmcssz/plugins/sfCaptchaGDPlugin/lib/sfCaptchaGD.class.php:123) in /usr/share/php/symfony/response/sfWebResponse.class.php on line 264


Warning: Cannot modify header information - headers already sent by (output started at /home/boteeka/Work/rmcssz/plugins/sfCaptchaGDPlugin/lib/sfCaptchaGD.class.php:123) in /usr/share/php/symfony/response/sfWebResponse.class.php on line 274


I understand why the warnings - after all the funny ASCII chars being printed out.

When I checked the response headers the content-type is still text/html instead of image/gif.

At this point I don't know what to try out. I started my project using symfony because it promised that it will be so easy, but since I started I stumble upon problems after problems.

Maybe the author of this plugin has some words to say?
Re: New Plugin sfCaptchaGD [message #61410 is a reply to message #61408 ] Sat, 20 September 2008 17:33 Go to previous messageGo to next message
GliNT  is currently offline GliNT
Messages: 30
Registered: June 2008
Member
boteeka, if you started a new project I think it's better to use 1.1 version of symfony. In 1.1 there is no problem with this plugin, because I wrote plugin for this version originally.
Re: New Plugin sfCaptchaGD [message #61850 is a reply to message #54790 ] Thu, 25 September 2008 20:20 Go to previous messageGo to next message
whalexis  is currently offline whalexis
Messages: 207
Registered: July 2008
Faithful Member
Hi all,

I try to make things work with this plugin.
I made some changes in the code to display an image.

I change this
    // create a new string with a blank space between each letter so it looks better
    $newstr = "";
    for ($i = 0; $i < strlen($this->securityCode); $i++) {
        $newstr .= $this->securityCode[$i] ." ";
    }

by
    // create a new string with a blank space between each letter so it looks better
    $newstr = "";
    $splittedString = str_split($this->securityCode);
    for ($i = 0; $i < strlen($this->securityCode); $i++) {
        $newstr .= $splittedString[$i] ." ";
    }


Without that change, nothing is displayed in the image.
Now I have text in my image.

But i don't know how to make it work without forcing value for $this->securityCode... Still searching how it works
Re: New Plugin sfCaptchaGD [message #61854 is a reply to message #54790 ] Thu, 25 September 2008 21:11 Go to previous messageGo to next message
whalexis  is currently offline whalexis
Messages: 207
Registered: July 2008
Faithful Member
Maybe you should change the default fonts in your plugin because licenses of those fonts are incompatible with the MIT license.
Some off them are for personal use only.

You should have a look to this website http://www.aenigmafonts.com/fonts/fontsa.html
Re: New Plugin sfCaptchaGD [message #61856 is a reply to message #54790 ] Thu, 25 September 2008 21:30 Go to previous messageGo to next message
whalexis  is currently offline whalexis
Messages: 207
Registered: July 2008
Faithful Member
Hi,

I made some changes in the sfCaptchaGD class.

I was bored to add manually font to the configuration file so I made an auto loading font function
.
  protected function getFonts(){
  	if (is_dir($this->fonts_dir)){
  		$files = sfFinder::type('file')->ignore_version_control(true)->name('*.ttf')->relative()->maxdepth(3)->in($this->fonts_dir);
  		foreach($files as $file){
  			$this->fonts[]=$file;
  		}
  	}
  }



And I call it in the constructor
  function __construct() {
      $this->border_color = sfConfig::get('app_sf_captchagd_border_color', "000000");
      $this->background_color = sfConfig::get('app_sf_captchagd_background_color', "DDDDDD");
      $this->fonts_dir = sfConfig::get('app_sf_captchagd_fonts_dir', sfConfig::get('sf_plugins_dir').'/sfCaptchaGDPlugin/data/fonts/');
      $this->fontSize = sfConfig::get('app_sf_captchagd_font_size', "18");
      $this->fontColor = sfConfig::get('app_sf_captchagd_font_color', array("252525", "8b8787", "550707", "3526E6", "88531E"));
      $this->chars = sfConfig::get('app_sf_captchagd_chars', "123456789");
      $this->codeLength = sfConfig::get('app_sf_captchagd_length', 4);
      $this->image_width = sfConfig::get('app_sf_captchagd_image_width', 100);
      $this->image_height = sfConfig::get('app_sf_captchagd_image_height', 30);

      $this->getFonts();
  }


If it could help someone...
Re: New Plugin sfCaptchaGD [message #63399 is a reply to message #61856 ] Sat, 18 October 2008 08:07 Go to previous messageGo to next message
kk8401  is currently offline kk8401
Messages: 10
Registered: October 2008
Junior Member
Hi i m able to use the sfCaptchaGD plugin finally by adding this line of code at the form there

config/routing.yml
sf_captchagd:
  url:    /captcha/:key/:reload
  param:  { module: sfCaptchaGD, action: getImage, key: failed, reload: 0 }


 <a href='' onClick='return false' title='Reload image'><img id='captchaimg' src='<?php echo url_for('@sf_captchagd?key='.gmdate('Y-m-d h:m:s'))?>' onClick="<?php echo 'document.getElementById(\'captchaimg\').src=\''.url_for('@sf_captchagd?reload=1').'&key=\'+Math.round(Math.random(0)*1000)+1+\'\''?>" border='0'></a>


However, i found out that the random generated number is always the same even though i refresh the page or click the image to reload it.
It will change to another random number only after the validator found out that the number inserted was incorrect.

Is there anyway to make the random number really works fine?

Thanks
Re: New Plugin sfCaptchaGD [message #63402 is a reply to message #63399 ] Sat, 18 October 2008 09:25 Go to previous messageGo to next message
JessOVR  is currently offline JessOVR
Messages: 48
Registered: April 2008
Location: France
Member
Hi,
could'nt it be a caching issue ?
Re: New Plugin sfCaptchaGD [message #63405 is a reply to message #54790 ] Sat, 18 October 2008 09:54 Go to previous messageGo to next message
kk8401  is currently offline kk8401
Messages: 10
Registered: October 2008
Junior Member
I clear the browser and symfony cache, tested wit FF, IE.
It is still the same
Re: New Plugin sfCaptchaGD [message #63491 is a reply to message #54790 ] Mon, 20 October 2008 05:52 Go to previous messageGo to next message
kk8401  is currently offline kk8401
Messages: 10
Registered: October 2008
Junior Member
if ($context->getRequest()->getGetParameter('reload') || ! $securityCode){
   $this->securityCode = $this->simpleRandString($this->codeLength, $this->chars);
} else {
   $this->securityCode = $securityCode;
}



instead of using the code above in sfCaptchaGD
i had change the code to let it auto generate random number all the while.
it works fine now

//if ($context->getRequest()->getGetParameter('reload') || ! $securityCode){
   $this->securityCode = $this->simpleRandString($this->codeLength, $this->chars);  // Just use this line
//} else {
//   $this->securityCode = $securityCode;
//}
Re: New Plugin sfCaptchaGD [message #65918 is a reply to message #63491 ] Tue, 25 November 2008 09:18 Go to previous messageGo to next message
leopan  is currently offline leopan
Messages: 18
Registered: July 2008
Location: Philippines
Junior Member
plugin just doesn't work out of the box, it's easier to create a personal captcha function

recent download of the plugin manifested errors pointed out in previous posts,


didn't work in 1.0 and still didn't work in 1.1 the way previous post suggested (glint?)


Only those who risk going too far can possibly find out how far one can go
Re: New Plugin sfCaptchaGD [message #65993 is a reply to message #65918 ] Tue, 25 November 2008 22:20 Go to previous messageGo to next message
GliNT  is currently offline GliNT
Messages: 30
Registered: June 2008
Member
Quote:

plugin just doesn't work out of the box, it's easier to create a personal captcha function

recent download of the plugin manifested errors pointed out in previous posts,


didn't work in 1.0 and still didn't work in 1.1 the way previous post suggested (glint?)


Some errors were in 1.0 symfony, I haven't much time to check in old version. After releasing 1.2 I upgrade this plugin to work with 1.2. Current version works fine in 1.1, tested in clean symfony 1.1 installation.

Have you any problem in 1.1?
Re: New Plugin sfCaptchaGD [message #84912 is a reply to message #54790 ] Mon, 07 September 2009 00:00 Go to previous messageGo to next message
Apiarnaud  is currently offline Apiarnaud
Messages: 7
Registered: February 2009
Location: Antibes, France
Junior Member

Hello all,

thanks for your help.

In my situation (a project symfony 1.0 based),
I have some authentication with a myUser class

The captcha MUST not be secured (else it'll appear only when you are connected)

I add this file directly in the plugin :

create /plugins/sfCaptchaGDPlugin/modules/sfCaptchaGD/config

and cat a security.yml file

add the lines :

GetImage:
  is_secure:   off


it's like an older post which explain on general security.yml (in app folder) is_secure set on "off" but you lose your authentication.

sorry for my english i'm french

the sfCaptchaGD works fine for me after edit the class to correct all bugs !!!

Buff

[Updated on: Mon, 07 September 2009 00:01]

Re: New Plugin sfCaptchaGD [message #87704 is a reply to message #54790 ] Mon, 02 November 2009 11:49 Go to previous messageGo to next message
SmallBen  is currently offline SmallBen
Messages: 21
Registered: September 2009
Junior Member
Hi all i am new in symfony and this is my first plugin i am trying to install (instead of sfGuard from jobeet), so be patient please Very Happy

I've got a project on symfony1.2.8, this is what i,ve done:

in lib/form/base/BaseSzkolaForm.class.php
class BaseSzkolaForm extends BaseFormPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      ...
	  'captcha'  => new sfWidgetCaptchaGD(),
    ));

    $this->setValidators(array(
      ...
    'captcha'  => new sfCaptchaGDValidator(array('length' => 4)),
    ));

    ...
  }
...
}


apps/frontend/config/routing.yml
...
sf_captchagd:
  url:    /captcha/:key/:reload
  param:  { module: sfCaptchaGD, action: getImage, key: failed, reload: 0 }


the form is displayed and validated by default symfony actions and templates: newSuccess.php which use partial form (i didn't edit them), and in the action.class.php
protected function processForm(sfWebRequest $request, sfForm $form)
{
  $form->bind(array(
     'captcha' => $request->getParameter('captcha'),
     $request->getParameter($form->getName())),
     $request->getFiles($form->getName())
     );
    if ($form->isValid())
    {
      ...
    }
  }


So i've got the captcha input field in my form but there is no image. What am i doing wrong?
Re: New Plugin sfCaptchaGD [message #87730 is a reply to message #87704 ] Mon, 02 November 2009 23:48 Go to previous messageGo to next message
GliNT  is currently offline GliNT
Messages: 30
Registered: June 2008
Member
Hi, SmallBen!

Try to load captcha image with this url(relative to app root): /captcha?1

If something goes wrong - look at logs for a reason.
Re: New Plugin sfCaptchaGD [message #87743 is a reply to message #87730 ] Tue, 03 November 2009 10:13 Go to previous messageGo to next message
SmallBen  is currently offline SmallBen
Messages: 21
Registered: September 2009
Junior Member
GliNT wrote on Mon, 02 November 2009 23:48


Try to load captcha image with this url(relative to app root): /captcha?1



What do You mean, i don't understand what to do Confused
1.Put the <img> in the template with form?
or
2.Make a link like
<a href="../apps/frontend:/captcha?1">


Can You explain me how to load that captcha in more detailed way because i dont't get it?

can you give me an example....

thanks in advance!
Re: New Plugin sfCaptchaGD [message #87817 is a reply to message #87704 ] Wed, 04 November 2009 12:48 Go to previous messageGo to next message
GliNT  is currently offline GliNT
Messages: 30
Registered: June 2008
Member
I've attached sample module.
Hope it helps.

  • Attachment: main.tgz
    (Size: 1.08KB, Downloaded 87 time(s))

Re: New Plugin sfCaptchaGD [message #87878 is a reply to message #87817 ] Thu, 05 November 2009 13:37 Go to previous messageGo to next message
SmallBen  is currently offline SmallBen
Messages: 21
Registered: September 2009
Junior Member
So GliNT
I've made a project with your contactform (from attachment).

And there is the same problem as i have in my project - the image is not displayed.

This is all project(PluginsTests without symfony installation in lib/vendor) based upon your attach, can You look at this and write how to fix it?

Re: New Plugin sfCaptchaGD [message #87881 is a reply to message #87878 ] Thu, 05 November 2009 13:46 Go to previous messageGo to next message
SmallBen  is currently offline SmallBen
Messages: 21
Registered: September 2009
Junior Member
OK it works fine - i've forget about enable module Smile
But now when i try to submit the form with good values it returns me:
ERR!
* csrf token: Required.

[Updated on: Thu, 05 November 2009 15:59]

Re: New Plugin sfCaptchaGD [message #87951 is a reply to message #54790 ] Sat, 07 November 2009 01:12 Go to previous messageGo to next message
jesse  is currently offline jesse
Messages: 104
Registered: June 2007
Location: Berkeley, CA
Senior Member
Is there any reason why someone would use a plugin like this instead of a service like reCAPTCHA? Most GD-based CAPTCHAs can be defeated quickly, whereas reCAPTCHA is a service that relieves developers of the burden of keeping their algorithms one-step ahead of bots.


Jesse Dhillon
http://deva0.net
Re: New Plugin sfCaptchaGD [message #87954 is a reply to message #87951 ] Sat, 07 November 2009 09:11 Go to previous messageGo to next message
GliNT  is currently offline GliNT
Messages: 30
Registered: June 2008
Member
Defeat quickly? Are you really so cool hacker? Before I didn't meet anyone who did it, so this captcha does its job very well. If you like reCaptcha - just use it Smile
Re: New Plugin sfCaptchaGD [message #87979 is a reply to message #87954 ] Sat, 07 November 2009 19:40 Go to previous messageGo to next message
jesse  is currently offline jesse
Messages: 104
Registered: June 2007
Location: Berkeley, CA
Senior Member
Is there anyone who is can make a helpful contribution on this topic?

Specifically: when Google, Yahoo and Microsoft's implementations have defeat rates from 20-40%, even though they have armies of programmers, and endless supplies of PhD's, what hope is there for an implementation maintained by one guy?

I'm honestly asking:

  • What is the motivation for developing yet another implementation?
  • What is the motivation for bypassing an existing, well-maintained implementation which comes with an implicit guarantee of transparent improvement? (An improvement to the algorithm can be made without requiring developers to upgrade their versions of the library)


If we can avoid the defensive comments from this plugin's author, I'm hoping to understand what is the incentive to use this implementation. Thanks,

PS -- Here are some links to research about defeating CAPTCHAs:
http://www.cs.sfu.ca/~mori/research/gimpy/
http://caca.zoy.org/wiki/PWNtcha

[Updated on: Sat, 07 November 2009 22:43]


Jesse Dhillon
http://deva0.net
Re: New Plugin sfCaptchaGD [message #88008 is a reply to message #87704 ] Sun, 08 November 2009 23:51 Go to previous messageGo to next message
GliNT  is currently offline GliNT
Messages: 30
Registered: June 2008
Member
reCaptcha plugin makes some low-level fsockopen calls to reCaptcha servers, this plugin doesn't, only requitment is GD library.
If reCaptcha servers are not available captcha doesn't work. It is a weak thing. Less 3-d party connections is better.

Quote:

they have armies of programmers, and endless supplies of PhD's

So, we must sit and wait when a Google makes ours work?
Re: New Plugin sfCaptchaGD [message #88347 is a reply to message #88008 ] Fri, 13 November 2009 14:48 Go to previous messageGo to next message
SmallBen  is currently offline SmallBen
Messages: 21
Registered: September 2009
Junior Member
OK
I've got image but when i write down the code and try to send the form. It gives me:

-csrf token: Required.

here's the code:
// lib\form\ContactForm.class.php
class ContactForm extends sfForm
{
  public function configure()
  {
    $this->setWidgets(array(
      'name'    => new sfWidgetFormInput(),
      'email'   => new sfWidgetFormInput(),
      'message' => new sfWidgetFormTextarea(),
      'captcha' => new sfWidgetCaptchaGD(),
    ));

    $this->setValidators(array(
      'name'    => new sfValidatorString(array('required' => false)),
      'email'   => new sfValidatorEmail(),
      'message' => new sfValidatorString(array('min_length' => 4)),
      'captcha' => new sfCaptchaGDValidator(array('length' => 4)),
    ));
  }
}

// apps\...\action.class.php
class captchagdActions extends sfActions
{
  public function executeIndex(sfWebRequest $request)
  {
    $this->form = new ContactForm();

    if ($request->isMethod('post'))
    {
      $this->form->bind(array(
        'name'      => $request->getParameter('name'), 
        'email'     => $request->getParameter('email'),
        'message'   => $request->getParameter('message'),
        'captcha'   => $request->getParameter('captcha'),
      ));
      if ($this->form->isValid()){
        $this->msg = "OK!";
      } else {
        $this->msg = "ERR!";
      }
    }
  }
}

// apps\...\indexSuccess.php
<?php
  if (isset($msg))
  {
	echo "<h3>$msg</h3>";
  }
?>
<form method="POST">
  <table>
    <?php echo $form ?>
    <tr>
      <td colspan="2">
        <input type="submit" />
      </td>
    </tr>
  </table>
</form>


Where is mistake?

[Updated on: Fri, 13 November 2009 15:21]

Re: New Plugin sfCaptchaGD [message #88353 is a reply to message #88347 ] Fri, 13 November 2009 16:04 Go to previous messageGo to next message
GliNT  is currently offline GliNT
Messages: 30
Registered: June 2008
Member
Did you enable csrf_secret in settings.yml?
Re: New Plugin sfCaptchaGD [message #88387 is a reply to message #88353 ] Sat, 14 November 2009 13:41 Go to previous messageGo to next message
SmallBen  is currently offline SmallBen
Messages: 21
Registered: September 2009
Junior Member
ok when i put "csrf_secret: false" in settings.yml it works fine Smile
But in more complicated form it always gives me "captcha required" even when i fill this field.
here is my code:
//lib\form\base\BaseSzkolaForm.class.php
class BaseSzkolaForm extends BaseFormPropel
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'               => new sfWidgetFormInputHidden(),

      .
      .
      .

      'captcha' 		 => new sfWidgetCaptchaGD(),
    ));

    $this->setValidators(array(
      'id'         => new sfValidatorPropelChoice(array('model' => 'Szkola', 'column' => 'id', 'required' => false)),
      'captcha' 		 => new sfCaptchaGDValidator(array('length' => 4)),
    ));

    $this->widgetSchema->setNameFormat('szkola[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

//...\actions.class.php
...
$form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
...

there are also files send by this form, i think that i give wrong parameter to bind(). is this wrong when i set widgets and validators in baseForm.class instead of Form.class?

[Updated on: Sun, 15 November 2009 13:02]

Re: New Plugin sfCaptchaGD [message #88479 is a reply to message #87951 ] Mon, 16 November 2009 11:19 Go to previous messageGo to next message
SmallBen  is currently offline SmallBen
Messages: 21
Registered: September 2009
Junior Member
jesse wrote on Sat, 07 November 2009 01:12

Is there any reason why someone would use a plugin like this instead of a service like reCAPTCHA?

Where can i find a read me file to reCAPTCHA?

[Updated on: Mon, 16 November 2009 11:32]

Re: New Plugin sfCaptchaGD [message #88513 is a reply to message #88479 ] Mon, 16 November 2009 18:29 Go to previous messageGo to next message
jesse  is currently offline jesse
Messages: 104
Registered: June 2007
Location: Berkeley, CA
Senior Member
http://recaptcha.net/plugins/php/

There is a symfony plugin but I don't know its current status. There is not much to the library, you can put it all in lib/ and have it autoload.


Jesse Dhillon
http://deva0.net
Re: New Plugin sfCaptchaGD [message #88574 is a reply to message #54790 ] Tue, 17 November 2009 14:57 Go to previous messageGo to next message
litelus  is currently offline litelus
Messages: 2
Registered: November 2009
Junior Member
in case you get csrf required or captcha required errors you should make sure you bind them both in the same bind() call.

something like this:

$values = $request->getParameter($form->getName());
$values['captcha'] = $request->getParameter('captcha');
$form->bind($values);

also turning csrf protection off or writing in base files is not a good idea.
hope this helps someone, cause i'm new to symfony also and it gave me a little headache
Re: New Plugin sfCaptchaGD [message #88627 is a reply to message #88574 ] Wed, 18 November 2009 10:45 Go to previous messageGo to next message
SmallBen  is currently offline SmallBen
Messages: 21
Registered: September 2009
Junior Member
litelus wrote on Tue, 17 November 2009 14:57

in case you get csrf required or captcha required errors you should make sure you bind them both in the same bind() call.

something like this:

$values = $request->getParameter($form->getName());
$values['captcha'] = $request->getParameter('captcha');
$form->bind($values);

also turning csrf protection off or writing in base files is not a good idea.
hope this helps someone, cause i'm new to symfony also and it gave me a little headache

OK so in my first project(simple contact form) with this captcha plugin, there is one bind and it looks like this:
$this->form->bind(array(
        'name'      => $request->getParameter('name'), 
        'email'     => $request->getParameter('email'),
        'message'   => $request->getParameter('message'),
        'captcha'   => $request->getParameter('captcha'),
      ));

when csrf_secret: in settings.yml is enabled, the form returns csrf token: Required, when csrf_secret: is disabled it works fine. What should i do to make it works with csrf protection enabled?
Re: New Plugin sfCaptchaGD [message #88636 is a reply to message #88627 ] Wed, 18 November 2009 11:40 Go to previous messageGo to previous message
litelus  is currently offline litelus
Messages: 2
Registered: November 2009
Junior Member
try

$this->form->bind(array(
        'name'      => $request->getParameter('name'), 
        'email'     => $request->getParameter('email'),
        'message'   => $request->getParameter('message'),
        'captcha'   => $request->getParameter('captcha'),
        '_csrf_token'   => $request->getParameter('_csrf_token'),
      ));



you could also try
var_dump($request->getParameter($this->form->getName())); 
die();

and see what the form framework gives you

Previous Topic:sfWidgetFormJqueryDate problems
Next Topic:SfEasyGmapPlugin
Goto Forum:
  

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software