Code Monkey home page Code Monkey logo

kohana2-modules's Introduction

Kohana 2.x modules

reCAPTCHA

Installation and Configuration

  1. Copy "recaptcha" folder to your project/modules folder.
  2. Copy folder modules/recaptcha/config/captcha to application/config.
  3. Enable this module in application/config/config.php.
/**
 * Additional resource paths, or "modules". Each path can either be absolute
 * or relative to the docroot. Modules can include any resource that can exist
 * in your application directory, configuration files, controllers, views, etc.
 */
$config['modules'] = array
(
    ...
    MODPATH.'recaptcha',
    ...
);

Get siteKey and privateKey keys on Google reCAPTCHA and change config file application/config/captcha/recaptcha.php

/*
 * Options:
 *  theme      - reCaptcha theme, e.g. dark, light
 *  type       - reCaptcha type, e.g. audio, image
 *  size       - reCaptcha size, e.g. compact, normal
 *  siteKey    - reCaptcha sitekey for html (see more on https://developers.google.com/recaptcha/docs/display)
 *  privateKey - reCaptcha secretkey for verify (see more on https://developers.google.com/recaptcha/docs/verify)
 */
$config = array
(
    'theme'      => 'light',
    'type'       => 'image',
    'size'       => 'normal',
    'siteKey'    => '',
    'privateKey' => ''
);

Configuration is done in the application/config/captcha.php file, if it's not there take the one from system/config and copy it to the application folder.

$config['default'] = array
(
    'style'      => 'recaptcha',
    'promote'    => FALSE,
    //you can override option from application/config/captcha/recaptcha.php
    'theme'      => 'dark',
    'type'       => 'image',
    'size'       => 'normal',
    //also you can change/override standart recaptcha field name from "g-recaptcha-response"
    'field'      => 'code',
);

Usage example

The code below demonstrates how to use captcha on a form. In your controller:

class Example_Controller extends Controller
{
    public function index()
    {
        $this-> Captcha = Captcha::instance();
          
        if (empty($_POST))
        {
          return;
        }
          
        $this-> Form = Validation::factory($_POST);
        $this-> Form-> pre_filter('trim');
        $this-> Form-> add_rules('g-recaptcha-response', 'required', 'Captcha::valid');
        # or 
        #$this-> Form-> add_rules('code', 'required', 'Captcha::valid');

        if (!$this-> Form-> validate())
        {
          print_r($this-> Form-> errors('errors'));
          return;
        }
    }
}

ExtCache

Installation and Configuration

  1. Copy "extcache" folder to your project/modules folder.
  2. Copy folder modules/extcache/config/cache to application/config/cache.
  3. Enable this module in application/config/config.php
/**
 * Additional resource paths, or "modules". Each path can either be absolute
 * or relative to the docroot. Modules can include any resource that can exist
 * in your application directory, configuration files, controllers, views, etc.
 */
$config['modules'] = array
(
    ...
    MODPATH.'extcache',
    ...
);

This module provides several cache drivers:

  • Memcached (need install php-memcached extension). Config application/config/cache/memcached.php.
  • Igbinaryfile (need install php-igbinary)
  • Jsonfile
  • Msgpackfile (need install php-msgpack)
  • PHP (some reasons some times need for developers)

kohana2-modules's People

Contributors

paramonovav avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.