Skip to content

Commit

Permalink
CI Updated with 3.1.2 and Eloquent 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
webwizo committed Nov 16, 2016
1 parent 765eeb7 commit df51948
Show file tree
Hide file tree
Showing 173 changed files with 4,259 additions and 3,102 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MIT",
"require": {
"php": ">=5.2.4",
"illuminate/database": "^5.1"
"illuminate/database": "^5.3"
},
"require-dev": {
"mikey179/vfsStream": "1.1.*"
Expand Down
10 changes: 5 additions & 5 deletions system/core/Benchmark.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014 - 2015, British Columbia Institute of Technology
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -28,10 +28,10 @@
*
* @package CodeIgniter
* @author EllisLab Dev Team
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
* @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
* @license http://opensource.org/licenses/MIT MIT License
* @link http://codeigniter.com
* @link https://codeigniter.com
* @since Version 1.0.0
* @filesource
*/
Expand All @@ -47,7 +47,7 @@
* @subpackage Libraries
* @category Libraries
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/libraries/benchmark.html
* @link https://codeigniter.com/user_guide/libraries/benchmark.html
*/
class CI_Benchmark {

Expand Down
39 changes: 27 additions & 12 deletions system/core/CodeIgniter.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014 - 2015, British Columbia Institute of Technology
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -28,10 +28,10 @@
*
* @package CodeIgniter
* @author EllisLab Dev Team
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
* @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
* @license http://opensource.org/licenses/MIT MIT License
* @link http://codeigniter.com
* @link https://codeigniter.com
* @since Version 1.0.0
* @filesource
*/
Expand All @@ -46,7 +46,7 @@
* @subpackage CodeIgniter
* @category Front-controller
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/
* @link https://codeigniter.com/user_guide/
*/

/**
Expand All @@ -55,7 +55,7 @@
* @var string
*
*/
define('CI_VERSION', '3.0.0');
const CI_VERSION = '3.1.2';

/*
* ------------------------------------------------------
Expand Down Expand Up @@ -359,7 +359,7 @@
*
* Returns current CI instance object
*
* @return object
* @return CI_Controller
*/
function &get_instance()
{
Expand Down Expand Up @@ -416,14 +416,29 @@ function &get_instance()
$params = array($method, array_slice($URI->rsegments, 2));
$method = '_remap';
}
// WARNING: It appears that there are issues with is_callable() even in PHP 5.2!
// Furthermore, there are bug reports and feature/change requests related to it
// that make it unreliable to use in this context. Please, DO NOT change this
// work-around until a better alternative is available.
elseif ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($class)), TRUE))
elseif ( ! method_exists($class, $method))
{
$e404 = TRUE;
}
/**
* DO NOT CHANGE THIS, NOTHING ELSE WORKS!
*
* - method_exists() returns true for non-public methods, which passes the previous elseif
* - is_callable() returns false for PHP 4-style constructors, even if there's a __construct()
* - method_exists($class, '__construct') won't work because CI_Controller::__construct() is inherited
* - People will only complain if this doesn't work, even though it is documented that it shouldn't.
*
* ReflectionMethod::isConstructor() is the ONLY reliable check,
* knowing which method will be executed as a constructor.
*/
elseif ( ! is_callable(array($class, $method)) && strcasecmp($class, $method) === 0)
{
$reflection = new ReflectionMethod($class, $method);
if ( ! $reflection->isPublic() OR $reflection->isConstructor())
{
$e404 = TRUE;
}
}
}

if ($e404)
Expand Down
59 changes: 32 additions & 27 deletions system/core/Common.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014 - 2015, British Columbia Institute of Technology
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -28,10 +28,10 @@
*
* @package CodeIgniter
* @author EllisLab Dev Team
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
* @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
* @license http://opensource.org/licenses/MIT MIT License
* @link http://codeigniter.com
* @link https://codeigniter.com
* @since Version 1.0.0
* @filesource
*/
Expand All @@ -46,7 +46,7 @@
* @subpackage CodeIgniter
* @category Common Functions
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/
* @link https://codeigniter.com/user_guide/
*/

