Skip to content

Commit e86e1d2

Browse files
committed
Update index.php
1 parent 8d12057 commit e86e1d2

File tree

1 file changed

+89
-115
lines changed

1 file changed

+89
-115
lines changed

index.php

Lines changed: 89 additions & 115 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* CodeIgniter
45
*
@@ -53,7 +54,7 @@
5354
*
5455
* NOTE: If you change these, also change the error_reporting() code below
5556
*/
56-
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
57+
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'production');
5758

5859
/*
5960
*---------------------------------------------------------------
@@ -63,25 +64,21 @@
6364
* Different environments will require different levels of error reporting.
6465
* By default development will show errors but testing and live will hide them.
6566
*/
66-
switch (ENVIRONMENT)
67-
{
67+
switch (ENVIRONMENT) {
6868
case 'development':
6969
error_reporting(-1);
7070
ini_set('display_errors', 1);
71-
break;
71+
break;
7272

7373
case 'testing':
7474
case 'production':
7575
ini_set('display_errors', 0);
76-
if (version_compare(PHP_VERSION, '5.3', '>='))
77-
{
76+
if (version_compare(PHP_VERSION, '5.3', '>=')) {
7877
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
79-
}
80-
else
81-
{
78+
} else {
8279
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
8380
}
84-
break;
81+
break;
8582

8683
default:
8784
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
@@ -97,7 +94,7 @@
9794
* This variable must contain the name of your "system" directory.
9895
* Set the path if it is not in the same directory as this file.
9996
*/
100-
$system_path = 'system';
97+
$system_path = 'system';
10198

10299
/*
103100
*---------------------------------------------------------------
@@ -114,7 +111,7 @@
114111
*
115112
* NO TRAILING SLASH!
116113
*/
117-
$application_folder = 'application';
114+
$application_folder = 'application';
118115

119116
/*
120117
*---------------------------------------------------------------
@@ -129,7 +126,7 @@
129126
*
130127
* NO TRAILING SLASH!
131128
*/
132-
$view_folder = '';
129+
$view_folder = '';
133130

134131

135132
/*
@@ -151,15 +148,15 @@
151148
*
152149
* Un-comment the $routing array below to use this feature
153150
*/
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
156-
// $routing['directory'] = '';
151+
// The directory name, relative to the "controllers" directory. Leave blank
152+
// if your controller is not in a sub-directory within the "controllers" one
153+
// $routing['directory'] = '';
157154

158-
// The controller class file name. Example: mycontroller
159-
// $routing['controller'] = '';
155+
// The controller class file name. Example: mycontroller
156+
// $routing['controller'] = '';
160157

161-
// The controller function you wish to be called.
162-
// $routing['function'] = '';
158+
// The controller function you wish to be called.
159+
// $routing['function'] = '';
163160

164161

165162
/*
@@ -176,7 +173,7 @@
176173
*
177174
* Un-comment the $assign_to_config array below to use this feature
178175
*/
179-
// $assign_to_config['name_of_config_item'] = 'value of config item';
176+
// $assign_to_config['name_of_config_item'] = 'value of config item';
180177

181178

182179

@@ -190,120 +187,97 @@
190187
* ---------------------------------------------------------------
191188
*/
192189

193-
// Set the current directory correctly for CLI requests
194-
if (defined('STDIN'))
195-
{
196-
chdir(dirname(__FILE__));
197-
}
190+
// Set the current directory correctly for CLI requests
191+
if (defined('STDIN')) {
192+
chdir(dirname(__FILE__));
193+
}
198194

199-
if (($_temp = realpath($system_path)) !== FALSE)
200-
{
201-
$system_path = $_temp.DIRECTORY_SEPARATOR;
202-
}
203-
else
204-
{
205-
// Ensure there's a trailing slash
206-
$system_path = strtr(
207-
rtrim($system_path, '/\\'),
208-
'/\\',
209-
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
210-
).DIRECTORY_SEPARATOR;
211-
}
195+
if (($_temp = realpath($system_path)) !== FALSE) {
196+
$system_path = $_temp . DIRECTORY_SEPARATOR;
197+
} else {
198+
// Ensure there's a trailing slash
199+
$system_path = strtr(
200+
rtrim($system_path, '/\\'),
201+
'/\\',
202+
DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
203+
) . DIRECTORY_SEPARATOR;
204+
}
212205

213-
// Is the system path correct?
214-
if ( ! is_dir($system_path))
215-
{
216-
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
217-
echo 'Your system folder path does not appear to be set correctly. Please open the following file and correct this: '.pathinfo(__FILE__, PATHINFO_BASENAME);
218-
exit(3); // EXIT_CONFIG
219-
}
206+
// Is the system path correct?
207+
if (!is_dir($system_path)) {
208+
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
209+
echo 'Your system folder path does not appear to be set correctly. Please open the following file and correct this: ' . pathinfo(__FILE__, PATHINFO_BASENAME);
210+
exit(3); // EXIT_CONFIG
211+
}
220212

221213
/*
222214
* -------------------------------------------------------------------
223215
* Now that we know the path, set the main path constants
224216
* -------------------------------------------------------------------
225217
*/
226-
// The name of THIS file
227-
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
218+
// The name of THIS file
219+
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
228220

229-
// Path to the system directory
230-
define('BASEPATH', $system_path);
221+
// Path to the system directory
222+
define('BASEPATH', $system_path);
231223

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

235-
// Name of the "system" directory
236-
define('SYSDIR', basename(BASEPATH));
227+
// Name of the "system" directory
228+
define('SYSDIR', basename(BASEPATH));
237229

238-
// The path to the "application" directory
239-
if (is_dir($application_folder))
240-
{
241-
if (($_temp = realpath($application_folder)) !== FALSE)
242-
{
243-
$application_folder = $_temp;
244-
}
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, '/\\'),
230+
// The path to the "application" directory
231+
if (is_dir($application_folder)) {
232+
if (($_temp = realpath($application_folder)) !== FALSE) {
233+
$application_folder = $_temp;
234+
} else {
235+
$application_folder = strtr(
236+
rtrim($application_folder, '/\\'),
258237
'/\\',
259-
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
238+
DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
260239
);
261240
}
262-
else
263-
{
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
267-
}
241+
} elseif (is_dir(BASEPATH . $application_folder . DIRECTORY_SEPARATOR)) {
242+
$application_folder = BASEPATH . strtr(
243+
trim($application_folder, '/\\'),
244+
'/\\',
245+
DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
246+
);
247+
} else {
248+
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
249+
echo 'Your application folder path does not appear to be set correctly. Please open the following file and correct this: ' . SELF;
250+
exit(3); // EXIT_CONFIG
251+
}
268252

269-
define('APPPATH', $application_folder.DIRECTORY_SEPARATOR);
253+
define('APPPATH', $application_folder . DIRECTORY_SEPARATOR);
270254

271-
// The path to the "views" directory
272-
if ( ! isset($view_folder[0]) && is_dir(APPPATH.'views'.DIRECTORY_SEPARATOR))
273-
{
274-
$view_folder = APPPATH.'views';
275-
}
276-
elseif (is_dir($view_folder))
277-
{
278-
if (($_temp = realpath($view_folder)) !== FALSE)
279-
{
280-
$view_folder = $_temp;
281-
}
282-
else
283-
{
284-
$view_folder = strtr(
285-
rtrim($view_folder, '/\\'),
286-
'/\\',
287-
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
288-
);
289-
}
290-
}
291-
elseif (is_dir(APPPATH.$view_folder.DIRECTORY_SEPARATOR))
292-
{
293-
$view_folder = APPPATH.strtr(
294-
trim($view_folder, '/\\'),
255+
// The path to the "views" directory
256+
if (!isset($view_folder[0]) && is_dir(APPPATH . 'views' . DIRECTORY_SEPARATOR)) {
257+
$view_folder = APPPATH . 'views';
258+
} elseif (is_dir($view_folder)) {
259+
if (($_temp = realpath($view_folder)) !== FALSE) {
260+
$view_folder = $_temp;
261+
} else {
262+
$view_folder = strtr(
263+
rtrim($view_folder, '/\\'),
295264
'/\\',
296-
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
265+
DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
297266
);
298267
}
299-
else
300-
{
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
304-
}
268+
} elseif (is_dir(APPPATH . $view_folder . DIRECTORY_SEPARATOR)) {
269+
$view_folder = APPPATH . strtr(
270+
trim($view_folder, '/\\'),
271+
'/\\',
272+
DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR
273+
);
274+
} else {
275+
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
276+
echo 'Your view folder path does not appear to be set correctly. Please open the following file and correct this: ' . SELF;
277+
exit(3); // EXIT_CONFIG
278+
}
305279

306-
define('VIEWPATH', $view_folder.DIRECTORY_SEPARATOR);
280+
define('VIEWPATH', $view_folder . DIRECTORY_SEPARATOR);
307281

308282
/*
309283
* --------------------------------------------------------------------
@@ -312,4 +286,4 @@
312286
*
313287
* And away we go...
314288
*/
315-
require_once BASEPATH.'core/CodeIgniter.php';
289+
require_once BASEPATH . 'core/CodeIgniter.php';

0 commit comments

Comments
 (0)