Slider Captcha using QSlider
Hi.
I saw a neat Captcha system the other day using a Slide bar instead of the crazy questions and disabled letters. It simply used a Slider Bar. I don't yet know how effective it is against Bots...but I decided to try it using QSlider. I elected to simply make the Submit button invisable until the slider is moved. You could dress the display up with CSS and whatever. You could also set a value that the Slider->Value must exceed before turning on the Submit button.
Would be fun to tell the "Human" that they have to slide the bar further. :-)
Here is the code I used.. I tried to make a quick stand alone example but you can put the slider and Submit button code in any Qform that you want Captcha.
<?php
require_once('../qcubed.inc.php');
class DemoCaptchaSlider extends QForm {
protected $Slider;
Protected $btnSubmit;
protected function Form_Create() {
// Slider
$this->Slider = new QSlider($this);
$this->Slider->Name = 'If you are Human move this Slider to enable Submit';
$this->Slider->Width = 100;
$this->Slider->AddAction (new QSlider_ChangeEvent(), new QAjaxAction ('slider_change'));
// Create Buttons and Actions on this Form
$this->btnSubmit = new QButton($this);
$this->btnSubmit->Text = QApplication::Translate('Submit');
$this->btnSubmit->AddAction(new QClickEvent(), new QAjaxAction('Submit_Click'));
$this->btnSubmit->CausesValidation = true;
// make sure Submit button does not display at first
$this->btnSubmit->Display = false;
}
Protected function Submit_Click() {
// send form data wherever here
}
// Turn on Submit Button
protected function slider_change() {
$this->btnSave->Display = true;
}
}
DemoCaptchaSlider::Run('DemoCaptchaSlider');
?>Here is the .tpl
<?php
$this->RenderBegin();
?><?php
$this->Slider->RenderWithName();
?><?php
$this->btnSave->Render();
?><?php
$this->RenderEnd()
?>
Opps typo
All of the btnSave's above should be btnSubmit.
David