Kohana v3.3.2

This commit is contained in:
Deon George
2014-09-06 23:43:07 +10:00
parent f96694b18f
commit 8888719653
236 changed files with 1685 additions and 996 deletions

View File

@@ -207,8 +207,13 @@ class Kohana_Arr {
$delimiter = Arr::$delimiter;
}
// Split the keys by delimiter
$keys = explode($delimiter, $path);
// The path has already been separated into keys
$keys = $path;
if ( ! is_array($path))
{
// Split the keys by delimiter
$keys = explode($delimiter, $path);
}
// Set current $array to inner-most array path
while (count($keys) > 1)
@@ -283,7 +288,7 @@ class Kohana_Arr {
*
* // Get the values "username", "password" from $_POST
* $auth = Arr::extract($_POST, array('username', 'password'));
*
*
* // Get the value "level1.level2a" from $data
* $data = array('level1' => array('level2a' => 'value 1', 'level2b' => 'value 2'));
* Arr::extract($data, array('level1.level2a', 'password'));
@@ -617,4 +622,4 @@ class Kohana_Arr {
return $flat;
}
} // End arr
}

View File

@@ -3,7 +3,7 @@
* Wrapper for configuration arrays. Multiple configuration readers can be
* attached to allow loading configuration from files, database, etc.
*
* Configuration directives cascade across config sources in the same way that
* Configuration directives cascade across config sources in the same way that
* files cascade across the filesystem.
*
* Directives from sources high in the sources list will override ones from those
@@ -74,9 +74,9 @@ class Kohana_Config {
}
/**
* Load a configuration group. Searches all the config sources, merging all the
* directives found into a single config group. Any changes made to the config
* in this group will be mirrored across all writable sources.
* Load a configuration group. Searches all the config sources, merging all the
* directives found into a single config group. Any changes made to the config
* in this group will be mirrored across all writable sources.
*
* $array = $config->load($name);
*
@@ -146,7 +146,7 @@ class Kohana_Config {
/**
* Copy one configuration group to all of the other writers.
*
*
* $config->copy($name);
*
* @param string $group configuration group name
@@ -181,7 +181,7 @@ class Kohana_Config {
{
continue;
}
// Copy each value in the config
$source->write($group, $key, $value);
}
@@ -189,4 +189,4 @@ class Kohana_Config {
return $this;
}
} // End Kohana_Config
}

View File

@@ -9,7 +9,7 @@
* @copyright (c) 2009-2012 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_Config_File extends Kohana_Config_File_Reader
class Kohana_Config_File extends Kohana_Config_File_Reader
{
// @see Kohana_Config_File_Reader
}

View File

@@ -1,4 +1,4 @@
<?php
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* File-based configuration reader. Multiple configuration directories can be
* used by attaching multiple instances of this class to [Kohana_Config].
@@ -53,4 +53,4 @@ class Kohana_Config_File_Reader implements Kohana_Config_Reader {
return $config;
}
} // End Kohana_Config
}

View File

@@ -4,15 +4,15 @@
* The group wrapper acts as an interface to all the config directives
* gathered from across the system.
*
* This is the object returned from Kohana_Config::load
* This is the object returned from Kohana_Config::load
*
* Any modifications to configuration items should be done through an instance of this object
*
* @package Kohana
* @category Configuration
* @author Kohana Team
* @copyright (c) 2012 Kohana Team
* @license http://kohanaphp.com/license
* @copyright (c) 2012-2014 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_Config_Group extends ArrayObject {
@@ -31,7 +31,7 @@ class Kohana_Config_Group extends ArrayObject {
protected $_group_name = '';
/**
* Constructs the group object. Kohana_Config passes the config group
* Constructs the group object. Kohana_Config passes the config group
* and its config items to the object here.
*
* @param Kohana_Config $instance "Owning" instance of Kohana_Config
@@ -77,7 +77,7 @@ class Kohana_Config_Group extends ArrayObject {
{
return $this->_group_name;
}
/**
* Get a variable from the configuration or return the default value.
*
@@ -110,7 +110,7 @@ class Kohana_Config_Group extends ArrayObject {
/**
* Overrides ArrayObject::offsetSet()
* This method is called when config is changed via
* This method is called when config is changed via
*
* $config->var = 'asd';
*
@@ -127,4 +127,5 @@ class Kohana_Config_Group extends ArrayObject {
return parent::offsetSet($key, $value);
}
}

View File

@@ -11,9 +11,9 @@
*/
interface Kohana_Config_Reader extends Kohana_Config_Source
{
/**
* Tries to load the specificed configuration group
* Tries to load the specified configuration group
*
* Returns FALSE if group does not exist or an array if it does
*
@@ -21,5 +21,5 @@ interface Kohana_Config_Reader extends Kohana_Config_Source
* @return boolean|array
*/
public function load($group);
}

View File

@@ -7,8 +7,8 @@
* @package Kohana
* @category Configuration
* @author Kohana Team
* @copyright (c) 2012 Kohana Team
* @license http://kohanaphp.com/license
* @copyright (c) 2012-2014 Kohana Team
* @license http://kohanaframework.org/license
*/
interface Kohana_Config_Source {}

View File

@@ -3,19 +3,19 @@
/**
* Interface for config writers
*
* Specifies the methods that a config writer must implement
*
* Specifies the methods that a config writer must implement
*
* @package Kohana
* @author Kohana Team
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaphp.com/license
* @copyright (c) 2008-2014 Kohana Team
* @license http://kohanaframework.org/license
*/
interface Kohana_Config_Writer extends Kohana_Config_Source
{
/**
* Writes the passed config for $group
*
* Returns chainable instance on success or throws
* Returns chainable instance on success or throws
* Kohana_Config_Exception on failure
*
* @param string $group The config group
@@ -24,4 +24,5 @@ interface Kohana_Config_Writer extends Kohana_Config_Source
* @return boolean
*/
public function write($group, $key, $config);
}

View File

@@ -51,15 +51,15 @@ abstract class Kohana_Controller {
/**
* Executes the given action and calls the [Controller::before] and [Controller::after] methods.
*
*
* Can also be used to catch exceptions from actions in a single place.
*
*
* 1. Before the controller action is called, the [Controller::before] method
* will be called.
* 2. Next the controller action will be called.
* 3. After the controller action is called, the [Controller::after] method
* will be called.
*
*
* @throws HTTP_Exception_404
* @return Response
*/
@@ -105,7 +105,7 @@ abstract class Kohana_Controller {
* Automatically executed after the controller action. Can be used to apply
* transformation to the response, add extra output, and execute
* other custom code.
*
*
* @return void
*/
public function after()
@@ -124,16 +124,16 @@ abstract class Kohana_Controller {
*/
public static function redirect($uri = '', $code = 302)
{
return HTTP::redirect($uri, $code);
return HTTP::redirect( (string) $uri, $code);
}
/**
* Checks the browser cache to see the response needs to be returned,
* execution will halt and a 304 Not Modified will be sent if the
* browser cache is up to date.
*
*
* $this->check_cache(sha1($content));
*
*
* @param string $etag Resource Etag
* @return Response
*/
@@ -142,4 +142,4 @@ abstract class Kohana_Controller {
return HTTP::check_cache($this->request, $this->response, $etag);
}
} // End Controller
}

View File

@@ -47,4 +47,4 @@ abstract class Kohana_Controller_Template extends Controller {
parent::after();
}
} // End Controller_Template
}

View File

@@ -124,7 +124,6 @@ class Kohana_Cookie {
*
* @param string $name cookie name
* @return boolean
* @uses Cookie::set
*/
public static function delete($name)
{
@@ -149,7 +148,7 @@ class Kohana_Cookie {
// Require a valid salt
if ( ! Cookie::$salt)
{
throw new Kohana_Exception('A valid cookie salt is required. Please set Cookie::$salt.');
throw new Kohana_Exception('A valid cookie salt is required. Please set Cookie::$salt in your bootstrap.php. For more information check the documentation');
}
// Determine the user agent
@@ -158,4 +157,4 @@ class Kohana_Cookie {
return sha1($agent.$name.$value.Cookie::$salt);
}
} // End cookie
}

View File

@@ -16,8 +16,8 @@
class Kohana_Core {
// Release version and codename
const VERSION = '3.3.0';
const CODENAME = 'badius';
const VERSION = '3.3.1';
const CODENAME = 'peregrinus';
// Common environment type constants for consistency and convenience
const PRODUCTION = 10;
@@ -383,7 +383,7 @@ class Kohana_Core {
/**
* Reverts the effects of the `register_globals` PHP setting by unsetting
* all global varibles except for the default super globals (GPCS, etc),
* all global variables except for the default super globals (GPCS, etc),
* which is a [potential security hole.][ref-wikibooks]
*
* This is called automatically by [Kohana::init] if `register_globals` is
@@ -521,7 +521,7 @@ class Kohana_Core {
/**
* Provides auto-loading support of classes that follow Kohana's old class
* naming conventions.
*
*
* This is included for compatibility purposes with older modules.
*
* @param string $class Class name
@@ -927,7 +927,7 @@ class Kohana_Core {
}
/**
* Get a message from a file. Messages are arbitary strings that are stored
* Get a message from a file. Messages are arbitrary strings that are stored
* in the `messages/` directory and reference by a key. Translation is not
* performed on the returned values. See [message files](kohana/files/messages)
* for more information.
@@ -1037,7 +1037,7 @@ class Kohana_Core {
/**
* Generates a version string based on the variables defined above.
*
*
* @return string
*/
public static function version()
@@ -1045,4 +1045,4 @@ class Kohana_Core {
return 'Kohana Framework '.Kohana::VERSION.' ('.Kohana::CODENAME.')';
}
} // End Kohana
}

View File

@@ -600,4 +600,4 @@ class Kohana_Date {
return $time->format($timestamp_format);
}
} // End date
}

View File

@@ -5,8 +5,8 @@
* @package Kohana
* @category Base
* @author Kohana Team
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaphp.com/license
* @copyright (c) 2008-2014 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_Debug {

View File

@@ -210,4 +210,4 @@ class Kohana_Encrypt {
return rtrim(mcrypt_decrypt($this->_cipher, $this->_key, $data, $this->_mode, $iv), "\0");
}
} // End Encrypt
}

View File

@@ -182,4 +182,4 @@ class Kohana_Feed {
return $feed;
}
} // End Feed
}

View File

@@ -163,16 +163,16 @@ class Kohana_File {
// Write files in 8k blocks
$block_size = 1024 * 8;
// Total number of peices
$peices = 0;
// Total number of pieces
$pieces = 0;
while ( ! feof($file))
{
// Create another piece
$peices += 1;
$pieces += 1;
// Create a new file piece
$piece = str_pad($peices, 3, '0', STR_PAD_LEFT);
$piece = str_pad($pieces, 3, '0', STR_PAD_LEFT);
$piece = fopen($filename.'.'.$piece, 'wb+');
// Number of bytes read
@@ -195,7 +195,7 @@ class Kohana_File {
// Close the file
fclose($file);
return $peices;
return $pieces;
}
/**
@@ -214,7 +214,7 @@ class Kohana_File {
// Read files in 8k blocks
$block_size = 1024 * 8;
// Total number of peices
// Total number of pieces
$pieces = 0;
while (is_file($piece = $filename.'.'.str_pad($pieces + 1, 3, '0', STR_PAD_LEFT)))
@@ -231,11 +231,11 @@ class Kohana_File {
fwrite($file, fread($piece, $block_size));
}
// Close the peice
// Close the piece
fclose($piece);
}
return $pieces;
}
} // End file
}

View File

@@ -2,7 +2,7 @@
/**
* Form helper class. Unless otherwise noted, all generated HTML will be made
* safe using the [HTML::chars] method. This prevents against simple XSS
* attacks that could otherwise be trigged by inserting HTML characters into
* attacks that could otherwise be triggered by inserting HTML characters into
* form fields.
*
* @package Kohana
@@ -431,4 +431,4 @@ class Kohana_Form {
return '<label'.HTML::attributes($attributes).'>'.$text.'</label>';
}
} // End form
}

View File

@@ -144,4 +144,4 @@ class Kohana_Fragment {
Kohana::cache(Fragment::_cache_key($name, $i18n), NULL, -3600);
}
} // End Fragment
}

View File

@@ -342,4 +342,4 @@ class Kohana_HTML {
return $compiled;
}
} // End html
}

View File

@@ -11,8 +11,8 @@
* @category HTTP
* @author Kohana Team
* @since 3.1.0
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaphp.com/license
* @copyright (c) 2008-2014 Kohana Team
* @license http://kohanaframework.org/license
*/
abstract class Kohana_HTTP {
@@ -44,7 +44,7 @@ abstract class Kohana_HTTP {
* Checks the browser cache to see the response needs to be returned,
* execution will halt and a 304 Not Modified will be sent if the
* browser cache is up to date.
*
*
* @param Request $request Request
* @param Response $response Response
* @param string $etag Resource ETag
@@ -214,4 +214,5 @@ abstract class Kohana_HTTP {
return implode('&', $encoded);
}
} // End Kohana_HTTP
}

View File

@@ -4,7 +4,7 @@ abstract class Kohana_HTTP_Exception extends Kohana_Exception {
/**
* Creates an HTTP_Exception of the specified type.
*
*
* @param integer $code the http status code
* @param string $message status message, custom content to display with error
* @param array $variables translation variables
@@ -13,7 +13,7 @@ abstract class Kohana_HTTP_Exception extends Kohana_Exception {
public static function factory($code, $message = NULL, array $variables = NULL, Exception $previous = NULL)
{
$class = 'HTTP_Exception_'.$code;
return new $class($message, $variables, $previous);
}
@@ -44,15 +44,15 @@ abstract class Kohana_HTTP_Exception extends Kohana_Exception {
/**
* Store the Request that triggered this exception.
*
*
* @param Request $request Request object that triggered this exception.
* @return Response
* @return HTTP_Exception
*/
public function request(Request $request = NULL)
{
if ($request === NULL)
return $this->_request;
$this->_request = $request;
return $this;
@@ -60,7 +60,7 @@ abstract class Kohana_HTTP_Exception extends Kohana_Exception {
/**
* Generate a Response for the current Exception
*
*
* @uses Kohana_Exception::response()
* @return Response
*/
@@ -69,4 +69,4 @@ abstract class Kohana_HTTP_Exception extends Kohana_Exception {
return Kohana_Exception::response($this);
}
} // End Kohana_HTTP_Exception
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_300 extends HTTP_Exception_Redirect {
*/
protected $_code = 300;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_301 extends HTTP_Exception_Redirect {
*/
protected $_code = 301;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_302 extends HTTP_Exception_Redirect {
*/
protected $_code = 302;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_303 extends HTTP_Exception_Redirect {
*/
protected $_code = 303;
}
}

View File

@@ -6,5 +6,5 @@ class Kohana_HTTP_Exception_304 extends HTTP_Exception_Expected {
* @var integer HTTP 304 Not Modified
*/
protected $_code = 304;
}
}

View File

@@ -9,7 +9,7 @@ class Kohana_HTTP_Exception_305 extends HTTP_Exception_Expected {
/**
* Specifies the proxy to replay this request via
*
*
* @param string $location URI of the proxy
*/
public function location($uri = NULL)
@@ -24,7 +24,7 @@ class Kohana_HTTP_Exception_305 extends HTTP_Exception_Expected {
/**
* Validate this exception contains everything needed to continue.
*
*
* @throws Kohana_Exception
* @return bool
*/
@@ -38,4 +38,5 @@ class Kohana_HTTP_Exception_305 extends HTTP_Exception_Expected {
return TRUE;
}
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_307 extends HTTP_Exception_Redirect {
*/
protected $_code = 307;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_400 extends HTTP_Exception {
*/
protected $_code = 400;
}
}

View File

@@ -9,14 +9,14 @@ class Kohana_HTTP_Exception_401 extends HTTP_Exception_Expected {
/**
* Specifies the WWW-Authenticate challenge.
*
*
* @param string $challenge WWW-Authenticate challenge (eg `Basic realm="Control Panel"`)
*/
public function authenticate($challenge = NULL)
{
if ($challenge === NULL)
return $this->headers('www-authenticate');
$this->headers('www-authenticate', $challenge);
return $this;
@@ -24,7 +24,7 @@ class Kohana_HTTP_Exception_401 extends HTTP_Exception_Expected {
/**
* Validate this exception contains everything needed to continue.
*
*
* @throws Kohana_Exception
* @return bool
*/
@@ -35,4 +35,5 @@ class Kohana_HTTP_Exception_401 extends HTTP_Exception_Expected {
return TRUE;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_402 extends HTTP_Exception {
*/
protected $_code = 402;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_403 extends HTTP_Exception {
*/
protected $_code = 403;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_404 extends HTTP_Exception {
*/
protected $_code = 404;
}
}

View File

@@ -9,7 +9,7 @@ class Kohana_HTTP_Exception_405 extends HTTP_Exception_Expected {
/**
* Specifies the list of allowed HTTP methods
*
*
* @param array $methods List of allowed methods
*/
public function allowed($methods)
@@ -26,7 +26,7 @@ class Kohana_HTTP_Exception_405 extends HTTP_Exception_Expected {
/**
* Validate this exception contains everything needed to continue.
*
*
* @throws Kohana_Exception
* @return bool
*/
@@ -38,4 +38,4 @@ class Kohana_HTTP_Exception_405 extends HTTP_Exception_Expected {
return TRUE;
}
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_406 extends HTTP_Exception {
*/
protected $_code = 406;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_407 extends HTTP_Exception {
*/
protected $_code = 407;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_408 extends HTTP_Exception {
*/
protected $_code = 408;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_409 extends HTTP_Exception {
*/
protected $_code = 409;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_410 extends HTTP_Exception {
*/
protected $_code = 410;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_411 extends HTTP_Exception {
*/
protected $_code = 411;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_412 extends HTTP_Exception {
*/
protected $_code = 412;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_413 extends HTTP_Exception {
*/
protected $_code = 413;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_414 extends HTTP_Exception {
*/
protected $_code = 414;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_415 extends HTTP_Exception {
*/
protected $_code = 415;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_416 extends HTTP_Exception {
*/
protected $_code = 416;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_417 extends HTTP_Exception {
*/
protected $_code = 417;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_500 extends HTTP_Exception {
*/
protected $_code = 500;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_501 extends HTTP_Exception {
*/
protected $_code = 501;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_502 extends HTTP_Exception {
*/
protected $_code = 502;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_503 extends HTTP_Exception {
*/
protected $_code = 503;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_504 extends HTTP_Exception {
*/
protected $_code = 504;
}
}

View File

@@ -7,4 +7,4 @@ class Kohana_HTTP_Exception_505 extends HTTP_Exception {
*/
protected $_code = 505;
}
}

View File

@@ -1,8 +1,8 @@
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* "Expected" HTTP exception class. Used for all [HTTP_Exception]'s where a standard
* Kohana error page should never be shown.
*
* Kohana error page should never be shown.
*
* Eg [HTTP_Exception_301], [HTTP_Exception_302] etc
*
* @package Kohana
@@ -39,7 +39,7 @@ abstract class Kohana_HTTP_Exception_Expected extends HTTP_Exception {
/**
* Gets and sets headers to the [Response].
*
*
* @see [Response::headers]
* @param mixed $key
* @param string $value
@@ -57,7 +57,7 @@ abstract class Kohana_HTTP_Exception_Expected extends HTTP_Exception {
/**
* Validate this exception contains everything needed to continue.
*
*
* @throws Kohana_Exception
* @return bool
*/
@@ -68,7 +68,7 @@ abstract class Kohana_HTTP_Exception_Expected extends HTTP_Exception {
/**
* Generate a Response for the current Exception
*
*
* @uses Kohana_Exception::response()
* @return Response
*/
@@ -79,4 +79,4 @@ abstract class Kohana_HTTP_Exception_Expected extends HTTP_Exception {
return $this->_response;
}
} // End Kohana_HTTP_Exception
}

View File

@@ -2,7 +2,7 @@
/**
* Redirect HTTP exception class. Used for all [HTTP_Exception]'s where the status
* code indicates a redirect.
*
*
* Eg [HTTP_Exception_301], [HTTP_Exception_302] and most of the other 30x's
*
* @package Kohana
@@ -15,14 +15,14 @@ abstract class Kohana_HTTP_Exception_Redirect extends HTTP_Exception_Expected {
/**
* Specifies the URI to redirect to.
*
*
* @param string $location URI of the proxy
*/
public function location($uri = NULL)
{
if ($uri === NULL)
return $this->headers('Location');
if (strpos($uri, '://') === FALSE)
{
// Make the URI into a URL
@@ -36,7 +36,7 @@ abstract class Kohana_HTTP_Exception_Redirect extends HTTP_Exception_Expected {
/**
* Validate this exception contains everything needed to continue.
*
*
* @throws Kohana_Exception
* @return bool
*/
@@ -48,4 +48,4 @@ abstract class Kohana_HTTP_Exception_Redirect extends HTTP_Exception_Expected {
return TRUE;
}
} // End Kohana_HTTP_Exception_Redirect
}

View File

@@ -9,8 +9,8 @@
* @category HTTP
* @author Kohana Team
* @since 3.1.0
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaphp.com/license
* @copyright (c) 2008-2014 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_HTTP_Header extends ArrayObject {
@@ -287,7 +287,7 @@ class Kohana_HTTP_Header extends ArrayObject {
* @param int $flags Flags
* @param string $iterator_class The iterator class to use
*/
public function __construct(array $input = array(), $flags = NULL, $iterator_class = 'ArrayIterator')
public function __construct(array $input = array(), $flags = 0, $iterator_class = 'ArrayIterator')
{
/**
* @link http://www.w3.org/Protocols/rfc2616/rfc2616.html
@@ -859,12 +859,6 @@ class Kohana_HTTP_Header extends ArrayObject {
*/
public function send_headers(HTTP_Response $response = NULL, $replace = FALSE, $callback = NULL)
{
if ($response === NULL)
{
// Default to the initial request message
$response = Request::initial()->response();
}
$protocol = $response->protocol();
$status = $response->status();
@@ -946,4 +940,4 @@ class Kohana_HTTP_Header extends ArrayObject {
return $this;
}
} // End Kohana_HTTP_Header
}

View File

@@ -7,8 +7,8 @@
* @category HTTP
* @author Kohana Team
* @since 3.1.0
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaphp.com/license
* @copyright (c) 2008-2014 Kohana Team
* @license http://kohanaframework.org/license
*/
interface Kohana_HTTP_Message {
@@ -53,4 +53,5 @@ interface Kohana_HTTP_Message {
* @return string
*/
public function render();
}
}

View File

@@ -8,8 +8,8 @@
* @category HTTP
* @author Kohana Team
* @since 3.1.0
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaphp.com/license
* @copyright (c) 2008-2014 Kohana Team
* @license http://kohanaframework.org/license
*/
interface Kohana_HTTP_Request extends HTTP_Message {
@@ -61,4 +61,4 @@ interface Kohana_HTTP_Request extends HTTP_Message {
*/
public function post($key = NULL, $value = NULL);
}
}

View File

@@ -1,6 +1,6 @@
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* A HTTP Reponse specific interface that adds the methods required
* A HTTP Response specific interface that adds the methods required
* by HTTP responses. Over and above [Kohana_HTTP_Interaction], this
* interface provides status.
*
@@ -8,8 +8,8 @@
* @category HTTP
* @author Kohana Team
* @since 3.1.0
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaphp.com/license
* @copyright (c) 2008-2014 Kohana Team
* @license http://kohanaframework.org/license
*/
interface Kohana_HTTP_Response extends HTTP_Message {
@@ -28,4 +28,4 @@ interface Kohana_HTTP_Response extends HTTP_Message {
*/
public function status($code = NULL);
}
}

View File

@@ -134,7 +134,7 @@ class Kohana_I18n {
return I18n::$_cache[$lang] = $table;
}
} // End I18n
}
if ( ! function_exists('__'))
{
@@ -145,7 +145,7 @@ if ( ! function_exists('__'))
* __('Welcome back, :user', array(':user' => $username));
*
* [!!] The target language is defined by [I18n::$lang].
*
*
* @uses I18n::get
* @param string $string text to translate
* @param array $values values to replace in the translated text

View File

@@ -70,7 +70,7 @@ class Kohana_Inflector {
*
* [!!] Special inflections are defined in `config/inflector.php`.
*
* @param string $str word to singularize
* @param string $str word to make singular
* @param integer $count count of thing
* @return string
* @uses Inflector::uncountable
@@ -183,6 +183,10 @@ class Kohana_Inflector {
{
$str = Inflector::$irregular[$str];
}
elseif (in_array($str, Inflector::$irregular))
{
// Do nothing
}
elseif (preg_match('/[sxz]$/', $str) OR preg_match('/[^aeioudgkprt]h$/', $str))
{
$str .= 'es';
@@ -197,7 +201,7 @@ class Kohana_Inflector {
$str .= 's';
}
// Convert to uppsecase if nessasary
// Convert to uppercase if necessary
if ($is_uppercase)
{
$str = strtoupper($str);
@@ -266,4 +270,4 @@ class Kohana_Inflector {
return preg_replace('/[_-]+/', ' ', trim($str));
}
} // End Inflector
}

View File

@@ -1,4 +1,4 @@
<?php defined('SYSPATH') OR die('No direct access');
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* Kohana exception class. Translates exceptions using the [I18n] class.
*
@@ -79,7 +79,7 @@ class Kohana_Kohana_Exception extends Exception {
*
* @uses Kohana_Exception::response
* @param Exception $e
* @return boolean
* @return void
*/
public static function handler(Exception $e)
{
@@ -97,7 +97,7 @@ class Kohana_Kohana_Exception extends Exception {
*
* @uses Kohana_Exception::response
* @param Exception $e
* @return boolean
* @return Response
*/
public static function _handler(Exception $e)
{
@@ -185,12 +185,6 @@ class Kohana_Kohana_Exception extends Exception {
$line = $e->getLine();
$trace = $e->getTrace();
if ( ! headers_sent())
{
// Make sure the proper http header is sent
$http_header_status = ($e instanceof HTTP_Exception) ? $code : 500;
}
/**
* HTTP_Exceptions are constructed in the HTTP_Exception::factory()
* method. We need to remove that entry from the trace and overwrite
@@ -230,7 +224,7 @@ class Kohana_Kohana_Exception extends Exception {
}
}
}
if (isset(Kohana_Exception::$php_errors[$code]))
{
// Use the human-readable error name
@@ -251,13 +245,13 @@ class Kohana_Kohana_Exception extends Exception {
// Instantiate the error view.
$view = View::factory(Kohana_Exception::$error_view, get_defined_vars());
// Prepare the response object.
$response = Response::factory();
// Set the response status
$response->status(($e instanceof HTTP_Exception) ? $e->getCode() : 500);
// Set the response headers
$response->headers('Content-Type', Kohana_Exception::$error_view_content_type.'; charset='.Kohana::$charset);
@@ -279,4 +273,4 @@ class Kohana_Kohana_Exception extends Exception {
return $response;
}
} // End Kohana_Exception
}

View File

@@ -80,7 +80,7 @@ class Kohana_Log {
{
$levels = range($min_level, $levels);
}
$this->_writers["{$writer}"] = array
(
'object' => $writer,
@@ -225,4 +225,4 @@ class Kohana_Log {
}
}
} // End Kohana_Log
}

View File

@@ -91,4 +91,4 @@ class Kohana_Log_File extends Log_Writer {
}
}
} // End Kohana_Log_File
}

View File

@@ -5,8 +5,8 @@
* @package Kohana
* @category Logging
* @author Kohana Team
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaphp.com/license
* @copyright (c) 2008-2014 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_Log_StdErr extends Log_Writer {
/**
@@ -26,4 +26,4 @@ class Kohana_Log_StdErr extends Log_Writer {
}
}
} // End Kohana_Log_StdErr
}

View File

@@ -5,8 +5,8 @@
* @package Kohana
* @category Logging
* @author Kohana Team
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaphp.com/license
* @copyright (c) 2008-2014 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_Log_StdOut extends Log_Writer {
@@ -27,4 +27,4 @@ class Kohana_Log_StdOut extends Log_Writer {
}
}
} // End Kohana_Log_StdOut
}

View File

@@ -62,4 +62,4 @@ class Kohana_Log_Syslog extends Log_Writer {
closelog();
}
} // End Kohana_Log_Syslog
}

View File

@@ -12,21 +12,21 @@ abstract class Kohana_Log_Writer {
/**
* @var string timestamp format for log entries.
*
*
* Defaults to Date::$timestamp_format
*/
public static $timestamp;
/**
* @var string timezone for log entries
*
*
* Defaults to Date::$timezone, which defaults to date_default_timezone_get()
*/
public static $timezone;
/**
* Numeric log level to string lookup table.
* @var array
* @var array
*/
protected $_log_levels = array(
LOG_EMERG => 'EMERGENCY',
@@ -68,7 +68,7 @@ abstract class Kohana_Log_Writer {
/**
* Formats a log entry.
*
*
* @param array $message
* @param string $format
* @return string
@@ -78,7 +78,7 @@ abstract class Kohana_Log_Writer {
$message['time'] = Date::formatted_time('@'.$message['time'], Log_Writer::$timestamp, Log_Writer::$timezone, TRUE);
$message['level'] = $this->_log_levels[$message['level']];
$string = strtr($format, $message);
$string = strtr($format, array_filter($message, 'is_scalar'));
if (isset($message['additional']['exception']))
{
@@ -86,10 +86,10 @@ abstract class Kohana_Log_Writer {
$message['body'] = $message['additional']['exception']->getTraceAsString();
$message['level'] = $this->_log_levels[Log_Writer::$strace_level];
$string .= PHP_EOL.strtr($format, $message);
$string .= PHP_EOL.strtr($format, array_filter($message, 'is_scalar'));
}
return $string;
}
} // End Kohana_Log_Writer
}

View File

@@ -26,4 +26,4 @@ abstract class Kohana_Model {
return new $class;
}
} // End Model
}

View File

@@ -231,4 +231,4 @@ class Kohana_Num {
return $bytes;
}
} // End num
}

View File

@@ -14,7 +14,7 @@
class Kohana_Profiler {
/**
* @var integer maximium number of application stats to keep
* @var integer maximum number of application stats to keep
*/
public static $rollover = 1000;
@@ -382,4 +382,4 @@ class Kohana_Profiler {
return $stats;
}
} // End Profiler
}

View File

@@ -59,14 +59,7 @@ class Kohana_Request implements HTTP_Request {
// If this is the initial request
if ( ! Request::$initial)
{
if (isset($_SERVER['SERVER_PROTOCOL']))
{
$protocol = $_SERVER['SERVER_PROTOCOL'];
}
else
{
$protocol = HTTP::$protocol;
}
$protocol = HTTP::$protocol;
if (isset($_SERVER['REQUEST_METHOD']))
{
@@ -79,7 +72,10 @@ class Kohana_Request implements HTTP_Request {
$method = HTTP_Request::GET;
}
if ( ! empty($_SERVER['HTTPS']) AND filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN))
if (( ! empty($_SERVER['HTTPS']) AND filter_var($_SERVER['HTTPS'], FILTER_VALIDATE_BOOLEAN))
OR (isset($_SERVER['HTTP_X_FORWARDED_PROTO'])
AND $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
AND in_array($_SERVER['REMOTE_ADDR'], Request::$trusted_proxies))
{
// This request is secure
$secure = TRUE;
@@ -1223,7 +1219,8 @@ class Kohana_Request implements HTTP_Request {
}
else
{
$this->headers('content-type', 'application/x-www-form-urlencoded');
$this->headers('content-type',
'application/x-www-form-urlencoded; charset='.Kohana::$charset);
$body = http_build_query($post, NULL, '&');
}
@@ -1328,4 +1325,4 @@ class Kohana_Request implements HTTP_Request {
return $this;
}
} // End Request
}

View File

@@ -105,8 +105,8 @@ abstract class Kohana_Request_Client {
':depth' => $this->callback_depth() - 1,
));
// Execute the request
$orig_response = $response = Response::factory();
// Execute the request and pass the currently used protocol
$orig_response = $response = Response::factory(array('_protocol' => $request->protocol()));
if (($cache = $this->cache()) instanceof HTTP_Cache)
return $cache->execute($this, $request, $response);
@@ -405,10 +405,13 @@ abstract class Kohana_Request_Client {
break;
}
// Prepare the additional request
// Prepare the additional request, copying any follow_headers that were present on the original request
$orig_headers = $request->headers()->getArrayCopy();
$follow_headers = array_intersect_assoc($orig_headers, array_fill_keys($client->follow_headers(), TRUE));
$follow_request = Request::factory($response->headers('Location'))
->method($follow_method)
->headers(Arr::extract($request->headers(), $client->follow_headers()));
->headers($follow_headers);
if ($follow_method !== Request::GET)
{
@@ -421,4 +424,4 @@ abstract class Kohana_Request_Client {
return NULL;
}
}
}

View File

@@ -2,7 +2,7 @@
/**
* [Request_Client_External] Curl driver performs external requests using the
* php-curl extention. This is the default driver for all external requests.
*
*
* @package Kohana
* @category Base
* @author Kohana Team
@@ -63,7 +63,7 @@ class Kohana_Request_Client_Curl extends Request_Client_External {
$this->_options[CURLOPT_RETURNTRANSFER] = TRUE;
$this->_options[CURLOPT_HEADER] = FALSE;
// Apply any additional options set to
// Apply any additional options set to
$options += $this->_options;
$uri = $request->uri();
@@ -110,8 +110,9 @@ class Kohana_Request_Client_Curl extends Request_Client_External {
}
/**
* Sets the appropriate curl request options. Uses the responding options
* for POST and PUT, uses CURLOPT_CUSTOMREQUEST otherwise
* Sets the appropriate curl request options. Uses the responding option
* for POST or CURLOPT_CUSTOMREQUEST otherwise
*
* @param Request $request
* @param array $options
* @return array
@@ -122,9 +123,6 @@ class Kohana_Request_Client_Curl extends Request_Client_External {
case Request::POST:
$options[CURLOPT_POST] = TRUE;
break;
case Request::PUT:
$options[CURLOPT_PUT] = TRUE;
break;
default:
$options[CURLOPT_CUSTOMREQUEST] = $request->method();
break;
@@ -132,4 +130,4 @@ class Kohana_Request_Client_Curl extends Request_Client_External {
return $options;
}
} // End Kohana_Request_Client_Curl
}

View File

@@ -3,25 +3,25 @@
* [Request_Client_External] provides a wrapper for all external request
* processing. This class should be extended by all drivers handling external
* requests.
*
*
* Supported out of the box:
* - Curl (default)
* - PECL HTTP
* - Streams
*
*
* To select a specific external driver to use as the default driver, set the
* following property within the Application bootstrap. Alternatively, the
* client can be injected into the request object.
*
*
* @example
*
*
* // In application bootstrap
* Request_Client_External::$client = 'Request_Client_Stream';
*
*
* // Add client to request
* $request = Request::factory('http://some.host.tld/foo/bar')
* ->client(Request_Client_External::factory('Request_Client_HTTP));
*
*
* @package Kohana
* @category Base
* @author Kohana Team
@@ -36,7 +36,7 @@ abstract class Kohana_Request_Client_External extends Request_Client {
* - Request_Client_Curl (default)
* - Request_Client_HTTP
* - Request_Client_Stream
*
*
* @var string defines the external client to use by default
*/
public static $client = 'Request_Client_Curl';
@@ -45,7 +45,7 @@ abstract class Kohana_Request_Client_External extends Request_Client {
* Factory method to create a new Request_Client_External object based on
* the client name passed, or defaulting to Request_Client_External::$client
* by default.
*
*
* Request_Client_External::$client can be set in the application bootstrap.
*
* @param array $params parameters to pass to the client
@@ -124,7 +124,7 @@ abstract class Kohana_Request_Client_External extends Request_Client {
if ($post = $request->post())
{
$request->body(http_build_query($post, NULL, '&'))
->headers('content-type', 'application/x-www-form-urlencoded');
->headers('content-type', 'application/x-www-form-urlencoded; charset='.Kohana::$charset);
}
// If Kohana expose, set the user-agent
@@ -204,4 +204,4 @@ abstract class Kohana_Request_Client_External extends Request_Client {
*/
abstract protected function _send_message(Request $request, Response $response);
} // End Kohana_Request_Client_External
}

View File

@@ -1,14 +1,14 @@
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* [Request_Client_External] HTTP driver performs external requests using the
* php-http extention. To use this driver, ensure the following is completed
* php-http extension. To use this driver, ensure the following is completed
* before executing an external request- ideally in the application bootstrap.
*
*
* @example
*
*
* // In application bootstrap
* Request_Client_External::$client = 'Request_Client_HTTP';
*
*
* @package Kohana
* @category Base
* @author Kohana Team
@@ -118,4 +118,4 @@ class Kohana_Request_Client_HTTP extends Request_Client_External {
return $response;
}
} // End Kohana_Request_Client_HTTP
}

View File

@@ -104,6 +104,12 @@ class Kohana_Request_Client_Internal extends Request_Client {
}
catch (HTTP_Exception $e)
{
// Store the request context in the Exception
if ($e->request() === NULL)
{
$e->request($request);
}
// Get the response via the Exception
$response = $e->get_response();
}
@@ -125,4 +131,5 @@ class Kohana_Request_Client_Internal extends Request_Client {
// Return the response
return $response;
}
} // End Kohana_Request_Client_Internal
}

View File

@@ -1,5 +1,4 @@
<?php
defined('SYSPATH') OR die('No direct script access.');
<?php defined('SYSPATH') OR die('No direct script access.');
/**
* @package Kohana
* @category Exceptions
@@ -7,4 +6,4 @@ defined('SYSPATH') OR die('No direct script access.');
* @copyright (c) 2009-2012 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_Request_Client_Recursion_Exception extends Kohana_Exception {}
class Kohana_Request_Client_Recursion_Exception extends Kohana_Exception {}

View File

@@ -3,12 +3,12 @@
* [Request_Client_External] Stream driver performs external requests using php
* sockets. To use this driver, ensure the following is completed
* before executing an external request- ideally in the application bootstrap.
*
*
* @example
*
*
* // In application bootstrap
* Request_Client_External::$client = 'Request_Client_Stream';
*
*
* @package Kohana
* @category Base
* @author Kohana Team
@@ -106,4 +106,4 @@ class Kohana_Request_Client_Stream extends Request_Client_External {
return $response;
}
} // End Kohana_Request_Client_Stream
}

View File

@@ -6,4 +6,4 @@
* @copyright (c) 2009-2012 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_Request_Exception extends Kohana_Exception {}
class Kohana_Request_Exception extends Kohana_Exception {}

View File

@@ -7,8 +7,8 @@
* @package Kohana
* @category Base
* @author Kohana Team
* @copyright (c) 2008-2012 Kohana Team
* @license http://kohanaphp.com/license
* @copyright (c) 2008-2014 Kohana Team
* @license http://kohanaframework.org/license
* @since 3.1.0
*/
class Kohana_Response implements HTTP_Response {
@@ -270,10 +270,10 @@ class Kohana_Response implements HTTP_Response {
/**
* Set and get cookies values for this response.
*
*
* // Get the cookies set to the response
* $cookies = $response->cookie();
*
*
* // Set a cookie to the response
* $response->cookie('session', array(
* 'value' => $value,
@@ -710,4 +710,5 @@ class Kohana_Response implements HTTP_Response {
return array($start, $end);
}
} // End Kohana_Response
}

View File

@@ -35,6 +35,9 @@
*/
class Kohana_Route {
// Matches a URI group and captures the contents
const REGEX_GROUP = '\(((?:(?>[^()]+)|(?R))*)\)';
// Defines the pattern of a <segment>
const REGEX_KEY = '<([a-zA-Z0-9_]++)>';
@@ -213,9 +216,9 @@ class Kohana_Route {
// Create a URI with the route and convert it to a URL
if ($route->is_external())
return Route::get($name)->uri($params);
return $route->uri($params);
else
return URL::site(Route::get($name)->uri($params), $protocol);
return URL::site($route->uri($params), $protocol);
}
/**
@@ -394,23 +397,23 @@ class Kohana_Route {
}
/**
* Tests if the route matches a given URI. A successful match will return
* Tests if the route matches a given Request. A successful match will return
* all of the routed parameters as an array. A failed match will return
* boolean FALSE.
*
* // Params: controller = users, action = edit, id = 10
* $params = $route->matches('users/edit/10');
* $params = $route->matches(Request::factory('users/edit/10'));
*
* This method should almost always be used within an if/else block:
*
* if ($params = $route->matches($uri))
* if ($params = $route->matches($request))
* {
* // Parse the parameters
* }
*
* @param string $uri URI to match
* @return array on success
* @return FALSE on failure
* @param Request $request Request object to match
* @return array on success
* @return FALSE on failure
*/
public function matches(Request $request)
{
@@ -501,109 +504,81 @@ class Kohana_Route {
* @param array $params URI parameters
* @return string
* @throws Kohana_Exception
* @uses Route::REGEX_Key
* @uses Route::REGEX_GROUP
* @uses Route::REGEX_KEY
*/
public function uri(array $params = NULL)
{
// Start with the routed URI
$uri = $this->_uri;
$defaults = $this->_defaults;
if (strpos($uri, '<') === FALSE AND strpos($uri, '(') === FALSE)
/**
* Recursively compiles a portion of a URI specification by replacing
* the specified parameters and any optional parameters that are needed.
*
* @param string $portion Part of the URI specification
* @param boolean $required Whether or not parameters are required (initially)
* @return array Tuple of the compiled portion and whether or not it contained specified parameters
*/
$compile = function ($portion, $required) use (&$compile, $defaults, $params)
{
// This is a static route, no need to replace anything
$missing = array();
if ( ! $this->is_external())
return $uri;
// If the localhost setting does not have a protocol
if (strpos($this->_defaults['host'], '://') === FALSE)
$pattern = '#(?:'.Route::REGEX_KEY.'|'.Route::REGEX_GROUP.')#';
$result = preg_replace_callback($pattern, function ($matches) use (&$compile, $defaults, &$missing, $params, &$required)
{
// Use the default defined protocol
$params['host'] = Route::$default_protocol.$this->_defaults['host'];
}
else
{
// Use the supplied host with protocol
$params['host'] = $this->_defaults['host'];
}
// Compile the final uri and return it
return rtrim($params['host'], '/').'/'.$uri;
}
// Keep track of whether an optional param was replaced
$provided_optional = FALSE;
while (preg_match('#\([^()]++\)#', $uri, $match))
{
// Search for the matched value
$search = $match[0];
// Remove the parenthesis from the match as the replace
$replace = substr($match[0], 1, -1);
while (preg_match('#'.Route::REGEX_KEY.'#', $replace, $match))
{
list($key, $param) = $match;
if (isset($params[$param]) AND $params[$param] !== Arr::get($this->_defaults, $param))
if ($matches[0][0] === '<')
{
// Future optional params should be required
$provided_optional = TRUE;
// Parameter, unwrapped
$param = $matches[1];
// Replace the key with the parameter value
$replace = str_replace($key, $params[$param], $replace);
}
elseif ($provided_optional)
{
// Look for a default
if (isset($this->_defaults[$param]))
if (isset($params[$param]))
{
$replace = str_replace($key, $this->_defaults[$param], $replace);
}
else
{
// Ungrouped parameters are required
throw new Kohana_Exception('Required route parameter not passed: :param', array(
':param' => $param,
));
// This portion is required when a specified
// parameter does not match the default
$required = ($required OR ! isset($defaults[$param]) OR $params[$param] !== $defaults[$param]);
// Add specified parameter to this result
return $params[$param];
}
// Add default parameter to this result
if (isset($defaults[$param]))
return $defaults[$param];
// This portion is missing a parameter
$missing[] = $param;
}
else
{
// This group has missing parameters
$replace = '';
break;
// Group, unwrapped
$result = $compile($matches[2], FALSE);
if ($result[1])
{
// This portion is required when it contains a group
// that is required
$required = TRUE;
// Add required groups to this result
return $result[0];
}
// Do not add optional groups to this result
}
}
}, $portion);
// Replace the group in the URI
$uri = str_replace($search, $replace, $uri);
}
while (preg_match('#'.Route::REGEX_KEY.'#', $uri, $match))
{
list($key, $param) = $match;
if ( ! isset($params[$param]))
if ($required AND $missing)
{
// Look for a default
if (isset($this->_defaults[$param]))
{
$params[$param] = $this->_defaults[$param];
}
else
{
// Ungrouped parameters are required
throw new Kohana_Exception('Required route parameter not passed: :param', array(
':param' => $param,
));
}
throw new Kohana_Exception(
'Required route parameter not passed: :param',
array(':param' => reset($missing))
);
}
$uri = str_replace($key, $params[$param], $uri);
}
return array($result, $required);
};
list($uri) = $compile($this->_uri, TRUE);
// Trim all extra slashes from the URI
$uri = preg_replace('#//+#', '/', rtrim($uri, '/'));
@@ -626,4 +601,4 @@ class Kohana_Route {
return $uri;
}
} // End Route
}

View File

@@ -48,7 +48,17 @@ class Kohana_Security {
if ($new === TRUE OR ! $token)
{
// Generate a new unique token
$token = sha1(uniqid(NULL, TRUE));
if (function_exists('openssl_random_pseudo_bytes'))
{
// Generate a random pseudo bytes token if openssl_random_pseudo_bytes is available
// This is more secure than uniqid, because uniqid relies on microtime, which is predictable
$token = base64_encode(openssl_random_pseudo_bytes(32));
}
else
{
// Otherwise, fall back to a hashed uniqid
$token = sha1(uniqid(NULL, TRUE));
}
// Store the new token
$session->set(Security::$token_name, $token);
@@ -100,4 +110,4 @@ class Kohana_Security {
return str_replace(array('<?', '?>'), array('&lt;?', '?&gt;'), $str);
}
} // End security
}

View File

@@ -502,4 +502,4 @@ abstract class Kohana_Session {
*/
abstract protected function _restart();
} // End Session
}

View File

@@ -52,4 +52,4 @@ class Kohana_Session_Cookie extends Session {
return Cookie::delete($this->_name);
}
} // End Session_Cookie
}

View File

@@ -7,5 +7,7 @@
* @license http://kohanaframework.org/license
*/
class Kohana_Session_Exception extends Kohana_Exception {
const SESSION_CORRUPT = 1;
}
}

View File

@@ -104,4 +104,4 @@ class Kohana_Session_Native extends Session {
return $status;
}
} // End Session_Native
}

View File

@@ -235,11 +235,11 @@ class Kohana_Text {
/**
* Uppercase words that are not separated by spaces, using a custom
* delimiter or the default.
*
* $str = Text::ucfirst('content-type'); // returns "Content-Type"
*
* $str = Text::ucfirst('content-type'); // returns "Content-Type"
*
* @param string $string string to transform
* @param string $delimiter delemiter to use
* @param string $delimiter delimiter to use
* @return string
*/
public static function ucfirst($string, $delimiter = '-')
@@ -272,7 +272,7 @@ class Kohana_Text {
* @param string $str phrase to replace words in
* @param array $badwords words to replace
* @param string $replacement replacement string
* @param boolean $replace_partial_words replace words across word boundries (space, period, etc)
* @param boolean $replace_partial_words replace words across word boundaries (space, period, etc)
* @return string
* @uses UTF8::strlen
*/
@@ -531,7 +531,7 @@ class Kohana_Text {
{
if ($number / $unit >= 1)
{
// $value = the number of times the number is divisble by unit
// $value = the number of times the number is divisible by unit
$number -= $unit * ($value = (int) floor($number / $unit));
// Temporary var for textifying the current unit
$item = '';
@@ -683,4 +683,4 @@ class Kohana_Text {
return FALSE;
}
} // End text
}

View File

@@ -122,7 +122,7 @@ class Kohana_URL {
/**
* Callback used for encoding all non-ASCII characters, as per RFC 1738
* Used by URL::site()
*
*
* @param array $matches Array of matches from preg_replace_callback()
* @return string Encoded string
*/
@@ -210,4 +210,4 @@ class Kohana_URL {
return trim($title, $separator);
}
} // End url
}

View File

@@ -8,8 +8,6 @@
* - PCRE needs to be compiled with UTF-8 support (--enable-utf8)
* - Support for [Unicode properties](http://php.net/manual/reference.pcre.pattern.modifiers.php)
* is highly recommended (--enable-unicode-properties)
* - UTF-8 conversion will be much more reliable if the
* [iconv extension](http://php.net/iconv) is loaded
* - The [mbstring extension](http://php.net/mbstring) is highly recommended,
* but must not be overloading string functions
*
@@ -42,11 +40,10 @@ class Kohana_UTF8 {
*
* UTF8::clean($_GET); // Clean GET data
*
* [!!] This method requires [Iconv](http://php.net/iconv)
*
* @param mixed $var variable to clean
* @param string $charset character set, defaults to Kohana::$charset
* @return mixed
* @uses UTF8::clean
* @uses UTF8::strip_ascii_ctrl
* @uses UTF8::is_ascii
*/
@@ -63,21 +60,20 @@ class Kohana_UTF8 {
foreach ($var as $key => $val)
{
// Recursion!
$var[self::clean($key)] = self::clean($val);
$var[UTF8::clean($key)] = UTF8::clean($val);
}
}
elseif (is_string($var) AND $var !== '')
{
// Remove control characters
$var = self::strip_ascii_ctrl($var);
$var = UTF8::strip_ascii_ctrl($var);
if ( ! self::is_ascii($var))
if ( ! UTF8::is_ascii($var))
{
// Disable notices
$error_reporting = error_reporting(~E_NOTICE);
// iconv is expensive, so it is only used when needed
$var = iconv($charset, $charset.'//IGNORE', $var);
$var = mb_convert_encoding($var, $charset, $charset);
// Turn notices back on
error_reporting($error_reporting);
@@ -144,12 +140,12 @@ class Kohana_UTF8 {
*/
public static function transliterate_to_ascii($str, $case = 0)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _transliterate_to_ascii($str, $case);
@@ -164,18 +160,19 @@ class Kohana_UTF8 {
* @param string $str string being measured for length
* @return integer
* @uses UTF8::$server_utf8
* @uses Kohana::$charset
*/
public static function strlen($str)
{
if (UTF8::$server_utf8)
return mb_strlen($str, Kohana::$charset);
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _strlen($str);
@@ -194,18 +191,19 @@ class Kohana_UTF8 {
* @return integer position of needle
* @return boolean FALSE if the needle is not found
* @uses UTF8::$server_utf8
* @uses Kohana::$charset
*/
public static function strpos($str, $search, $offset = 0)
{
if (UTF8::$server_utf8)
return mb_strpos($str, $search, $offset, Kohana::$charset);
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _strpos($str, $search, $offset);
@@ -230,12 +228,12 @@ class Kohana_UTF8 {
if (UTF8::$server_utf8)
return mb_strrpos($str, $search, $offset, Kohana::$charset);
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _strrpos($str, $search, $offset);
@@ -262,12 +260,12 @@ class Kohana_UTF8 {
? mb_substr($str, $offset, mb_strlen($str), Kohana::$charset)
: mb_substr($str, $offset, $length, Kohana::$charset);
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _substr($str, $offset, $length);
@@ -287,12 +285,12 @@ class Kohana_UTF8 {
*/
public static function substr_replace($str, $replacement, $offset, $length = NULL)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _substr_replace($str, $replacement, $offset, $length);
@@ -305,21 +303,22 @@ class Kohana_UTF8 {
* $str = UTF8::strtolower($str);
*
* @author Andreas Gohr <andi@splitbrain.org>
* @param string $str mixed case string
* @param string $str mixed case string
* @return string
* @uses UTF8::$server_utf8
* @uses Kohana::$charset
*/
public static function strtolower($str)
{
if (UTF8::$server_utf8)
return mb_strtolower($str, Kohana::$charset);
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _strtolower($str);
@@ -330,7 +329,7 @@ class Kohana_UTF8 {
* of [strtoupper](http://php.net/strtoupper).
*
* @author Andreas Gohr <andi@splitbrain.org>
* @param string $str mixed case string
* @param string $str mixed case string
* @return string
* @uses UTF8::$server_utf8
* @uses Kohana::$charset
@@ -340,12 +339,12 @@ class Kohana_UTF8 {
if (UTF8::$server_utf8)
return mb_strtoupper($str, Kohana::$charset);
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _strtoupper($str);
@@ -358,17 +357,17 @@ class Kohana_UTF8 {
* $str = UTF8::ucfirst($str);
*
* @author Harry Fuecks <hfuecks@gmail.com>
* @param string $str mixed case string
* @param string $str mixed case string
* @return string
*/
public static function ucfirst($str)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _ucfirst($str);
@@ -381,18 +380,17 @@ class Kohana_UTF8 {
* $str = UTF8::ucwords($str);
*
* @author Harry Fuecks <hfuecks@gmail.com>
* @param string $str mixed case string
* @param string $str mixed case string
* @return string
* @uses UTF8::$server_utf8
*/
public static function ucwords($str)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _ucwords($str);
@@ -413,12 +411,12 @@ class Kohana_UTF8 {
*/
public static function strcasecmp($str1, $str2)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _strcasecmp($str1, $str2);
@@ -442,25 +440,25 @@ class Kohana_UTF8 {
*/
public static function str_ireplace($search, $replace, $str, & $count = NULL)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _str_ireplace($search, $replace, $str, $count);
}
/**
* Case-insenstive UTF-8 version of strstr. Returns all of input string
* Case-insensitive UTF-8 version of strstr. Returns all of input string
* from the first occurrence of needle to the end. This is a UTF8-aware
* version of [stristr](http://php.net/stristr).
*
* $found = UTF8::stristr($str, $search);
*
* @author Harry Fuecks <hfuecks@gmail.com>
* @author Harry Fuecks <hfuecks@gmail.com>
* @param string $str input string
* @param string $search needle
* @return string matched substring if found
@@ -468,12 +466,12 @@ class Kohana_UTF8 {
*/
public static function stristr($str, $search)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _stristr($str, $search);
@@ -485,7 +483,7 @@ class Kohana_UTF8 {
*
* $found = UTF8::strspn($str, $mask);
*
* @author Harry Fuecks <hfuecks@gmail.com>
* @author Harry Fuecks <hfuecks@gmail.com>
* @param string $str input string
* @param string $mask mask for search
* @param integer $offset start position of the string to examine
@@ -494,12 +492,12 @@ class Kohana_UTF8 {
*/
public static function strspn($str, $mask, $offset = NULL, $length = NULL)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _strspn($str, $mask, $offset, $length);
@@ -520,12 +518,12 @@ class Kohana_UTF8 {
*/
public static function strcspn($str, $mask, $offset = NULL, $length = NULL)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _strcspn($str, $mask, $offset, $length);
@@ -546,12 +544,12 @@ class Kohana_UTF8 {
*/
public static function str_pad($str, $final_str_length, $pad_str = ' ', $pad_type = STR_PAD_RIGHT)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _str_pad($str, $final_str_length, $pad_str, $pad_type);
@@ -570,12 +568,12 @@ class Kohana_UTF8 {
*/
public static function str_split($str, $split_length = 1)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _str_split($str, $split_length);
@@ -587,17 +585,17 @@ class Kohana_UTF8 {
* $str = UTF8::strrev($str);
*
* @author Harry Fuecks <hfuecks@gmail.com>
* @param string $str string to be reversed
* @param string $str string to be reversed
* @return string
*/
public static function strrev($str)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _strrev($str);
@@ -616,12 +614,12 @@ class Kohana_UTF8 {
*/
public static function trim($str, $charlist = NULL)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _trim($str, $charlist);
@@ -640,12 +638,12 @@ class Kohana_UTF8 {
*/
public static function ltrim($str, $charlist = NULL)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _ltrim($str, $charlist);
@@ -664,12 +662,12 @@ class Kohana_UTF8 {
*/
public static function rtrim($str, $charlist = NULL)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _rtrim($str, $charlist);
@@ -687,12 +685,12 @@ class Kohana_UTF8 {
*/
public static function ord($chr)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _ord($chr);
@@ -717,12 +715,12 @@ class Kohana_UTF8 {
*/
public static function to_unicode($str)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _to_unicode($str);
@@ -731,7 +729,7 @@ class Kohana_UTF8 {
/**
* Takes an array of ints representing the Unicode characters and returns a UTF-8 string.
* Astral planes are supported i.e. the ints in the input can be > 0xFFFF.
* Occurrances of the BOM are ignored. Surrogates are not allowed.
* Occurrences of the BOM are ignored. Surrogates are not allowed.
*
* $str = UTF8::to_unicode($array);
*
@@ -747,18 +745,18 @@ class Kohana_UTF8 {
*/
public static function from_unicode($arr)
{
if ( ! isset(self::$called[__FUNCTION__]))
if ( ! isset(UTF8::$called[__FUNCTION__]))
{
require Kohana::find_file('utf8', __FUNCTION__);
// Function has been called
self::$called[__FUNCTION__] = TRUE;
UTF8::$called[__FUNCTION__] = TRUE;
}
return _from_unicode($arr);
}
} // End UTF8
}
if (Kohana_UTF8::$server_utf8 === NULL)
{

View File

@@ -253,4 +253,4 @@ class Kohana_Upload {
return FALSE;
}
} // End upload
}

View File

@@ -478,7 +478,7 @@ class Kohana_Valid {
*/
public static function range($number, $min, $max, $step = NULL)
{
if ($number <= $min OR $number >= $max)
if ($number < $min OR $number > $max)
{
// Number is outside of range
return FALSE;
@@ -548,4 +548,4 @@ class Kohana_Valid {
return ($array[$field] === $array[$match]);
}
} // End Valid
}

View File

@@ -302,7 +302,7 @@ class Kohana_Validation implements ArrayAccess {
$expected = Arr::merge(array_keys($original), array_keys($this->_labels));
// Import the rules locally
$rules = $this->_rules;
$rules = $this->_rules;
foreach ($expected as $field)
{
@@ -609,4 +609,4 @@ class Kohana_Validation implements ArrayAccess {
return $messages;
}
} // End Validation
}

View File

@@ -26,4 +26,4 @@ class Kohana_Validation_Exception extends Kohana_Exception {
parent::__construct($message, $values, $code, $previous);
}
} // End Kohana_Validation_Exception
}

View File

@@ -232,10 +232,10 @@ class Kohana_View {
/**
* Display the exception message.
*
* We use this method here because it's impossible to throw and
* We use this method here because it's impossible to throw an
* exception from __toString().
*/
$error_response = Kohana_exception::_handler($e);
$error_response = Kohana_Exception::_handler($e);
return $error_response->body();
}
@@ -348,4 +348,4 @@ class Kohana_View {
return View::capture($this->_file, $this->_data);
}
} // End View
}

View File

@@ -6,4 +6,4 @@
* @copyright (c) 2009-2012 Kohana Team
* @license http://kohanaframework.org/license
*/
class Kohana_View_Exception extends Kohana_Exception { }
class Kohana_View_Exception extends Kohana_Exception {}