1
|
|
|
<?php |
|
|
|
|
2
|
|
|
$ariadne = ''; |
3
|
|
|
|
4
|
|
|
function check_php_version() { |
5
|
|
|
if (version_compare(PHP_VERSION, '5.4.7', '>=')) { |
6
|
|
|
return true; |
7
|
|
|
} |
8
|
|
|
return false; |
9
|
|
|
} |
10
|
|
|
|
11
|
|
|
function check_database_support() { |
12
|
|
|
if (check_mysql() || check_postgresql()) { |
13
|
|
|
return true; |
14
|
|
|
} |
15
|
|
|
return false; |
16
|
|
|
} |
17
|
|
|
|
18
|
|
|
function check_mysql() { |
19
|
|
|
if(function_exists('mysqli_connect')) { |
20
|
|
|
return true; |
21
|
|
|
} |
22
|
|
|
return false; |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
function check_postgresql() { |
26
|
|
|
if (function_exists('pg_connect')) { |
27
|
|
|
return true; |
28
|
|
|
} |
29
|
|
|
return false; |
30
|
|
|
} |
31
|
|
|
|
32
|
|
|
function check_apache() { |
|
|
|
|
33
|
|
|
if (preg_match("/^apache/i", $_SERVER['SERVER_SOFTWARE'])) { |
34
|
|
|
return true; |
35
|
|
|
} |
36
|
|
|
return false; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
function check_webserver() { |
40
|
|
|
if ( |
41
|
|
|
check_apache() |
42
|
|
|
// FIXME: Add more compatible webservers. |
|
|
|
|
43
|
|
|
) { |
44
|
|
|
return true; |
45
|
|
|
} |
46
|
|
|
return false; |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
function check_accept_path_info() { |
|
|
|
|
50
|
|
|
if ( function_exists('apache_lookup_uri')) { |
51
|
|
|
$extrapath = "/test_path_info/"; |
52
|
|
|
$object = apache_lookup_uri($_SERVER['REQUEST_URI'] . $extrapath); |
53
|
|
|
if ($object->path_info == $extrapath) { |
54
|
|
|
return true; |
55
|
|
|
} |
56
|
|
|
return false; |
57
|
|
|
} else { |
58
|
|
|
$ariadne = ''; |
59
|
|
|
@include("../ariadne.inc"); |
|
|
|
|
60
|
|
|
if ( $ariadne != '' ) { |
61
|
|
|
require_once($ariadne . '/ar.php'); |
62
|
|
|
|
63
|
|
|
// checking if path_info could be available |
64
|
|
|
$testuri = new ar_url('http://' . $_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]); |
65
|
|
|
$testuri->query = ''; |
|
|
|
|
66
|
|
|
$testuri->path = str_replace('/index.php', '/', $testuri->path)."serverinfo.php"; |
|
|
|
|
67
|
|
|
$testuri = (string)$testuri; |
68
|
|
|
$result1 = json_decode(ar_http::get($testuri),true); |
69
|
|
|
$result2 = json_decode(ar_http::get($testuri.'/my/path/info'),true); |
70
|
|
|
|
71
|
|
|
if ( is_array($result1) && is_array($result2) ) { |
72
|
|
|
// self request works |
73
|
|
|
// pathinfo could work |
74
|
|
|
if( $result2['server']['PATH_INFO'] == '/my/path/info' ) { |
75
|
|
|
return true; |
76
|
|
|
} else { |
77
|
|
|
return false; |
78
|
|
|
} |
79
|
|
|
} elseif ( is_array($result1) && is_null($result2) ) { |
80
|
|
|
// self request works |
81
|
|
|
// request with pathinfo fails |
82
|
|
|
return false; |
83
|
|
|
} else { |
84
|
|
|
// self request fails |
85
|
|
|
// should return 'check via browser' |
86
|
|
|
return false; |
87
|
|
|
} |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
return false; |
91
|
|
|
} |
92
|
|
|
|
93
|
|
|
function check_zend_compat() { |
94
|
|
|
if (!ini_get("zend.ze1_compatibility_mode")) { |
95
|
|
|
return true; |
96
|
|
|
} |
97
|
|
|
return false; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
function check_ariadne_inc_read() { |
101
|
|
|
if (is_readable("../ariadne.inc")) { |
102
|
|
|
return true; |
103
|
|
|
} |
104
|
|
|
return false; |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
function check_ariadne_path() { |
108
|
|
|
@include("../ariadne.inc"); |
|
|
|
|
109
|
|
|
if (is_readable($ariadne . "/templates/pobject/")) { |
|
|
|
|
110
|
|
|
return true; |
111
|
|
|
} |
112
|
|
|
return false; |
113
|
|
|
} |
114
|
|
|
|
115
|
|
|
|
116
|
|
|
function check_files_write() { |
117
|
|
|
@include("../ariadne.inc"); |
|
|
|
|
118
|
|
|
if (is_writable($ariadne . "/../files/")) { |
|
|
|
|
119
|
|
|
return true; |
120
|
|
|
} |
121
|
|
|
return false; |
122
|
|
|
} |
123
|
|
|
|
124
|
|
|
function check_ariadne_phtml_write() { |
125
|
|
|
@include("../ariadne.inc"); |
|
|
|
|
126
|
|
|
if (file_exists($ariadne . "/configs/ariadne.phtml")) { |
127
|
|
|
if (is_writable($ariadne . "/configs/ariadne.phtml")) { |
|
|
|
|
128
|
|
|
return true; |
129
|
|
|
} |
130
|
|
|
} else { |
131
|
|
|
if (is_writable($ariadne . "/configs/")) { |
132
|
|
|
return true; |
133
|
|
|
} |
134
|
|
|
} |
135
|
|
|
return false; |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
function check_im_convert() { |
139
|
|
|
$bin = find_in_path('convert'); |
140
|
|
|
if (is_executable($bin)) { |
141
|
|
|
global $found_bins; |
142
|
|
|
$found_bins['bin_convert'] = $bin; |
143
|
|
|
return true; |
144
|
|
|
} |
145
|
|
|
return false; |
146
|
|
|
} |
147
|
|
|
|
148
|
|
|
function check_im_mogrify() { |
149
|
|
|
$bin = find_in_path('mogrify'); |
150
|
|
|
if (is_executable($bin)) { |
151
|
|
|
global $found_bins; |
152
|
|
|
$found_bins['bin_mogrify'] = $bin; |
153
|
|
|
return true; |
154
|
|
|
} |
155
|
|
|
return false; |
156
|
|
|
} |
157
|
|
|
|
158
|
|
|
function check_im_composite() { |
159
|
|
|
$bin = find_in_path('composite'); |
160
|
|
|
if (is_executable($bin)) { |
161
|
|
|
global $found_bins; |
162
|
|
|
$found_bins['bin_composite'] = $bin; |
163
|
|
|
return true; |
164
|
|
|
} |
165
|
|
|
return false; |
166
|
|
|
} |
167
|
|
|
|
168
|
|
|
function check_im_identify() { |
169
|
|
|
$bin = find_in_path('identify'); |
170
|
|
|
if (is_executable($bin)) { |
171
|
|
|
global $found_bins; |
172
|
|
|
$found_bins['bin_identify'] = $bin; |
173
|
|
|
return true; |
174
|
|
|
} |
175
|
|
|
return false; |
176
|
|
|
} |
177
|
|
|
|
178
|
|
|
function check_image_magick() { |
179
|
|
|
if ( |
180
|
|
|
check_im_convert() && |
181
|
|
|
check_im_mogrify() && |
182
|
|
|
check_im_composite() && |
183
|
|
|
check_im_identify() |
184
|
|
|
) { |
185
|
|
|
return true; |
186
|
|
|
} |
187
|
|
|
return false; |
188
|
|
|
} |
189
|
|
|
|
190
|
|
|
function check_svn() { |
191
|
|
|
if ( |
192
|
|
|
check_svn_class() && |
193
|
|
|
check_svn_binary() |
194
|
|
|
) { |
195
|
|
|
return true; |
196
|
|
|
} |
197
|
|
|
return false; |
198
|
|
|
} |
199
|
|
|
|
200
|
|
|
function check_svn_class() { |
201
|
|
|
@include_once("VersionControl/SVN.php"); |
|
|
|
|
202
|
|
|
if (class_exists("VersionControl_SVN")) { |
203
|
|
|
return true; |
204
|
|
|
} |
205
|
|
|
return false; |
206
|
|
|
} |
207
|
|
|
|
208
|
|
View Code Duplication |
function check_svn_binary() { |
|
|
|
|
209
|
|
|
$bin = find_in_path('svn'); |
210
|
|
|
if (is_executable($bin)) { |
211
|
|
|
global $found_bins; |
212
|
|
|
$found_bins['bin_svn'] = $bin; |
213
|
|
|
return true; |
214
|
|
|
} |
215
|
|
|
return false; |
216
|
|
|
} |
217
|
|
|
|
218
|
|
|
function check_svn_write() { |
219
|
|
|
@include("../ariadne.inc"); |
|
|
|
|
220
|
|
|
if (is_writeable($ariadne . "/configs/svn/")) { |
|
|
|
|
221
|
|
|
return true; |
222
|
|
|
} |
223
|
|
|
return false; |
224
|
|
|
} |
225
|
|
|
|
226
|
|
View Code Duplication |
function check_html_tidy() { |
|
|
|
|
227
|
|
|
$bin = find_in_path('tidy'); |
228
|
|
|
if (is_executable($bin)) { |
229
|
|
|
global $found_bins; |
230
|
|
|
$found_bins['bin_tidy'] = $bin; |
231
|
|
|
return true; |
232
|
|
|
} |
233
|
|
|
return false; |
234
|
|
|
} |
235
|
|
|
|
236
|
|
View Code Duplication |
function check_grep() { |
|
|
|
|
237
|
|
|
$bin = find_in_path('grep'); |
238
|
|
|
if (is_executable($bin)) { |
239
|
|
|
global $found_bins; |
240
|
|
|
$found_bins['bin_grep'] = $bin; |
241
|
|
|
return true; |
242
|
|
|
} |
243
|
|
|
return false; |
244
|
|
|
} |
245
|
|
|
|
246
|
|
|
function check_connect_db($conf) { |
247
|
|
View Code Duplication |
if ($conf && $conf->dbms) { |
248
|
|
|
switch ( $conf->dbms ) { |
249
|
|
|
case 'mysql': |
250
|
|
|
case 'mysql_workspaces': |
251
|
|
|
return check_connect_db_mysql($conf); |
252
|
|
|
break; |
253
|
|
|
case 'postgresql': |
254
|
|
|
return check_connect_db_postgresql($conf); |
255
|
|
|
break; |
256
|
|
|
} |
257
|
|
|
// FIXME: Add postgresql checks too |
|
|
|
|
258
|
|
|
} |
259
|
|
|
return false; |
260
|
|
|
} |
261
|
|
|
|
262
|
|
|
function check_select_db($conf) { |
263
|
|
View Code Duplication |
if ($conf && $conf->dbms) { |
264
|
|
|
switch ( $conf->dbms ) { |
265
|
|
|
case 'mysql': |
266
|
|
|
case 'mysql_workspaces': |
267
|
|
|
return check_select_db_mysql($conf); |
268
|
|
|
break; |
269
|
|
|
case 'postgresql': |
270
|
|
|
return check_select_db_postgresql($conf); |
271
|
|
|
break; |
272
|
|
|
} |
273
|
|
|
} |
274
|
|
|
return false; |
275
|
|
|
} |
276
|
|
|
|
277
|
|
|
function check_db_grants($conf) { |
278
|
|
View Code Duplication |
if ($conf && $conf->dbms) { |
279
|
|
|
switch ( $conf->dbms ) { |
280
|
|
|
case 'mysql': |
281
|
|
|
case 'mysql_workspaces': |
282
|
|
|
return check_db_grants_mysql($conf); |
283
|
|
|
break; |
284
|
|
|
case 'postgresql': |
285
|
|
|
return check_db_grants_postgresql($conf); |
286
|
|
|
break; |
287
|
|
|
} |
288
|
|
|
} |
289
|
|
|
return false; |
290
|
|
|
} |
291
|
|
|
|
292
|
|
|
function check_db_grants_mysql($conf) { |
293
|
|
|
$dbh = getConnection($conf); |
294
|
|
|
if (!$dbh->connect_errno) { |
295
|
|
|
$query = "SHOW GRANTS FOR CURRENT_USER();"; |
296
|
|
|
|
297
|
|
|
$result = $dbh->query($query); |
298
|
|
|
if (!$dbh->errno ) { |
299
|
|
|
while ($row = $result->fetch_row()){ |
300
|
|
|
if (preg_match("/^GRANT ALL/", $row[0])) { |
301
|
|
|
return true; |
302
|
|
|
} |
303
|
|
|
if ( |
304
|
|
|
preg_match("/^GRANT.*?SELECT.*?ON/", $row[0]) && |
305
|
|
|
preg_match("/^GRANT.*?INSERT.*?ON/", $row[0]) && |
306
|
|
|
preg_match("/^GRANT.*?UPDATE.*?ON/", $row[0]) && |
307
|
|
|
preg_match("/^GRANT.*?CREATE.*?ON/", $row[0]) && |
308
|
|
|
preg_match("/^GRANT.*?DELETE.*?ON/", $row[0]) |
309
|
|
|
) { |
310
|
|
|
return true; |
311
|
|
|
} |
312
|
|
|
} |
313
|
|
|
} |
314
|
|
|
} |
315
|
|
|
return false; |
316
|
|
|
} |
317
|
|
|
|
318
|
|
|
function check_db_grants_postgresql($conf) { |
319
|
|
|
if ( check_select_db_postgresql($conf) ) { |
320
|
|
|
$query = "SELECT has_database_privilege ( '".$conf->database."', 'CREATE' );"; |
321
|
|
|
$result = pg_query( $query ); |
322
|
|
|
while ( $row = pg_fetch_row( $result ) ) { |
323
|
|
|
if ( $row[0]=='t' ) { |
324
|
|
|
return true; |
325
|
|
|
} |
326
|
|
|
} |
327
|
|
|
} |
328
|
|
|
return false; |
329
|
|
|
} |
330
|
|
|
|
331
|
|
|
function getConnection($conf){ |
332
|
|
|
static $dbh; |
333
|
|
|
if(!isset($dbh)) { |
334
|
|
|
$dbh = new mysqli($conf->host, $conf->user, $conf->password, $conf->database); |
335
|
|
|
} |
336
|
|
|
return $dbh; |
337
|
|
|
} |
338
|
|
|
|
339
|
|
|
function check_connect_db_mysql($conf) { |
340
|
|
|
$dbh = getConnection($conf); |
341
|
|
|
if ($dbh->connect_errno) { |
342
|
|
|
return false; |
343
|
|
|
} |
344
|
|
|
return true; |
345
|
|
|
} |
346
|
|
|
|
347
|
|
|
function check_connect_db_postgresql($conf) { |
348
|
|
|
$port = null; |
349
|
|
|
$host = $conf->host; |
|
|
|
|
350
|
|
|
if ( strpos($conf->host,':') !== false) { |
351
|
|
|
list($host,$port) = explode($conf->host, ':',2); |
|
|
|
|
352
|
|
|
} |
353
|
|
|
|
354
|
|
|
if( $conf->host == ''){ |
355
|
|
|
$hoststr = ''; |
356
|
|
|
} else { |
357
|
|
|
$hoststr = 'host='.$conf->host; |
358
|
|
|
} |
359
|
|
|
|
360
|
|
|
if ($port) { |
361
|
|
|
$hoststr = $hoststr .= ' port='.$port; |
362
|
|
|
} |
363
|
|
|
|
364
|
|
|
if( $conf->password != '' ){ |
365
|
|
|
$password = ' password='.$conf->password; |
366
|
|
|
} |
367
|
|
|
|
368
|
|
|
$connstring = $hoststr.' dbname='.$conf->database.' user='.$conf->user . ' ' .$password; |
|
|
|
|
369
|
|
|
$conf->connection = pg_connect($connstring); |
370
|
|
|
return (bool) $conf->connection; |
371
|
|
|
} |
372
|
|
|
|
373
|
|
|
function check_select_db_mysql($conf) { |
374
|
|
|
return check_connect_db_mysql($conf); //connect also checks database |
375
|
|
|
} |
376
|
|
|
|
377
|
|
|
function check_select_db_postgresql($conf) { |
378
|
|
|
return check_connect_db_postgresql($conf); //connect also checks database |
379
|
|
|
} |
380
|
|
|
|
381
|
|
|
|
382
|
|
|
function check_db_is_empty($conf) { |
383
|
|
|
switch( $conf->dbms ) { |
384
|
|
|
case 'mysql': |
385
|
|
|
case 'mysql_workspaces': |
386
|
|
|
return check_db_is_empty_mysql($conf); |
387
|
|
|
break; |
388
|
|
|
case 'postgresql': |
389
|
|
|
return check_db_is_empty_postgresql($conf); |
390
|
|
|
break; |
391
|
|
|
} |
392
|
|
|
return false; |
393
|
|
|
} |
394
|
|
|
|
395
|
|
|
function check_db_is_empty_mysql($conf) { |
396
|
|
|
$dbh = getConnection($conf); |
397
|
|
|
if (!$dbh->connect_errno) { |
398
|
|
|
$query = "SHOW TABLES;"; |
399
|
|
|
$result = $dbh->query($query); |
400
|
|
|
if (!$dbh->errno && $result->num_rows == 0) { |
401
|
|
|
return true; |
402
|
|
|
} |
403
|
|
|
} |
404
|
|
|
return false; |
405
|
|
|
} |
406
|
|
|
|
407
|
|
|
function check_db_is_empty_postgresql($conf) { |
408
|
|
|
if (check_connect_db_postgresql($conf)) { |
409
|
|
|
$query = "SELECT table_name FROM information_schema.tables WHERE table_schema = 'public';"; |
410
|
|
|
$result = pg_query($conf->connection, $query); |
411
|
|
|
if (pg_num_rows($result) == 0) { |
412
|
|
|
return true; |
413
|
|
|
} |
414
|
|
|
} |
415
|
|
|
return false; |
416
|
|
|
} |
417
|
|
|
|
418
|
|
|
function check_file( $file ) { |
|
|
|
|
419
|
|
|
if (file_exists($file) && is_readable($file)) { |
420
|
|
|
return true; |
421
|
|
|
} |
422
|
|
|
return false; |
423
|
|
|
} |
424
|
|
|
|
425
|
|
|
function check_base_ax() { |
426
|
|
|
if (check_file("packages/base.ax")) { |
427
|
|
|
return true; |
428
|
|
|
} |
429
|
|
|
return false; |
430
|
|
|
} |
431
|
|
|
|
432
|
|
|
function check_demo_ax() { |
433
|
|
|
if (check_file("packages/demo.ax")) { |
434
|
|
|
return true; |
435
|
|
|
} |
436
|
|
|
return false; |
437
|
|
|
} |
438
|
|
|
|
439
|
|
|
function check_libs_ax() { |
440
|
|
|
if (check_file("packages/libs.ax")) { |
441
|
|
|
return true; |
442
|
|
|
} |
443
|
|
|
return false; |
444
|
|
|
} |
445
|
|
|
|
446
|
|
|
function check_docs_ax() { |
447
|
|
|
if (check_file("packages/docs.ax")) { |
448
|
|
|
return true; |
449
|
|
|
} |
450
|
|
|
return false; |
451
|
|
|
} |
452
|
|
|
|
453
|
|
|
function check_admin_password($admin_passwords) { |
454
|
|
|
if ($admin_passwords[0] && $admin_passwords[1] && $admin_passwords[0] == $admin_passwords[1]) { |
455
|
|
|
return true; |
456
|
|
|
} |
457
|
|
|
return false; |
458
|
|
|
} |
459
|
|
|
|
460
|
|
|
function check_tar_class() { |
461
|
|
|
@include_once("Archive/Tar.php"); |
|
|
|
|
462
|
|
|
if (class_exists("Archive_Tar")) { |
463
|
|
|
return true; |
464
|
|
|
} |
465
|
|
|
return false; |
466
|
|
|
} |
467
|
|
|
|
468
|
|
|
function check_exif() { |
469
|
|
|
if (function_exists('exif_read_data')) { |
470
|
|
|
return true; |
471
|
|
|
} |
472
|
|
|
return false; |
473
|
|
|
} |
474
|
|
|
|
475
|
|
|
function check_mb_functions() { |
476
|
|
|
if (function_exists('mb_substr')) { |
477
|
|
|
return true; |
478
|
|
|
} |
479
|
|
|
return false; |
480
|
|
|
} |
481
|
|
|
|
482
|
|
|
function check_mcrypt() { |
483
|
|
|
if (extension_loaded('mcrypt')) { |
484
|
|
|
return true; |
485
|
|
|
} |
486
|
|
|
return false; |
487
|
|
|
} |
488
|
|
|
|
489
|
|
|
function getServerVar( $name ) { |
|
|
|
|
490
|
|
|
return isset( $_SERVER[$name] ) ? $_SERVER[$name] : null; |
491
|
|
|
} |
492
|
|
|
|
493
|
|
|
function find_in_path($needle,array $extrapath=array()) { |
494
|
|
|
$paths = explode(PATH_SEPARATOR,getServerVar('PATH')); |
495
|
|
|
$paths = array_merge($paths,$extrapath); |
496
|
|
|
|
497
|
|
|
$exts = explode(PATH_SEPARATOR, getServerVar('PATHEXT')); |
498
|
|
|
|
499
|
|
|
foreach($paths as $path){ |
500
|
|
|
$file = $path . DIRECTORY_SEPARATOR . $needle; |
501
|
|
|
if(file_exists($file)) { |
502
|
|
|
return $file; |
503
|
|
|
} |
504
|
|
|
|
505
|
|
|
// W32 needs this |
506
|
|
|
foreach ($exts as $ext) { |
507
|
|
|
if(file_exists($file.$ext)) { |
508
|
|
|
return $file.$ext; |
509
|
|
|
} |
510
|
|
|
} |
511
|
|
|
} |
512
|
|
|
} |
513
|
|
|
|
514
|
|
|
$found_bins = array(); // will be filled by the check functions |
515
|
|
|
|
516
|
|
|
$required_checks = array( |
517
|
|
|
"check_php_version" => check_php_version(), // php => 5.4.0 |
|
|
|
|
518
|
|
|
"check_database_support" => check_database_support(), // MySQL or Postgres |
519
|
|
|
"check_webserver" => check_webserver(), // Apache, IIS, NGINX? |
520
|
|
|
"check_accept_path_info" => check_accept_path_info(), // Apache config: AcceptPathInfo |
521
|
|
|
"check_zend_compat" => check_zend_compat(), // zend.ze1_compatibility_mode = Off |
522
|
|
|
"check_ariadne_inc_read" => check_ariadne_inc_read(), // Check if configuration file (ariadne.inc) can be read bij www-data |
523
|
|
|
"check_ariadne_path" => check_ariadne_path(), // Check if path in ariadne.inc looks like an Ariadne tree |
524
|
|
|
"check_files_write" => check_files_write(), // Check if files dir can be written by www-data |
525
|
|
|
"check_base_ax" => check_base_ax(), |
526
|
|
|
"check_tar_class" => check_tar_class(), // Check if Archive/Tar class is available to import packages with. |
527
|
|
|
"check_mb_functions" => check_mb_functions(), // Check if Archive/Tar class is available to import packages with. |
528
|
|
|
); |
529
|
|
|
|
530
|
|
|
$recommended_checks = array( |
531
|
|
|
"check_ariadne_phtml_write" => check_ariadne_phtml_write(), // Check if configuration file (ariadne.phtml) can be written bij www-data |
532
|
|
|
"check_exif" => check_exif(), |
533
|
|
|
"check_image_magick" => check_image_magick(), |
534
|
|
|
"check_svn" => check_svn(), |
535
|
|
|
"check_svn_write" => check_svn_write(), |
536
|
|
|
"check_html_tidy" => check_html_tidy(), |
537
|
|
|
"check_grep" => check_grep(), |
538
|
|
|
"check_demo_ax" => check_demo_ax(), |
539
|
|
|
"check_mcrypt" => check_mcrypt(), |
540
|
|
|
// "check_libs_ax" => check_libs_ax(), |
|
|
|
|
541
|
|
|
// "check_docs_ax" => check_docs_ax() |
542
|
|
|
); |
543
|
|
|
|
544
|
|
|
?> |
|
|
|
|
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.