Skip to content

Instantly share code, notes, and snippets.

View kemo's full-sized avatar
💭
killing it

kemo

💭
killing it
  • Sarajevo, Bosnia and Herzegovina
  • X @delalick
View GitHub Profile
Route::set('forum', 'forum/<action>')
->defaults(array(
'controller' => 'forum',
'action' => 'index',
))
->methods(array(
Request::PUT => array
(
'update_post',
<?php defined('SYSPATH') or die('No direct script access.');
/**
* User controller
* Handles login, signup, post-signup pages
*
* @author Kemal Delalic <[email protected]>
* @version 1.0.0
*/
class Controller_User extends Controller_Template {
<?php defined('SYSPATH') or die('No direct script access.');
class Text extends Kohana_Text {
public static function extract_emails($string)
{
$return = array();
if (Valid::email($string))
{
@kemo
kemo / search.php
Created May 26, 2011 13:35
Kohana Search controller example
<?php defined('SYSPATH') or die('No direct script access.');
class Controller_Search extends Controller {
/**
* @var Database_Result
*/
protected $_results;
/**
@kemo
kemo / gist:1020533
Created June 11, 2011 13:01
JSend View Model
<?php defined('SYSPATH') or die('No direct script access.');
/**
* Strict JSend response formatting
*
* @author kemo <github.com/kemo>
* @see http://labs.omniti.com/labs/jsend
*/
class View_Ajax {
// Release version
@kemo
kemo / security.php
Created June 14, 2011 11:46
Security antispam check
<?php defined('SYSPATH') or die('No direct script access.');
/**
* @author kemo <github.com/kemo>
*/
class Security extends Kohana_Security {
/**
* Logs the timed purpose to session
* @param string purpose
* @return void
@kemo
kemo / where.php
Created June 17, 2011 09:03
and_where_open() / or_where_open() auto removal example
<?php defined('SYSPATH') or die('No direct script access.');
abstract class Database_Query_Builder_Where extends Kohana_Database_Query_Builder_Where {
/**
* Closes an open "AND WHERE (...)" grouping.
*
* @return $this
*/
public function and_where_close()
@kemo
kemo / request.php
Created June 17, 2011 13:15
Request::process_uri()
<?php
/**
* Process URI
*
* @param string $uri URI
* @param array $routes Route
* @return array
*/
public static function process_uri($uri, $routes = NULL)
{
@kemo
kemo / gist:1122991
Created August 3, 2011 15:56
Kohana 3 Route Caching
<?php // bootstrap ...
// Include app routes
if ( ! Route::cache())
{
require APPPATH.'routes.php';
Route::cache(Kohana::$environment === Kohana::PRODUCTION);
}
@kemo
kemo / gd.php
Created August 7, 2011 10:26
Kohana_Image_GD with grayscale conversion
<?php defined('SYSPATH') or die('No direct script access.');
class Image_GD extends Kohana_Image_GD {
public function grayscale()
{
// Creating the Canvas
$bwimage = $this->_create($this->width, $this->height);
$this->_load_image();