Skip to content
This repository was archived by the owner on Apr 1, 2026. It is now read-only.

Commit e386c89

Browse files
committed
[UPD] - CodeIgniter 3.1.6
1 parent e2df83f commit e386c89

17 files changed

Lines changed: 250 additions & 145 deletions

index.php

Lines changed: 78 additions & 55 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 - 2017, 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 - 2017, 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
*/
@@ -91,40 +91,41 @@
9191

9292
/*
9393
*---------------------------------------------------------------
94-
* SYSTEM FOLDER NAME
94+
* SYSTEM DIRECTORY NAME
9595
*---------------------------------------------------------------
9696
*
97-
* This variable must contain the name of your "system" folder.
98-
* Include the path if the folder is not in the same directory
99-
* as this file.
97+
* This variable must contain the name of your "system" directory.
98+
* Set the path if it is not in the same directory as this file.
10099
*/
101100
$system_path = 'system';
102101

103102
/*
104103
*---------------------------------------------------------------
105-
* APPLICATION FOLDER NAME
104+
* APPLICATION DIRECTORY NAME
106105
*---------------------------------------------------------------
107106
*
108107
* If you want this front controller to use a different "application"
109-
* folder than the default one you can set its name here. The folder
110-
* can also be renamed or relocated anywhere on your server. If
111-
* you do, use a full server path. For more info please see the user guide:
112-
* http://codeigniter.com/user_guide/general/managing_apps.html
108+
* directory than the default one you can set its name here. The directory
109+
* can also be renamed or relocated anywhere on your server. If you do,
110+
* use an absolute (full) server path.
111+
* For more info please see the user guide:
112+
*
113+
* https://codeigniter.com/user_guide/general/managing_apps.html
113114
*
114115
* NO TRAILING SLASH!
115116
*/
116117
$application_folder = 'application';
117118

118119
/*
119120
*---------------------------------------------------------------
120-
* VIEW FOLDER NAME
121+
* VIEW DIRECTORY NAME
121122
*---------------------------------------------------------------
122123
*
123-
* If you want to move the view folder out of the application
124-
* folder set the path to the folder here. The folder can be renamed
124+
* If you want to move the view directory out of the application
125+
* directory, set the path to it here. The directory can be renamed
125126
* and relocated anywhere on your server. If blank, it will default
126-
* to the standard location inside your application folder. If you
127-
* do move this, use the full server path to this folder.
127+
* to the standard location inside your application directory.
128+
* If you do move this, use an absolute (full) server path.
128129
*
129130
* NO TRAILING SLASH!
130131
*/
@@ -150,8 +151,8 @@
150151
*
151152
* Un-comment the $routing array below to use this feature
152153
*/
153-
// The directory name, relative to the "controllers" folder. Leave blank
154-
// if your controller is not in a sub-folder within the "controllers" folder
154+
// The directory name, relative to the "controllers" directory. Leave blank
155+
// if your controller is not in a sub-directory within the "controllers" one
155156
// $routing['directory'] = '';
156157

157158
// The controller class file name. Example: mycontroller
@@ -197,12 +198,16 @@
197198

198199
if (($_temp = realpath($system_path)) !== FALSE)
199200
{
200-
$system_path = $_temp.'/';
201+
$system_path = $_temp.DIRECTORY_SEPARATOR;
201202
}
202203
else
203204
{
204205
// Ensure there's a trailing slash
205-
$system_path = rtrim($system_path, '/').'/';
206+
$system_path = strtr(
207+
rtrim($system_path, '/\\'),
208+
'/\\',
209+
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
210+
).DIRECTORY_SEPARATOR;
206211
}
207212

208213
// Is the system path correct?
@@ -221,66 +226,84 @@
221226
// The name of THIS file
222227
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
223228

224-
// Path to the system folder
225-
define('BASEPATH', str_replace('\\', '/', $system_path));
229+
// Path to the system directory
230+
define('BASEPATH', $system_path);
226231

