Skip to content

Commit 133112c

Browse files
committed
CodeIgniter-Blog v2.4.2 Optimized website UI, Added the Benchmark function.
1 parent 885c08d commit 133112c

4 files changed

Lines changed: 138 additions & 135 deletions

File tree

application/views/article.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
</div>
3131
<a class="article-time">时间:<?php echo $rows->date;?></a>
3232
<a class="article-type">分类:<?php echo $rows->type;?></a>
33+
<strong>服务器君耗时 {elapsed_time} 秒,内存消耗 {memory_usage}</strong>
3334
<div class="article-content">
3435
<p><?php echo $rows->content;?></p>
3536
</div>

application/views/diaries_details.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@
2828
<div class="left" id="learn">
2929
<div class="content_text">
3030
<div class="article-title"></div>
31-
<a class="article-time">时间:<?php echo $rows['date'];?></a>
32-
<a class="article-type">分类:<?php echo $rows['type'];?></a>
31+
<a class="article-time">时间:<?php echo $rows['date'];?></a>
32+
<a class="article-type">分类:<?php echo $rows['type'];?></a>
33+
<strong>服务器君耗时 {elapsed_time} 秒,内存消耗 {memory_usage}</strong>
3334
<div class="article-content">
3435
<p><?php echo $rows['content'];?></p>
3536
</div>

application/views/search.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@
2929
<div class="article-title">
3030
<h1><?php echo $row->title;?></h1>
3131
</div>
32-
<a class="article-time">时间:<?php echo $row->date;?></a>
33-
<a class="article-type">分类:<?php echo $row->type;?></a>
32+
<a class="article-time">时间:<?php echo $row->date;?></a>
33+
<a class="article-type">分类:<?php echo $row->type;?></a>
34+
<strong>服务器君耗时 {elapsed_time} 秒,内存消耗 {memory_usage}</strong>
3435
<div class="article-content">
3536
<p><?php echo $row->content;?></p>
3637
</div>

index.php

Lines changed: 131 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
*
5454
* NOTE: If you change these, also change the error_reporting() code below
5555
*/
56-
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
56+
define('ENVIRONMENT', isset($_SERVER['CI_ENV']) ? $_SERVER['CI_ENV'] : 'development');
5757

5858
/*
5959
*---------------------------------------------------------------
@@ -65,28 +65,28 @@
6565
*/
6666
switch (ENVIRONMENT)
6767
{
68-
case 'development':
69-
error_reporting(-1);
70-
ini_set('display_errors', 1);
71-
break;
68+
case 'development':
69+
error_reporting(-1);
70+
ini_set('display_errors', 1);
71+
break;
7272

73-
case 'testing':
74-
case 'production':
75-
ini_set('display_errors', 0);
76-
if (version_compare(PHP_VERSION, '5.3', '>='))
77-
{
78-
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
79-
}
80-
else
81-
{
82-
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
83-
}
84-
break;
73+
case 'testing':
74+
case 'production':
75+
ini_set('display_errors', 0);
76+
if (version_compare(PHP_VERSION, '5.3', '>='))
77+
{
78+
error_reporting(E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_STRICT & ~E_USER_NOTICE & ~E_USER_DEPRECATED);
79+
}
80+
else
81+
{
82+
error_reporting(E_ALL & ~E_NOTICE & ~E_STRICT & ~E_USER_NOTICE);
83+
}
84+
break;
8585

86-
default:
87-
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
88-
echo 'The application environment is not set correctly.';
89-
exit(1); // EXIT_ERROR
86+
default:
87+
header('HTTP/1.1 503 Service Unavailable.', TRUE, 503);
88+
echo 'The application environment is not set correctly.';
89+
exit(1); // EXIT_ERROR
9090
}
9191

9292
/*
@@ -97,7 +97,7 @@
9797
* This variable must contain the name of your "system" directory.
9898
* Set the path if it is not in the same directory as this file.
9999
*/
100-
$system_path = 'system';
100+
$system_path = 'system';
101101

102102
/*
103103
*---------------------------------------------------------------
@@ -114,7 +114,7 @@
114114
*
115115
* NO TRAILING SLASH!
116116
*/
117-
$application_folder = 'application';
117+
$application_folder = 'application';
118118

119119
/*
120120
*---------------------------------------------------------------
@@ -129,7 +129,7 @@
129129
*
130130
* NO TRAILING SLASH!
131131
*/
132-
$view_folder = '';
132+
$view_folder = '';
133133

134134

135135
/*
@@ -151,15 +151,15 @@
151151
*
152152
* Un-comment the $routing array below to use this feature
153153
*/
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'] = '';
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'] = '';
157157

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

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

164164

165165
/*
@@ -176,7 +176,7 @@
176176
*
177177
* Un-comment the $assign_to_config array below to use this feature
178178
*/
179-
// $assign_to_config['name_of_config_item'] = 'value of config item';
179+
// $assign_to_config['name_of_config_item'] = 'value of config item';
180180

181181

182182

@@ -190,120 +190,120 @@
190190
* ---------------------------------------------------------------
191191
*/
192192

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

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-
}
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+
}
212212

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-
}
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+
}
220220

221221
/*
222222
* -------------------------------------------------------------------
223223
* Now that we know the path, set the main path constants
224224
* -------------------------------------------------------------------
225225
*/
226-
// The name of THIS file
227-
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
226+
// The name of THIS file
227+
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
228228

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

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

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

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, '/\\'),
258-
'/\\',
259-
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
260-
);
261-
}
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-
}
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, '/\\'),
258+
'/\\',
259+
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
260+
);
261+
}
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+
}
268268

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

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, '/\\'),
295-
'/\\',
296-
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
297-
);
298-
}
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-
}
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, '/\\'),
295+
'/\\',
296+
DIRECTORY_SEPARATOR.DIRECTORY_SEPARATOR
297+
);
298+
}
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+
}
305305

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

308308
/*
309309
* --------------------------------------------------------------------

0 commit comments

Comments
 (0)