Skip to content

Commit df51948

Browse files
committed
CI Updated with 3.1.2 and Eloquent 5.3
1 parent 765eeb7 commit df51948

File tree

173 files changed

+4259
-3102
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

173 files changed

+4259
-3102
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"license": "MIT",
55
"require": {
66
"php": ">=5.2.4",
7-
"illuminate/database": "^5.1"
7+
"illuminate/database": "^5.3"
88
},
99
"require-dev": {
1010
"mikey179/vfsStream": "1.1.*"

system/core/Benchmark.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* This content is released under the MIT License (MIT)
88
*
9-
* Copyright (c) 2014 - 2015, British Columbia Institute of Technology
9+
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
1010
*
1111
* Permission is hereby granted, free of charge, to any person obtaining a copy
1212
* of this software and associated documentation files (the "Software"), to deal
@@ -28,10 +28,10 @@
2828
*
2929
* @package CodeIgniter
3030
* @author EllisLab Dev Team
31-
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
32-
* @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
31+
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32+
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
3333
* @license http://opensource.org/licenses/MIT MIT License
34-
* @link http://codeigniter.com
34+
* @link https://codeigniter.com
3535
* @since Version 1.0.0
3636
* @filesource
3737
*/
@@ -47,7 +47,7 @@
4747
* @subpackage Libraries
4848
* @category Libraries
4949
* @author EllisLab Dev Team
50-
* @link http://codeigniter.com/user_guide/libraries/benchmark.html
50+
* @link https://codeigniter.com/user_guide/libraries/benchmark.html
5151
*/
5252
class CI_Benchmark {
5353

system/core/CodeIgniter.php

Lines changed: 27 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* This content is released under the MIT License (MIT)
88
*
9-
* Copyright (c) 2014 - 2015, British Columbia Institute of Technology
9+
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
1010
*
1111
* Permission is hereby granted, free of charge, to any person obtaining a copy
1212
* of this software and associated documentation files (the "Software"), to deal
@@ -28,10 +28,10 @@
2828
*
2929
* @package CodeIgniter
3030
* @author EllisLab Dev Team
31-
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
32-
* @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
31+
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32+
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
3333
* @license http://opensource.org/licenses/MIT MIT License
34-
* @link http://codeigniter.com
34+
* @link https://codeigniter.com
3535
* @since Version 1.0.0
3636
* @filesource
3737
*/
@@ -46,7 +46,7 @@
4646
* @subpackage CodeIgniter
4747
* @category Front-controller
4848
* @author EllisLab Dev Team
49-
* @link http://codeigniter.com/user_guide/
49+
* @link https://codeigniter.com/user_guide/
5050
*/
5151

5252
/**
@@ -55,7 +55,7 @@
5555
* @var string
5656
*
5757
*/
58-
define('CI_VERSION', '3.0.0');
58+
const CI_VERSION = '3.1.2';
5959

6060
/*
6161
* ------------------------------------------------------
@@ -359,7 +359,7 @@
359359
*
360360
* Returns current CI instance object
361361
*
362-
* @return object
362+
* @return CI_Controller
363363
*/
364364
function &get_instance()
365365
{
@@ -416,14 +416,29 @@ function &get_instance()
416416
$params = array($method, array_slice($URI->rsegments, 2));
417417
$method = '_remap';
418418
}
419-
// WARNING: It appears that there are issues with is_callable() even in PHP 5.2!
420-
// Furthermore, there are bug reports and feature/change requests related to it
421-
// that make it unreliable to use in this context. Please, DO NOT change this
422-
// work-around until a better alternative is available.
423-
elseif ( ! in_array(strtolower($method), array_map('strtolower', get_class_methods($class)), TRUE))
419+
elseif ( ! method_exists($class, $method))
424420
{
425421
$e404 = TRUE;
426422
}
423+
/**
424+
* DO NOT CHANGE THIS, NOTHING ELSE WORKS!
425+
*
426+
* - method_exists() returns true for non-public methods, which passes the previous elseif
427+
* - is_callable() returns false for PHP 4-style constructors, even if there's a __construct()
428+
* - method_exists($class, '__construct') won't work because CI_Controller::__construct() is inherited
429+
* - People will only complain if this doesn't work, even though it is documented that it shouldn't.
430+
*
431+
* ReflectionMethod::isConstructor() is the ONLY reliable check,
432+
* knowing which method will be executed as a constructor.
433+
*/
434+
elseif ( ! is_callable(array($class, $method)) && strcasecmp($class, $method) === 0)
435+
{
436+
$reflection = new ReflectionMethod($class, $method);
437+
if ( ! $reflection->isPublic() OR $reflection->isConstructor())
438+
{
439+
$e404 = TRUE;
440+
}
441+
}
427442
}
428443

429444
if ($e404)

system/core/Common.php

Lines changed: 32 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* This content is released under the MIT License (MIT)
88
*
9-
* Copyright (c) 2014 - 2015, British Columbia Institute of Technology
9+
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
1010
*
1111
* Permission is hereby granted, free of charge, to any person obtaining a copy
1212
* of this software and associated documentation files (the "Software"), to deal
@@ -28,10 +28,10 @@
2828
*
2929
* @package CodeIgniter
3030
* @author EllisLab Dev Team
31-
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
32-
* @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
31+
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32+
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
3333
* @license http://opensource.org/licenses/MIT MIT License
34-
* @link http://codeigniter.com
34+
* @link https://codeigniter.com
3535
* @since Version 1.0.0
3636
* @filesource
3737
*/
@@ -46,7 +46,7 @@
4646
* @subpackage CodeIgniter
4747
* @category Common Functions
4848
* @author EllisLab Dev Team
49-
* @link http://codeigniter.com/user_guide/
49+
* @link https://codeigniter.com/user_guide/
5050
*/
5151

5252
// ------------------------------------------------------------------------
@@ -181,7 +181,7 @@ function &load_class($class, $directory = 'libraries', $param = NULL)
181181
// Did we find the class?
182182
if ($name === FALSE)
183183
{
184-
// Note: We use exit() rather then show_error() in order to avoid a
184+
// Note: We use exit() rather than show_error() in order to avoid a
185185
// self-referencing loop with the Exceptions class
186186
set_status_header(503);
187187
echo 'Unable to locate the specified class: '.$class.'.php';
@@ -355,7 +355,7 @@ function is_https()
355355
{
356356
return TRUE;
357357
}
358-
elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] === 'https')
358+
elseif (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https')
359359
{
360360
return TRUE;
361361
}
@@ -506,6 +506,9 @@ function set_status_header($code = 200, $text = '')
506506
{
507507
is_int($code) OR $code = (int) $code;
508508
$stati = array(
509+
100 => 'Continue',
510+
101 => 'Switching Protocols',
511+
509512
200 => 'OK',
510513
201 => 'Created',
511514
202 => 'Accepted',
@@ -524,6 +527,7 @@ function set_status_header($code = 200, $text = '')
524527

525528
400 => 'Bad Request',
526529
401 => 'Unauthorized',
530+
402 => 'Payment Required',
527531
403 => 'Forbidden',
528532
404 => 'Not Found',
529533
405 => 'Method Not Allowed',
@@ -540,13 +544,18 @@ function set_status_header($code = 200, $text = '')
540544
416 => 'Requested Range Not Satisfiable',
541545
417 => 'Expectation Failed',
542546
422 => 'Unprocessable Entity',
547+
426 => 'Upgrade Required',
548+
428 => 'Precondition Required',
549+
429 => 'Too Many Requests',
550+
431 => 'Request Header Fields Too Large',
543551

544552
500 => 'Internal Server Error',
545553
501 => 'Not Implemented',
546554
502 => 'Bad Gateway',
547555
503 => 'Service Unavailable',
548556
504 => 'Gateway Timeout',
549-
505 => 'HTTP Version Not Supported'
557+
505 => 'HTTP Version Not Supported',
558+
511 => 'Network Authentication Required',
550559
);
551560

552561
if (isset($stati[$code]))
@@ -594,7 +603,7 @@ function set_status_header($code = 200, $text = '')
594603
*/
595604
function _error_handler($severity, $message, $filepath, $line)
596605
{
597-
$is_error = (((E_ERROR | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR) & $severity) === $severity);
606+
$is_error = (((E_ERROR | E_PARSE | E_COMPILE_ERROR | E_CORE_ERROR | E_USER_ERROR) & $severity) === $severity);
598607

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

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

719729
$non_displayables[] = '/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]+/S'; // 00-08, 11, 12, 14-31, 127
@@ -745,10 +755,15 @@ function html_escape($var, $double_encode = TRUE)
745755
{
746756
return $var;
747757
}
748-
758+
749759
if (is_array($var))
750760
{
751-
return array_map('html_escape', $var, array_fill(0, count($var), $double_encode));
761+
foreach (array_keys($var) as $key)
762+
{
763+
$var[$key] = html_escape($var[$key], $double_encode);
764+
}
765+
766+
return $var;
752767
}
753768

754769
return htmlspecialchars($var, ENT_QUOTES, config_item('charset'), $double_encode);
@@ -829,19 +844,9 @@ function function_usable($function_name)
829844
{
830845
if ( ! isset($_suhosin_func_blacklist))
831846
{
832-
if (extension_loaded('suhosin'))
833-
{
834-
$_suhosin_func_blacklist = explode(',', trim(ini_get('suhosin.executor.func.blacklist')));
835-
836-
if ( ! in_array('eval', $_suhosin_func_blacklist, TRUE) && ini_get('suhosin.executor.disable_eval'))
837-
{
838-
$_suhosin_func_blacklist[] = 'eval';
839-
}
840-
}
841-
else
842-
{
843-
$_suhosin_func_blacklist = array();
844-
}
847+
$_suhosin_func_blacklist = extension_loaded('suhosin')
848+
? explode(',', trim(ini_get('suhosin.executor.func.blacklist')))
849+
: array();
845850
}
846851

847852
return ! in_array($function_name, $_suhosin_func_blacklist, TRUE);

system/core/Config.php

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*
77
* This content is released under the MIT License (MIT)
88
*
9-
* Copyright (c) 2014 - 2015, British Columbia Institute of Technology
9+
* Copyright (c) 2014 - 2016, British Columbia Institute of Technology
1010
*
1111
* Permission is hereby granted, free of charge, to any person obtaining a copy
1212
* of this software and associated documentation files (the "Software"), to deal
@@ -28,10 +28,10 @@
2828
*
2929
* @package CodeIgniter
3030
* @author EllisLab Dev Team
31-
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (http://ellislab.com/)
32-
* @copyright Copyright (c) 2014 - 2015, British Columbia Institute of Technology (http://bcit.ca/)
31+
* @copyright Copyright (c) 2008 - 2014, EllisLab, Inc. (https://ellislab.com/)
32+
* @copyright Copyright (c) 2014 - 2016, British Columbia Institute of Technology (http://bcit.ca/)
3333
* @license http://opensource.org/licenses/MIT MIT License
34-
* @link http://codeigniter.com
34+
* @link https://codeigniter.com
3535
* @since Version 1.0.0
3636
* @filesource
3737
*/
@@ -46,7 +46,7 @@
4646
* @subpackage Libraries
4747
* @category Libraries
4848
* @author EllisLab Dev Team
49-
* @link http://codeigniter.com/user_guide/libraries/config.html
49+
* @link https://codeigniter.com/user_guide/libraries/config.html
5050
*/
5151
class CI_Config {
5252

@@ -88,11 +88,18 @@ public function __construct()
8888
// Set the base_url automatically if none was provided
8989
if (empty($this->config['base_url']))
9090
{
91-
// The regular expression is only a basic validation for a valid "Host" header.
92-
// It's not exhaustive, only checks for valid characters.
93-
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']))
91+
if (isset($_SERVER['SERVER_ADDR']))
9492
{
95-
$base_url = (is_https() ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST']
93+
if (strpos($_SERVER['SERVER_ADDR'], ':') !== FALSE)
94+
{
95+
$server_addr = '['.$_SERVER['SERVER_ADDR'].']';
96+
}
97+
else
98+
{
99+
$server_addr = $_SERVER['SERVER_ADDR'];
100+
}
101+
102+
$base_url = (is_https() ? 'https' : 'http').'://'.$server_addr
96103
.substr($_SERVER['SCRIPT_NAME'], 0, strpos($_SERVER['SCRIPT_NAME'], basename($_SERVER['SCRIPT_FILENAME'])));
97104
}
98105
else
@@ -238,7 +245,15 @@ public function site_url($uri = '', $protocol = NULL)
238245

239246
if (isset($protocol))
240247
{
241-
$base_url = $protocol.substr($base_url, strpos($base_url, '://'));
248+
// For protocol-relative links
249+
if ($protocol === '')
250+
{
251+
$base_url = substr($base_url, strpos($base_url, '//'));
252+
}
253+
else
254+
{
255+
$base_url = $protocol.substr($base_url, strpos($base_url, '://'));
256+
}
242257
}
243258

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

294309
if (isset($protocol))
295310
{
296-
$base_url = $protocol.substr($base_url, strpos($base_url, '://'));
311+
// For protocol-relative links
312+
if ($protocol === '')
313+
{
314+
$base_url = substr($base_url, strpos($base_url, '//'));
315+
}
316+
else
317+
{
318+
$base_url = $protocol.substr($base_url, strpos($base_url, '://'));
319+
}
297320
}
298321

299-
return $base_url.ltrim($this->_uri_string($uri), '/');
322+
return $base_url.$this->_uri_string($uri);
300323
}
301324

302325
// -------------------------------------------------------------
@@ -314,11 +337,8 @@ protected function _uri_string($uri)
314337
{
315338
if ($this->item('enable_query_strings') === FALSE)
316339
{
317-
if (is_array($uri))
318-
{
319-
$uri = implode('/', $uri);
320-
}
321-
return trim($uri, '/');
340+
is_array($uri) && $uri = implode('/', $uri);
341+
return ltrim($uri, '/');
322342
}
323343
elseif (is_array($uri))
324344
{

0 commit comments

Comments
 (0)