227-
// Path to the front controller (this file)
228-
define('FCPATH', dirname(__FILE__).'/');
232+
// Path to the front controller (this file) directory
233+
define('FCPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
229234

230-
// Name of the "system folder"
231-
define('SYSDIR', trim(strrchr(trim(BASEPATH, '/'), '/'), '/'));
235+
// Name of the "system" directory
236+
define('SYSDIR', basename(BASEPATH));
232237

233-
// The path to the "application" folder
238+
// The path to the "application" directory
234239
if (is_dir($application_folder))
235240
{
236241
if (($_temp = realpath($application_folder)) !== FALSE)
237242
{
238243
$application_folder = $_temp;
239244
}
240-
241-
define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
245+
else
246+
{
247+
$application_folder = strtr(
248+
rtrim($application_folder, '/\\'),
249+
'/\\',
250+
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
251+
);
252+
}
253+
}
254+
elseif (is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
255+
{
256+
$application_folder = BASEPATH.strtr(
257+
trim($application_folder, '/\\'),
258+
'/\\',
259+
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
260+
);
242261
}
243262
else
244263
{
245-
if ( ! is_dir(BASEPATH.$application_folder.DIRECTORY_SEPARATOR))
246-
{
247-
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
248-
echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
249-
exit(3); // EXIT_CONFIG
250-
}
251-
252-
define('APPPATH', BASEPATH.$application_folder.DIRECTORY_SEPARATOR);
264+
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
265+
echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
266+
exit(3); // EXIT_CONFIG
253267
}
254268

255-
// The path to the "views" folder
256-
if ( ! is_dir($view_folder))
269+
define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
270+
271+
// The path to the "views" directory
272+
if ( ! isset($view_folder[0]) && is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
257273
{
258-
if ( ! empty($view_folder) && is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
259-
{
260-
$view_folder = APPPATH.$view_folder;
261-
}
262-
elseif ( ! is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
274+
$view_folder = APPPATH.'views';
275+
}
276+
elseif (is_dir($view_folder))
277+
{
278+
if (($_temp = realpath($view_folder)) !== FALSE)
263279
{
264-
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
265-
echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
266-
exit(3); // EXIT_CONFIG
280+
$view_folder = $_temp;
267281
}
268282
else
269283
{
270-
$view_folder = APPPATH.'views';
284+
$view_folder = strtr(
285+
rtrim($view_folder, '/\\'),
286+
'/\\',
287+
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
288+
);
271289
}
272290
}
273-
274-
if (($_temp = realpath($view_folder)) !== FALSE)
291+
elseif (is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
275292
{
276-
$view_folder = $_temp.DIRECTORY_SEPARATOR;
293+
$view_folder = APPPATH.strtr(
294+
trim($view_folder, '/\\'),
295+
'/\\',
296+
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
297+
);
277298
}
278299
else
279300
{
280-
$view_folder = rtrim($view_folder, '/\\').DIRECTORY_SEPARATOR;
301+
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
302+
echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: '.SELF;
303+
exit(3); // EXIT_CONFIG
281304
}
282305

283-
define('VIEWPATH', $view_folder);
306+
define('VIEWPATH', $view_folder.DIRECTORY_SEPARATOR);
284307

285308
/*
286309
* --------------------------------------------------------------------

system/core/CodeIgniter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@
5555
* @var string
5656
*
5757
*/
58-
const CI_VERSION = '3.1.5';
58+
const CI_VERSION = '3.1.6';
5959

6060
/*
6161
* ------------------------------------------------------

system/core/Loader.php

Lines changed: 36 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ public function is_loaded($class)
182182
* Loads and instantiates libraries.
183183
* Designed to be called from application controllers.
184184
*
185-
* @param string $library Library name
185+
* @param mixed $library Library name
186186
* @param array $params Optional parameters to pass to the library class constructor
187187
* @param string $object_name An optional object name to assign to
188188
* @return object
@@ -1037,6 +1037,26 @@ protected function _ci_load_library($class, $params = NULL, $object_name = NULL)
10371037
return $this->_ci_load_stock_library($class, $subdir, $params, $object_name);
10381038
}
10391039

1040+
// Safety: Was the class already loaded by a previous call?
1041+
if (class_exists($class, FALSE))
1042+
{
1043+
$property = $object_name;
1044+
if (empty($property))
1045+
{
1046+
$property = strtolower($class);
1047+
isset($this->_ci_varmap[$property]) && $property = $this->_ci_varmap[$property];
1048+
}
1049+
1050+
$CI =& get_instance();
1051+
if (isset($CI->$property))
1052+
{
1053+
log_message('debug', $class.' class already loaded. Second attempt ignored.');
1054+
return;
1055+
}
1056+
1057+
return $this->_ci_init_library($class, '', $params, $object_name);
1058+
}
1059+
10401060
// Let's search for the requested library file and load it.
10411061
foreach ($this->_ci_library_paths as $path)
10421062
{
@@ -1047,27 +1067,8 @@ protected function _ci_load_library($class, $params = NULL, $object_name = NULL)
10471067
}
10481068

10491069
$filepath = $path.'libraries/'.$subdir.$class.'.php';
1050-
1051-
// Safety: Was the class already loaded by a previous call?
1052-
if (class_exists($class, FALSE))
1053-
{
1054-
// Before we deem this to be a duplicate request, let's see
1055-
// if a custom object name is being supplied. If so, we'll
1056-
// return a new instance of the object
1057-
if ($object_name !== NULL)
1058-
{
1059-
$CI =& get_instance();
1060-
if ( ! isset($CI->$object_name))
1061-
{
1062-
return $this->_ci_init_library($class, '', $params, $object_name);
1063-
}
1064-
}
1065-
1066-
log_message('debug', $class.' class already loaded. Second attempt ignored.');
1067-
return;
1068-
}
10691070
// Does the file exist? No? Bummer...
1070-
elseif ( ! file_exists($filepath))
1071+
if ( ! file_exists($filepath))
10711072
{
10721073
continue;
10731074
}
@@ -1112,16 +1113,17 @@ protected function _ci_load_stock_library($library_name, $file_path, $params, $o
11121113
$prefix = config_item('subclass_prefix');
11131114
}
11141115

1115-
// Before we deem this to be a duplicate request, let's see
1116-
// if a custom object name is being supplied. If so, we'll
1117-
// return a new instance of the object
1118-
if ($object_name !== NULL)
1116+
$property = $object_name;
1117+
if (empty($property))
11191118
{
1120-
$CI =& get_instance();
1121-
if ( ! isset($CI->$object_name))
1122-
{
1123-
return $this->_ci_init_library($library_name, $prefix, $params, $object_name);
1124-
}
1119+
$property = strtolower($library_name);
1120+
isset($this->_ci_varmap[$property]) && $property = $this->_ci_varmap[$property];
1121+
}
1122+
1123+
$CI =& get_instance();
1124+
if ( ! isset($CI->$property))
1125+
{
1126+
return $this->_ci_init_library($library_name, $prefix, $params, $object_name);
11251127
}
11261128

11271129
log_message('debug', $library_name.' class already loaded. Second attempt ignored.');
@@ -1143,10 +1145,8 @@ protected function _ci_load_stock_library($library_name, $file_path, $params, $o
11431145
{
11441146
return $this->_ci_init_library($library_name, $prefix, $params, $object_name);
11451147
}
1146-
else
1147-
{
1148-
log_message('debug', $path.' exists, but does not declare '.$prefix.$library_name);
1149-
}
1148+
1149+
log_message('debug', $path.' exists, but does not declare '.$prefix.$library_name);
11501150
}
11511151
}
11521152

@@ -1164,10 +1164,8 @@ protected function _ci_load_stock_library($library_name, $file_path, $params, $o
11641164
$prefix = config_item('subclass_prefix');
11651165
break;
11661166
}
1167-
else
1168-
{
1169-
log_message('debug', $path.' exists, but does not declare '.$subclass);
1170-
}
1167+
1168+
log_message('debug', $path.' exists, but does not declare '.$subclass);
11711169
}
11721170
}
11731171

system/database/DB_driver.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -916,6 +916,7 @@ public function trans_begin($test_mode = FALSE)
916916

917917
if ($this->_trans_begin())
918918
{
919+
$this->_trans_status = TRUE;
919920
$this->_trans_depth++;
920921
return TRUE;
921922
}
@@ -1044,7 +1045,7 @@ public function compile_binds($sql, $binds)
10441045
*/
10451046
public function is_write_type($sql)
10461047
{
1047-
return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX)\s/i', $sql);
1048+
return (bool) preg_match('/^\s*"?(SET|INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|TRUNCATE|LOAD|COPY|ALTER|RENAME|GRANT|REVOKE|LOCK|UNLOCK|REINDEX|MERGE)\s/i', $sql);
10481049
}
10491050

10501051
// --------------------------------------------------------------------

system/database/DB_query_builder.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,11 +1403,9 @@ public function count_all_results($table = '', $reset = TRUE)
14031403
// ORDER BY usage is often problematic here (most notably
14041404
// on Microsoft SQL Server) and ultimately unnecessary
14051405
// for selecting COUNT(*) ...
1406-
if ( ! empty($this->qb_orderby))
1407-
{
1408-
$orderby = $this->qb_orderby;
1409-
$this->qb_orderby = NULL;
1410-
}
1406+
$qb_orderby = $this->qb_orderby;
1407+
$qb_cache_orderby = $this->qb_cache_orderby;
1408+
$this->qb_orderby = $this->qb_cache_orderby = NULL;
14111409

14121410
$result = ($this->qb_distinct === TRUE OR ! empty($this->qb_groupby) OR ! empty($this->qb_cache_groupby) OR $this->qb_limit OR $this->qb_offset)
14131411
? $this->query($this->_count_string.$this->protect_identifiers('numrows')."\nFROM (\n".$this->_compile_select()."\n) CI_count_all_results")
@@ -1417,10 +1415,10 @@ public function count_all_results($table = '', $reset = TRUE)
14171415
{
14181416
$this->_reset_select();
14191417
}
1420-
// If we've previously reset the qb_orderby values, get them back
1421-
elseif ( ! isset($this->qb_orderby))
1418+
else
14221419
{
1423-
$this->qb_orderby = $orderby;
1420+
$this->qb_orderby = $qb_orderby;
1421+
$this->qb_cache_orderby = $qb_cache_orderby;
14241422
}
14251423

14261424
if ($result->num_rows() === 0)

0 commit comments

Comments
 (0)