This is the API documentation for concrete5 version 5.6 and earlier. View Current API Documentation
 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 
<?php

class Concrete5_Model_SecurimageSystemCaptchaTypeController extends SystemCaptchaTypeController {

    protected $securimage;
   
    public function __construct() {
        Loader::library("3rdparty/securimage/securimage");
        
        $this->securimage = new Securimage();
        $this->securimage->image_width   = 190;
        $this->securimage->image_height  = 60;
        $this->securimage->image_bg_color = new Securimage_Color(227, 218, 237);
        $this->securimage->line_color = new Securimage_Color(51, 51, 51);
        $this->securimage->num_lines = 5;
        
        $this->securimage->use_multi_text   = true;
        $this->securimage->multi_text_color = array(
            new Securimage_Color(184, 4, 50),
            new Securimage_Color(12, 67, 157),
            new Securimage_Color(244, 49, 11)
            );
        $this->securimage->text_color = new Securimage_Color(184, 4, 50);       
    }
    
    /** 
     * Display the captcha
     */ 
    public function display() {
      $ci = Loader::helper('concrete/urls');
      echo '<div><img src="' . $ci->getToolsURL('captcha') . '?nocache=' .time(). '" alt="' .t('Captcha Code'). '" onclick="this.src = \'' . $ci->getToolsURL('captcha') . '?nocache=\'+(new Date().getTime())" class="ccm-captcha-image" /></div>';
      echo '<br/><div>' . t('Click the image to see another captcha.') . '</div>';
    }
    
    public function label() {
        $form = Loader::helper('form');
        print $form->label('captcha', t('Please type the letters and numbers shown in the image.'));
    }
    
    
    /** 
     * Print the captcha image. You usually don't have to call this method directly.
     * It gets called by captcha.php from the tools 
     */     
    public function displayCaptchaPicture() {
       $this->securimage->show();
    }
    
    /**
     * Displays the text input field that must be entered when used with a corresponding image.
     */
    public function showInput($args = false, $forPreview = false)
    {
    $attribs = '';
        if (is_array($args)) {
            foreach($args as $key => $value) {
                $attribs .= $key . '="' . $value . '" ';
            }
        }
      echo '<div><input type="text" name="ccmCaptchaCode" class="ccm-input-captcha"'. ($forPreview === true  ? '' : ' required="required" ') . $attribs . ' /></div><br/>';
    }
    
    /** 
     * Checks the captcha code the user has entered.
     *       
     * @param string $fieldName Optional name of the field that contains the captcha code
     * @return boolean true if the code was correct, false if not
     */     
    public function check($fieldName='ccmCaptchaCode') {
       return $this->securimage->check($_REQUEST[$fieldName]);
    }


}