// ------------------------------------------------------------------------
Expand Down Expand Up @@ -181,7 +181,7 @@ function &load_class($class, $directory = 'libraries', $param = NULL)
// Did we find the class?
if ($name === FALSE)
{
// Note: We use exit() rather then show_error() in order to avoid a
// Note: We use exit() rather than show_error() in order to avoid a
// self-referencing loop with the Exceptions class
set_status_header(503);
echo 'Unable to locate the specified class: '.$class.'.php';
Expand Down Expand Up @@ -355,7 +355,7 @@ function is_https()
{
return TRUE;
}
elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https')
{
return TRUE;
}
Expand Down Expand Up @@ -506,6 +506,9 @@ function set_status_header($code = 200, $text = '')
{
is_int($code) OR $code = (int) $code;
$stati = array(
100 => 'Continue',
101 => 'Switching Protocols',

200 => 'OK',
201 => 'Created',
202 => 'Accepted',
Expand All @@ -524,6 +527,7 @@ function set_status_header($code = 200, $text = '')

400 => 'Bad Request',
401 => 'Unauthorized',
402 => 'Payment Required',
403 => 'Forbidden',
404 => 'Not Found',
405 => 'Method Not Allowed',
Expand All @@ -540,13 +544,18 @@ function set_status_header($code = 200, $text = '')
416 => 'Requested Range Not Satisfiable',
417 => 'Expectation Failed',
422 => 'Unprocessable Entity',
426 => 'Upgrade Required',
428 => 'Precondition Required',
429 => 'Too Many Requests',
431 => 'Request Header Fields Too Large',

500 => 'Internal Server Error',
501 => 'Not Implemented',
502 => 'Bad Gateway',
503 => 'Service Unavailable',
504 => 'Gateway Timeout',
505 => 'HTTP Version Not Supported'
505 => 'HTTP Version Not Supported',
511 => 'Network Authentication Required',
);

if (isset($stati[$code]))
Expand Down Expand Up @@ -594,7 +603,7 @@ function set_status_header($code = 200, $text = '')
*/
function _error_handler($severity, $message, $filepath, $line)
{
$is_error = (((E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR) & $severity) === $severity);
$is_error = (((E_ERROR | E_PARSE | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR) & $severity) === $severity);

// When an error occurred, set the status header to '500 Internal Server Error'
// to indicate to the client something went wrong.
Expand Down Expand Up @@ -652,6 +661,7 @@ function _exception_handler($exception)
$_error =& load_class('Exceptions', 'core');
$_error->log_exception('error', 'Exception: '.$exception->getMessage(), $exception->getFile(), $exception->getLine());

is_cli() OR set_status_header(500);
// Should we display the error?
if (str_ireplace(array('off', 'none', 'no', 'false', 'null'), '', ini_get('display_errors')))
{
Expand All @@ -673,7 +683,7 @@ function _exception_handler($exception)
* of CodeIgniter.php. The main reason we use this is to simulate
* a complete custom exception handler.
*
* E_STRICT is purposivly neglected because such events may have
* E_STRICT is purposively neglected because such events may have
* been caught. Duplication or none? None is preferred for now.
*
* @link http://insomanic.me.uk/post/229851073/php-trick-catching-fatal-errors-e-error-with-a
Expand Down Expand Up @@ -712,8 +722,8 @@ function remove_invisible_characters($str, $url_encoded = TRUE)
// carriage return (dec 13) and horizontal tab (dec 09)
if ($url_encoded)
{
$non_displayables[] = '/%0[0-8bcef]/'; // url encoded 00-08, 11, 12, 14, 15
$non_displayables[] = '/%1[0-9a-f]/'; // url encoded 16-31
$non_displayables[] = '/%0[0-8bcef]/i'; // url encoded 00-08, 11, 12, 14, 15
$non_displayables[] = '/%1[0-9a-f]/i'; // url encoded 16-31
}

$non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127
Expand Down Expand Up @@ -745,10 +755,15 @@ function html_escape($var, $double_encode = TRUE)
{
return $var;
}

if (is_array($var))
{
return array_map('html_escape', $var, array_fill(0, count($var), $double_encode));
foreach (array_keys($var) as $key)
{
$var[$key] = html_escape($var[$key], $double_encode);
}

return $var;
}

return htmlspecialchars($var, ENT_QUOTES, config_item('charset'), $double_encode);
Expand Down Expand Up @@ -829,19 +844,9 @@ function function_usable($function_name)
{
if ( ! isset($_suhosin_func_blacklist))
{
if (extension_loaded('suhosin'))
{
$_suhosin_func_blacklist = explode(',', trim(ini_get('suhosin.executor.func.blacklist')));

if ( ! in_array('eval', $_suhosin_func_blacklist, TRUE) && ini_get('suhosin.executor.disable_eval'))
{
$_suhosin_func_blacklist[] = 'eval';
}
}
else
{
$_suhosin_func_blacklist = array();
}
$_suhosin_func_blacklist = extension_loaded('suhosin')
? explode(',', trim(ini_get('suhosin.executor.func.blacklist')))
: array();
}

return ! in_array($function_name, $_suhosin_func_blacklist, TRUE);
Expand Down
54 changes: 37 additions & 17 deletions system/core/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* This content is released under the MIT License (MIT)
*
* Copyright (c) 2014 - 2015, British Columbia Institute of Technology
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
Expand All @@ -28,10 +28,10 @@
*
* @package CodeIgniter
* @author EllisLab Dev Team
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
* @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
* @license http://opensource.org/licenses/MIT MIT License
* @link http://codeigniter.com
* @link https://codeigniter.com
* @since Version 1.0.0
* @filesource
*/
Expand All @@ -46,7 +46,7 @@
* @subpackage Libraries
* @category Libraries
* @author EllisLab Dev Team
* @link http://codeigniter.com/user_guide/libraries/config.html
* @link https://codeigniter.com/user_guide/libraries/config.html
*/
class CI_Config {

Expand Down Expand Up @@ -88,11 +88,18 @@ public function __construct()
// Set the base_url automatically if none was provided
if (empty($this->config['base_url']))
{
// The regular expression is only a basic validation for a valid "Host" header.
// It's not exhaustive, only checks for valid characters.
if (isset($_SERVER['HTTP_HOST']) && preg_match('/^((\[[0-9a-f:]+\])|(\d{1,3}(\.\d{1,3}){3})|[a-z0-9\-\.]+)(:\d+)?$/i', $_SERVER['HTTP_HOST']))
if (isset($_SERVER['SERVER_ADDR']))
{
$base_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST']
if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE)
{
$server_addr = '['.$_SERVER['SERVER_ADDR'].']';
}
else
{
$server_addr = $_SERVER['SERVER_ADDR'];
}

$base_url = (is_https() ? 'https' : 'http').'://'.$server_addr
.substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])));
}
else
Expand Down Expand Up @@ -238,7 +245,15 @@ public function site_url($uri = '', $protocol = NULL)

if (isset($protocol))
{
$base_url = $protocol.substr($base_url, strpos($base_url, '://'));
// For protocol-relative links
if ($protocol === '')
{
$base_url = substr($base_url, strpos($base_url, '//'));
}
else
{
$base_url = $protocol.substr($base_url, strpos($base_url, '://'));
}
}

if (empty($uri))
Expand Down Expand Up @@ -293,10 +308,18 @@ public function base_url($uri = '', $protocol = NULL)

if (isset($protocol))
{
$base_url = $protocol.substr($base_url, strpos($base_url, '://'));
// For protocol-relative links
if ($protocol === '')
{
$base_url = substr($base_url, strpos($base_url, '//'));
}
else
{
$base_url = $protocol.substr($base_url, strpos($base_url, '://'));
}
}

return $base_url.ltrim($this->_uri_string($uri), '/');
return $base_url.$this->_uri_string($uri);
}

// -------------------------------------------------------------
Expand All @@ -314,11 +337,8 @@ protected function _uri_string($uri)
{
if ($this->item('enable_query_strings') === FALSE)
{
if (is_array($uri))
{
$uri = implode('/', $uri);
}
return trim($uri, '/');
is_array($uri) && $uri = implode('/', $uri);
return ltrim($uri, '/');
}
elseif (is_array($uri))
{
Expand Down
Loading

0 comments on commit df51948

Please sign in to comment.