Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Captcha
  • I think we need captcha class or package with option to create own drivers.
  • Feel free to create something, or port an existing library into a package. If you choose the latter check out the packages in github.com/fuel-packages as examples. Let me know if you've created something like this and I'll import it to the fuel-packages account.
  • Jelmer Schreuder wrote on 02/03/11 10:43 am:
    Feel free to create something, or port an existing library into a package. If you choose the latter check out the packages in github.com/fuel-packages as examples. Let me know if you've created something like this and I'll import it to the fuel-packages account.

    Ok, I will make it on days off.
  • vicente pattugalan wrote on Sunday 16th of October 2011:
    hello, can anyone provide a working sample of this Captcha? I am following the flow of this Captcha it seems the author did not proceed his plan 'after 2-3days' to modify. I hope he will have time and this will help the community in putting captcha in their application.
    thanks

    I've got it working with FuelPHP v1.1 RC1 In controller, I'm using:
    \Captcha::generate($this->response); Then inside packages/captcha/classes/captcha.php Replaced: public static function generate()
    With: public static function generate($response) Replaced: \Output::set_header
    With: $response->set_header
  • Mozhete pojasnit kak polzovatsia vashym classom captcha v fuelphp.
    Readme - u vas ne zaponen.
    Prosto trudno poniat ne imeja dostatochnogo upyta.
    Pozhalujsta. :)
  • Dmitry Barko wrote on Saturday 24th of September 2011:
    Mozhete pojasnit kak polzovatsia vashym classom captcha v fuelphp.
    Readme - u vas ne zaponen.
    Prosto trudno poniat ne imeja dostatochnogo upyta.
    Pozhalujsta. :)

    Solovej, please try that I posted in previous message. And if everything will went wrong, post here and I will help you.
  • 1. I downloaded your captcha pack.
    2. I make copy 'classes\captcha.php' to .. \htdocs\fuel\core\classes\
    3. I make copy 'config\captcha.php' to.. \htdocs\fuel\core\config and ..\htdocs\fuel\app\config\
    4. I make copy of directory fonts to..htdocs\fuel\core\fonts\
    5. I make copy bootstrap.
    My bootstrap was : ..htdocs\fuel\app\bootstrap.php
    require_once COREPATH.'bootstrap.php';
    
    Autoloader::add_classes(array(
     // Add classes you want to override here
     // Example: 'View' => APPPATH.'classes/view.php',
    ));
    Autoloader::register();
    Fuel::init(include(APPPATH.'config/config.php'));
    

    Then I add to bootstrap.php
    'Captcha\\Captcha' => __DIR__.DS.'classes'.DS.'captcha.php',
    and Fuel\Core\Autoloader::add_core_namespace('Captcha'); After that I got: Fatal error: Class 'Fuel\Core\Autoloader' not found in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\fuel\app\bootstrap.php on line 5 ok, I deleted Fuel\Core\Autoloader::add_core_namespace('Captcha');
    And problem was solved.
    Then I make Controller: captcha and view. Controller:
    <?php
    class Controller_Captcha extends \Fuel\Core\Controller_Template
    &#123;
        public function before()
        &#123;
            parent::before();
        }
        public function action_index()
        &#123;
            \Captcha::generate();
        }
        public function action_register()
        &#123;
            $data = array();
            if($_POST)
            &#123;
                if(!\Captcha::check()) $data['error'][] = 'You have entered wrong chars.';
            }
            $this->template->content = \View::factory('register/index', $data); }
    }
    

    View:
    <?php if(!\Captcha::check()): ?>
    <form method="post">
        <img src="/captcha" alt="captcha" />
        <input type="text" name="keystring" />
        <button type="submit">Register</button>
    </form>
    <?php else: ?>
    <p>Thanks for registering! Now you can login to your account.</p>
    <?php endif; ?>
    
    And I got: ErrorException [ Error ]: Class 'Captcha' not found
    APPPATH/classes/controller/captcha.php @ line 10
    

    Also I added in class captcha.php : protected static $fonts_dir = C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\fuel\core\fonts\; After that I add ones again Fuel\Core\Autoloader::add_core_namespace('Captcha'); and I got Fatal error: Class 'Fuel\Core\Autoloader' not found in C:\Program Files\Apache Software Foundation\Apache2.2\htdocs\fuel\app\bootstrap.php on line 6
    What now? :)
  • Hi everyone, I've forked Mikhail's original Captcha package in an attempt to get it working with Fuel 1.0.* https://github.com/jezgomez/fuel-captcha If the package does not autoload, add the following to fuel/app/bootstrap.php:
    require_once PKGPATH.'captcha/bootstrap.php';
    

    I can get it working up to a point but not to actually output the image (see http://imageshack.us/photo/my-images/202/selection001sj.png/) . I suspect this has something to do with not sending the headers (although I've tried doing so without any joy) Please feel free to clone the repo and let me know if you fix it!
  • It returns an image, so you can't just call it in your controller, you need to specify it in the href of an <img> tag.
  • Solovej, why you copy captcha to fuel/core? You should create folder "fuel-captcha" in fuel/packages and copy all files from my github link into it (this is step 0) in my instruction ).
  • Hello FuelRussia, I wanted to ask if you have came up with smth at least at 'beta' stage, so you could share? Thank you!
  • Mikhail Khasaya wrote on Monday 26th of September 2011:
    Solovej, why you copy captcha to fuel/core? You should create folder "fuel-captcha" in fuel/packages and copy all files from my github link into it (this is step 0) in my instruction ).

    you probably mean that the folder should be just 'captcha' instead of 'fuel-captcha'
  • There is a reCaptcha package already
  • Brian Perin wrote on Tuesday 27th of September 2011:
    There is a reCaptcha package already
    I don't like reCaptcha. It has bad usability)
  • Mikhail Khasaya wrote on Monday 26th of September 2011:
    Solovej, why you copy captcha to fuel/core? You should create folder "fuel-captcha" in fuel/packages and copy all files from my github link into it (this is step 0) in my instruction ).

    Now I made step by step. But I got: ErrorException [ Error ]: Class 'Captcha\Captcha' not found
    if I'll write to config.php packages => 'captcha'
    I got:
    ErrorException [ Compile Error ]: Cannot redeclare class Autoloader What now?
  • So, your captcha package is too old.
    Now fuelphp 1.0.1 version. You are uses: \Output::set_header('Pragma', 'no-cache');
    I do not fount any classes with name \output. I found Response...
    In you bootstrap Fuel\Core\Autoloader::add_core_namespace('Captcha');
    But should be Autoloader::add_core_namespace('Captcha'); so, etc...
    Maybe you can upload newer version ? For 1.0.1 or 1.1.
    And add to readme installation info.
    Please.
  • I'm very busy now, but if you can wait for 2-3 days, I can fix my package for Fuel 1.0.1
    Dmitry Barko wrote on Thursday 29th of September 2011:
    So, your captcha package is too old.
    Now fuelphp 1.0.1 version. You are uses: \Output::set_header('Pragma', 'no-cache');
    I do not fount any classes with name \output. I found Response...
    In you bootstrap Fuel\Core\Autoloader::add_core_namespace('Captcha');
    But should be Autoloader::add_core_namespace('Captcha'); so, etc...
    Maybe you can upload newer version ? For 1.0.1 or 1.1.
    And add to readme installation info.
    Please.
  • Mikhail Khasaya wrote on Thursday 29th of September 2011:
    I'm very busy now, but if you can wait for 2-3 days, I can fix my package for Fuel 1.0.1
    Dmitry Barko wrote on Thursday 29th of September 2011:
    So, your captcha package is too old.
    Now fuelphp 1.0.1 version. You are uses: \Output::set_header('Pragma', 'no-cache');
    I do not fount any classes with name \output. I found Response...
    In you bootstrap Fuel\Core\Autoloader::add_core_namespace('Captcha');
    But should be Autoloader::add_core_namespace('Captcha');
    so, etc...
    Maybe you can upload newer version ? For 1.0.1 or 1.1.
    And add to readme installation info.
    Please.
    Ok!
    Thanks! :)
  • hello, can anyone provide a working sample of this Captcha? I am following the flow of this Captcha it seems the author did not proceed his plan 'after 2-3days' to modify. I hope he will have time and this will help the community in putting captcha in their application.
    thanks
  • Yes I have beta package here: https://github.com/dillix/fuel-captcha Using:
    0) Move downloaded code to package folder. 1) You should create captcha controller in app/classes/controllers/captcha.php:
    class Controller_Captcha extends \Controller {
     public function before()
     {
      parent::before();
     }
     public function action_index()
     {
      \Captcha::generate();
     }
    }
    

    2) In module controller:
    public function action_register()
    {
     $data = array();
      
     if($_POST)
     {
      if(!\Captcha::check()) $data['error'][] = 'You have entered wrong chars.';
     }
     $this->template->content = \View::factory('register', $data);
    }
    

    In module view:
    <?php if(!\Captcha::check()): ?>
    <form method="post">
    <img src="/captcha" alt="captcha" />
    <input type="text" name="keystring" />
    <button type="submit">Register</button>
    </form>
    <?php else: ?>
    <p>Thanks for registering! Now you can login to your account.</p>
    <?php endif; ?>
    

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion