<?php 
namespace App\Modules\Captcha\Controllers;
ini_set("memory_limit","512M");
error_reporting(E_ALL ^ E_NOTICE);



use App\Modules\generic\Models\Mdl_generic;

use App\Modules\Captcha\Models\Mdl_captcha;

use CodeIgniter\Controller;

class Captcha extends Controller
{
   private $db;
 protected  $viewFile;
 protected  $email;
 protected  $captcha; 
 protected  $isLogin;
 
    /**
     * Constructor.
     */
    public function __construct()
    {
        //$db = \Config\Database::connect();
        $this->Mdl_captcha = new Mdl_captcha();
        parent::__construct();
    }

   /*

	**	CREATE CAPTCHA 

	*/

	function captcha(){

        $captcha_array = array(
                'word'          => random_string('alpha', 8),
                //'word'          => random_string('numeric', 8),
                'img_path'      => './captcha/',
                'img_url'       => base_url('captcha/'),
                'font_path'     => base_url('public/font/fontawesome-webfont.ttf'), //'./path/to/fonts/texb.ttf',
                'img_width'     => '190',
                'img_height'    => '60',
                'expiration'    => '7200',
                'word_length'   => '9',
                //'word_length'   => '8',
                'font_size'     => '27',
                'img_id'        => 'Imageid',
                'pool'          => '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
                //'pool'          => '0123456789',
                // White background and border, black text and red grid
                'colors'        => array(
                        'background' => array(255, 255, 255),
                        'border' => array(255, 255, 255),
                        'text' => array(0, 70, 0),
                        'grid' => array(255, 255, 100)
                )
                );
        
                $this->session->unset_userdata('valuecaptchaCode');
                $this->session->set_userdata('valuecaptchaCode', $captcha_array['word']);
        
                $captcha = create_captcha($captcha_array);
                return $captcha['image'];
        }

}
