mirror of
https://github.com/Pathduck/gallery3.git
synced 2024-10-29 21:07:18 -04:00
Update Kohana to r4374
This commit is contained in:
parent
356bac0db0
commit
b0cb3c7402
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Unit_Test library.
|
||||
*
|
||||
* $Id: Unit_Test.php 4158 2009-04-07 20:40:44Z zombor $
|
||||
* $Id: Unit_Test.php 4367 2009-05-27 21:23:57Z samsoir $
|
||||
*
|
||||
* @package Unit_Test
|
||||
* @author Kohana Team
|
||||
@ -66,7 +66,7 @@ class Unit_Test_Core {
|
||||
$class = substr($path, strrpos($path, '/') + 1, -(strlen(EXT)));
|
||||
|
||||
// Skip hidden files
|
||||
if (substr($class, 0, 1) === '.')
|
||||
if ($class[0] === '.')
|
||||
continue;
|
||||
|
||||
// Check for duplicate test class name
|
||||
|
@ -48,7 +48,7 @@ $config['enum'] = $config['set'] = $config['varchar'];
|
||||
$config['tinytext'] = $config['mediumtext'] = $config['longtext'] = $config['text'];
|
||||
|
||||
// BLOB
|
||||
$config['tinyblob'] = $config['mediumblob'] = $config['longblob'] = $config['clob'] = $config['bytea'] = $config['blob'];
|
||||
$config['tsvector'] = $config['tinyblob'] = $config['mediumblob'] = $config['longblob'] = $config['clob'] = $config['bytea'] = $config['blob'];
|
||||
|
||||
// CHARACTER
|
||||
$config['character'] = $config['char'];
|
||||
|
@ -4,7 +4,7 @@
|
||||
* to be added to 'events'. Events can be run multiple times, and can also
|
||||
* process event-specific data. By default, Kohana has several system events.
|
||||
*
|
||||
* $Id: Event.php 3993 2009-02-17 18:42:50Z jheathco $
|
||||
* $Id: Event.php 4358 2009-05-27 17:24:25Z ixmatus $
|
||||
*
|
||||
* @package Core
|
||||
* @author Kohana Team
|
||||
@ -206,7 +206,7 @@ final class Event {
|
||||
|
||||
foreach ($callbacks as $callback)
|
||||
{
|
||||
call_user_func($callback);
|
||||
call_user_func_array($callback, array(&$data));
|
||||
}
|
||||
|
||||
// Do this to prevent data from getting 'stuck'
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Provides Kohana-specific helper functions. This is where the magic happens!
|
||||
*
|
||||
* $Id: Kohana.php 4352 2009-05-14 20:26:53Z zombor $
|
||||
* $Id: Kohana.php 4372 2009-05-28 17:00:34Z ixmatus $
|
||||
*
|
||||
* @package Core
|
||||
* @author Kohana Team
|
||||
@ -54,6 +54,8 @@ final class Kohana {
|
||||
private static $internal_cache = array();
|
||||
private static $write_cache;
|
||||
private static $internal_cache_path;
|
||||
private static $internal_cache_key;
|
||||
private static $internal_cache_encrypt;
|
||||
|
||||
/**
|
||||
* Sets up the PHP environment. Adds error/exception handling, output
|
||||
@ -91,6 +93,17 @@ final class Kohana {
|
||||
|
||||
if (self::$cache_lifetime = self::config('core.internal_cache'))
|
||||
{
|
||||
// Are we using encryption for caches?
|
||||
self::$internal_cache_encrypt = self::config('core.internal_cache_encrypt');
|
||||
|
||||
if(self::$internal_cache_encrypt===TRUE)
|
||||
{
|
||||
self::$internal_cache_key = self::config('core.internal_cache_key');
|
||||
|
||||
// Be sure the key is of acceptable length for the mcrypt algorithm used
|
||||
self::$internal_cache_key = substr(self::$internal_cache_key, 0, 24);
|
||||
}
|
||||
|
||||
// Set the directory to be used for the internal cache
|
||||
if ( ! self::$internal_cache_path = self::config('core.internal_cache_path'))
|
||||
{
|
||||
@ -585,8 +598,29 @@ final class Kohana {
|
||||
// Check the file modification time
|
||||
if ((time() - filemtime($path)) < $lifetime)
|
||||
{
|
||||
// Cache is valid
|
||||
return unserialize(file_get_contents($path));
|
||||
// Cache is valid! Now, do we need to decrypt it?
|
||||
if(self::$internal_cache_encrypt===TRUE)
|
||||
{
|
||||
$data = file_get_contents($path);
|
||||
|
||||
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
|
||||
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
|
||||
|
||||
$decrypted_text = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, self::$internal_cache_key, $data, MCRYPT_MODE_ECB, $iv);
|
||||
|
||||
$cache = unserialize($decrypted_text);
|
||||
|
||||
// If the key changed, delete the cache file
|
||||
if(!$cache)
|
||||
unlink($path);
|
||||
|
||||
// If cache is false (as above) return NULL, otherwise, return the cache
|
||||
return ($cache ? $cache : NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
return unserialize(file_get_contents($path));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -623,35 +657,50 @@ final class Kohana {
|
||||
}
|
||||
else
|
||||
{
|
||||
// Write data to cache file
|
||||
return (bool) file_put_contents($path, serialize($data));
|
||||
// Using encryption? Encrypt the data when we write it
|
||||
if(self::$internal_cache_encrypt===TRUE)
|
||||
{
|
||||
// Encrypt and write data to cache file
|
||||
$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
|
||||
$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
|
||||
|
||||
// Serialize and encrypt!
|
||||
$encrypted_text = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, self::$internal_cache_key, serialize($data), MCRYPT_MODE_ECB, $iv);
|
||||
|
||||
return (bool) file_put_contents($path, $encrypted_text);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Write data to cache file
|
||||
return (bool) file_put_contents($path, serialize($data));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Kohana output handler.
|
||||
* Kohana output handler. Called during ob_clean, ob_flush, and their variants.
|
||||
*
|
||||
* @param string current output buffer
|
||||
* @return string
|
||||
*/
|
||||
public static function output_buffer($output)
|
||||
{
|
||||
// Could be flushing, so send headers first
|
||||
if ( ! Event::has_run('system.send_headers'))
|
||||
{
|
||||
// Run the send_headers event, specifically for cookies being set
|
||||
// Run the send_headers event
|
||||
Event::run('system.send_headers');
|
||||
}
|
||||
|
||||
// Set final output
|
||||
self::$output = $output;
|
||||
|
||||
|
||||
self::$output = $output;
|
||||
|
||||
// Set and return the final output
|
||||
return $output;
|
||||
return self::$output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes all open output buffers, either by flushing or cleaning all
|
||||
* open buffers, including the Kohana output buffer.
|
||||
* Closes all open output buffers, either by flushing or cleaning, and stores the Kohana
|
||||
* output buffer for display during shutdown.
|
||||
*
|
||||
* @param boolean disable to clear buffers, rather than flushing
|
||||
* @return void
|
||||
@ -669,11 +718,8 @@ final class Kohana {
|
||||
$close();
|
||||
}
|
||||
|
||||
// This will flush the Kohana buffer, which sets self::$output
|
||||
// Store the Kohana output buffer
|
||||
ob_end_clean();
|
||||
|
||||
// Reset the buffer level
|
||||
self::$buffer_level = ob_get_level();
|
||||
}
|
||||
}
|
||||
|
||||
@ -889,9 +935,9 @@ final class Kohana {
|
||||
}
|
||||
}
|
||||
|
||||
// Close all output buffers except for Kohana
|
||||
while (ob_get_level() > self::$buffer_level)
|
||||
{
|
||||
// Close open buffers
|
||||
ob_end_clean();
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* HTML helper class.
|
||||
*
|
||||
* $Id: html.php 4141 2009-03-29 03:30:06Z zombor $
|
||||
* $Id: html.php 4368 2009-05-27 21:58:51Z samsoir $
|
||||
*
|
||||
* @package Core
|
||||
* @author Kohana Team
|
||||
@ -96,7 +96,7 @@ class html_Core {
|
||||
// Attributes empty? Use an empty string
|
||||
.(is_array($attributes) ? html::attributes($attributes) : '').'>'
|
||||
// Title empty? Use the parsed URL
|
||||
.(($title === NULL) ? $site_url : $title).'</a>';
|
||||
.html::specialchars((($title === NULL) ? $site_url : $title), FALSE).'</a>';
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Validation helper class.
|
||||
*
|
||||
* $Id: valid.php 4187 2009-04-08 04:01:23Z zombor $
|
||||
* $Id: valid.php 4367 2009-05-27 21:23:57Z samsoir $
|
||||
*
|
||||
* @package Core
|
||||
* @author Kohana Team
|
||||
@ -161,13 +161,13 @@ class valid_Core {
|
||||
for ($i = $length - 1; $i >= 0; $i -= 2)
|
||||
{
|
||||
// Add up every 2nd digit, starting from the right
|
||||
$checksum += substr($number, $i, 1);
|
||||
$checksum += $number[$i];
|
||||
}
|
||||
|
||||
for ($i = $length - 2; $i >= 0; $i -= 2)
|
||||
{
|
||||
// Add up every 2nd digit doubled, starting from the right
|
||||
$double = substr($number, $i, 1) * 2;
|
||||
$double = $number[$i] * 2;
|
||||
|
||||
// Subtract 9 from the double where value is greater than 10
|
||||
$checksum += ($double >= 10) ? $double - 9 : $double;
|
||||
|
@ -3,7 +3,7 @@
|
||||
* Kohana Controller class. The controller class must be extended to work
|
||||
* properly, so this class is defined as abstract.
|
||||
*
|
||||
* $Id: Controller.php 3979 2009-02-13 16:46:12Z zombor $
|
||||
* $Id: Controller.php 4365 2009-05-27 21:09:27Z samsoir $
|
||||
*
|
||||
* @package Core
|
||||
* @author Kohana Team
|
||||
@ -69,7 +69,15 @@ abstract class Controller_Core {
|
||||
// Views are straight HTML pages with embedded PHP, so importing them
|
||||
// this way insures that $this can be accessed as if the user was in
|
||||
// the controller, which gives the easiest access to libraries in views
|
||||
include $kohana_view_filename;
|
||||
try
|
||||
{
|
||||
include $kohana_view_filename;
|
||||
}
|
||||
catch (Exception $e)
|
||||
{
|
||||
ob_end_clean();
|
||||
throw $e;
|
||||
}
|
||||
|
||||
// Fetch the output and close the buffer
|
||||
return ob_get_clean();
|
||||
|
@ -2,7 +2,7 @@
|
||||
/**
|
||||
* Captcha driver for "alpha" style.
|
||||
*
|
||||
* $Id: Alpha.php 3769 2008-12-15 00:48:56Z zombor $
|
||||
* $Id: Alpha.php 4367 2009-05-27 21:23:57Z samsoir $
|
||||
*
|
||||
* @package Captcha
|
||||
* @author Kohana Team
|
||||
@ -81,7 +81,7 @@ class Captcha_Alpha_Driver extends Captcha_Driver {
|
||||
|
||||
// Draw "ghost" alphabetic character
|
||||
$text_color = imagecolorallocatealpha($this->image, mt_rand($color_limit + 8, 255), mt_rand($color_limit + 8, 255), mt_rand($color_limit + 8, 255), mt_rand(70, 120));
|
||||
$char = substr($chars, mt_rand(0, 14), 1);
|
||||
$char = $chars[mt_rand(0, 14)];
|
||||
imagettftext($this->image, $size * 2, mt_rand(-45, 45), ($x - (mt_rand(5, 10))), ($y + (mt_rand(5, 10))), $text_color, $font, $char);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user