hellope

Controller (Captcha)

Jan 8th, 2017
2,537
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.14 KB | None | 0 0
  1. <?php defined('BASEPATH') OR exit('No direct script access allowed');
  2. class Cpanel extends CI_Controller {
  3.   function __construct(){
  4.     parent::__construct();
  5.   }
  6.  
  7.   function index(){
  8.     $options = array(
  9.         'img_path'=>'./captcha/', #folder captcha yg sudah dibuat tadi
  10.         'img_url'=>base_url('captcha'), #ini arahnya juga ke folder captcha
  11.         'img_width'=>'145', #lebar image captcha
  12.         'img_height'=>'45', #tinggi image captcha
  13.         'expiration'=>7200, #waktu expired
  14.         'font_path' => FCPATH . 'assets/font/coolvetica.ttf', #load font jika mau ganti fontnya
  15.         'pool' => '0123456789', #tipe captcha (angka/huruf, atau kombinasi dari keduanya)
  16.  
  17.         # atur warna captcha-nya di sini ya.. gunakan kode RGB
  18.         'colors' => array(
  19.                 'background' => array(242, 242, 242),
  20.                 'border' => array(255, 255, 255),
  21.                 'text' => array(0, 0, 0),
  22.                 'grid' => array(255, 40, 40))
  23.            );
  24.     $cap = create_captcha($options);
  25.     $data['image'] = $cap['image'];
  26.     $this->session->set_userdata('mycaptcha', $cap['word']);
  27.     $data['word'] = $this->session->userdata('mycaptcha');
  28.     $this->load->view('loginView',$data);
  29.   }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment