Skip to content

Instantly share code, notes, and snippets.

View biakaveron's full-sized avatar

Ivan Brotkin biakaveron

  • Russian Federation
View GitHub Profile
@biakaveron
biakaveron / input.php
Created June 24, 2009 13:57
input helper
<?php defined('SYSPATH') or die('No direct script access.');
class Kohana_Input {
protected static $user_agent = FALSE;
public static function get($key = NULL, $default = NULL) {
return self::find_key($_GET, $key, $default);
}
// modules/database/classes/database.php, Line 238
if (FALSE !== $dotpos = strpos($value, '.'))
{
if (substr($value, -1) == '*')
{
return $this->_identifier.substr($value, 0, $dotpos).$this->_identifier.'.*';
}
// Dots are used to separate schema, table, and column names
$value = str_replace('.', "{$this->_identifier}.{$this->_identifier}", $value);
}
/**
* Count records for a given table
*
* @param string table name
* @param array WHERE conditions
* @return int
*/
public function count_records($table = FALSE, $where = NULL)
{
$this->_select = array(array('COUNT("*")', 'records_found'));
// bootstrap.php
Route::set('artist','(sales(/<month>(/<day>)))')
->defaults(array(
'controller' => 'sales',
'action' => 'month',
));
// classes/sales.php
class Controller_Sales extends Controller {
diff --git a/classes/kohana/auth/orm.php b/classes/kohana/auth/orm.php
index dfca403..ed3a78c 100644
--- a/classes/kohana/auth/orm.php
+++ b/classes/kohana/auth/orm.php
@@ -143,11 +143,11 @@ class Kohana_Auth_ORM extends Auth {
if ($token = cookie::get('authautologin'))
{
// Load the token and user
- $token = ORM::factory('user_token', $token);
+ $token = ORM::factory('user_token', array('token' => $token));
@biakaveron
biakaveron / orm-remove.php
Created August 27, 2010 07:52
how to delete all user roles? Need ORM changes
/**
* Removes a relationship between this model and another (or delete all relationships).
*
* @param string alias of the has_many "through" relationship
* @param mixed related ORM model or NULL to clear relationship
* @return ORM
*/
public function remove($alias, ORM $model = NULL)
{
$query = DB::delete($this->_has_many[$alias]['through'])
@biakaveron
biakaveron / route.php
Created January 29, 2011 22:13
routes with prefixes and suffixes
<?php defined('SYSPATH') OR die('No direct access allowed.');
class Route extends Kohana_Route {
protected static $_prefix = array();
protected static $_suffix = array();
protected function _patch()
{
if ( ! empty(self::$_prefix))
@biakaveron
biakaveron / jelly_mptt.php
Created February 8, 2011 14:52
very draft Jelly MPTT class
<?php defined('SYSPATH') OR die('No direct access allowed.');
abstract class Jelly_Model_MPTT extends Jelly_Model {
protected static $_columns = array(
'left' => 'lft',
'right' => 'rgt',
'scope' => 'scope',
'level' => 'lvl',
'parent_id' => 'parent_id',
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* Kohana-World Exception Handler
*
* @package KW-Core
* @author Kohana-World Development Team
* @license MIT License
* @copyright 2011 Kohana-World Development Team
*/

GitHub OAuth Busy Developer's Guide

This is a quick guide to OAuth2 support in GitHub for developers. This is still experimental and could change at any moment. This Gist will serve as a living document until it becomes finalized at Develop.GitHub.com.

OAuth2 is a protocol that lets external apps request authorization to private details in your GitHub account without getting your password. All developers need to register their application before getting started.

Web Application Flow

  • Redirect to this link to request GitHub access: