|
|
| Re: New Plugin sfCaptchaGD [message #60366 is a reply to message #60361 ] |
Sun, 07 September 2008 17:27   |
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 #61856 is a reply to message #54790 ] |
Thu, 25 September 2008 21:30   |
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 #65918 is a reply to message #63491 ] |
Tue, 25 November 2008 09:18   |
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 #87704 is a reply to message #54790 ] |
Mon, 02 November 2009 11:49   |
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
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 #87817 is a reply to message #87704 ] |
Wed, 04 November 2009 12:48   |
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   |
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 #87979 is a reply to message #87954 ] |
Sat, 07 November 2009 19:40   |
 |
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 #88347 is a reply to message #88008 ] |
Fri, 13 November 2009 14:48   |
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 #88387 is a reply to message #88353 ] |
Sat, 14 November 2009 13:41   |
SmallBen Messages: 21 Registered: September 2009 |
Junior Member |
|
|
ok when i put "csrf_secret: false" in settings.yml it works fine 
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   |
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 #88627 is a reply to message #88574 ] |
Wed, 18 November 2009 10:45   |
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?
|
|
|
|